青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Using the .X File Format(2)

Defining Templates

Since an .X file's open−ended design is so, well, open−ended, you must predefine each template that you intend to use for DirectX to understand how to access the template's data. Typically templates are defined inside an .X file, although you can define them from within your program (as I mentioned earlier).

You define a template (contained in an .X file) by assigning it a unique class name preceded by the word template, as I have done in the following line of text. (Notice the opening bracket, which signifies the start of the template's definition.)

template ContactEntry {

Cool−now you've started the declaration of a template that you will use to store a person's contact information. We're calling the template class ContactEntry, as you can see from the code. Even though you have assigned your template a unique class name, you need to go one step further and also assign it a unique identification number−a GUID.

When you get around to reading an .X file into your program, you'll only have access to the GUIDs of each template, not the class names. The class names are important only to your .X file data objects; you want your program to differentiate those data objects by their template GUIDs.

To define a GUID for your template, fire up the guidgen.exe program that comes with your Microsoft Visual C/C++ compiler installation (located in the \Common\Tools directory of your MSVC installation). After you've found and executed the guidgen.exe file, you'll be presented with a small dialog box, shown in Figure 3.1.

Figure 3.1: The guidgen.exe's Create GUID dialog box allows you to create a unique identification number in various formats.

As you can see in Figure 3.1, the Create GUID dialog box allows you to choose the format of the GUID you want to create. In this case you'll use format #2, DEFINE_GUID(). Select the option and click the Copy button.

Now a completely unique identification number is on the Clipboard, waiting for you to paste it into your code. Go back to the .X file you are creating and paste the contents of the Clipboard into your template declaration.

template ContactEntry {
// {4C9D055B−C64D−4bfe−A7D9−981F507E45FF}
DEFINE_GUID(<<name>>,
0x4c9d055b, 0xc64d, 0x4bfe, 0xa7, 0xd9, 0x98, 0x1f, 0x50, 0x7e, 0x45, 0xff);

Whoops! That's a little too much text for the template, so you need to cut out the DEFINE_GUID macro stuff and paste that into your project's source code. Yes, that's right−every template you define requires a matching GUID definition (via the DEFINE_GUID macro, for example) inside your code. This means you need to include the initguid.h file in your code and use DEFINE_GUID, as I have done here.

#include "initguid.h"

// At beginning of source code file − add DEFINE_GUIDs
DEFINE_GUID(ContactEntry, 0x4c9d055b, 0xc64d, 0x4bfe, 0xa7, 0xd9, 0x98,  0x1f, 0x50, 0x7e, 0x45, 0xff);

Notice that in the DEFINE_GUID macro, I've replaced the <<name>> text with the actual class name of the template I am defining. In this case, I am using ContactEntry as a macro name. From this point on, the ContactEntry macro will contain a pointer to my template's GUID (which must match the template's GUID in the .X file).

Getting back to the ContactEntry template, you also need to remove the comment tag from the pasted text and change the GUID's brackets to angle brackets, as I have done here:

template ContactEntry {
<4C9D055B−C64D−4bfe−A7D9−981F507E45FF>

Now you're ready to move on and define the template's data. Templates are much like C structures and classes; they contain variables and pointers to other templates, as well as access restrictions. The types of variables you can use are much like the ones you use in C. Table 3.1 shows you the data types at your disposal for defining templates, as well as matching C/C++ data types.

Much like C/C++ variable declarations, you follow the data type keyword with an instance name and finish with a semicolon (signifying the end of the variable declaration).

DWORD Value;

In Table 3.1, you'll notice the array keyword, which defines an array of data types. To define an array, you specify the array keyword followed by the data type, instance name, and array size (enclosed in square brackets). For example, to declare an array of 20 STRING data types, you could use:

array STRING Text[20];

Note The cool thing about arrays is that you can use another data type to define the array size, as I have done here:

DWORD ArraySize;

array STRING Names[ArraySize];

Now you need to go back to the ContactEntry template and define a person's name, phone number, and age. The three variables−two strings (name and phone number) and one numerical value (age)−can be defined in the ContactEntry template as follows.

template ContactEntry {
  <4C9D055B−C64D−4bfe−A7D9−981F507E45FF>
  STRING Name; // The contact's name
  STRING PhoneNumber; // The contact's phone number
  DWORD Age; // The contact's age
}

Cool! You finish your template definition with a closing bracket, and you're ready to go.

 

Creating Data Objects from Templates

After you have defined a template, you can begin creating data objects and defining their data. Data objects are defined by their respective template class types and an optional instance name. You can use this instance name to later reference the data object inside the .X file or from within your project (a feature you'll read about later in this chapter).

Moving on with the example, take the ContactEntry template and create a data object from it. This data object will contain a person's name, phone number, and age.

ContactEntry JimsEntry {
  "Jim Adams";
  "(800) 555−1212";
  30;
}

Notice that I've declared the data object's instance name as JimsEntry. From now on, I can reference this data object by using the name enclosed in brackets, like this:

{JimsEntry}

Referencing a data object in this manner is called data referencing, or referencing (as if you couldn't guess!), and it allows you to point one data object to another. For example, an animation sequence template (AnimationSet) requires you to reference a Frame data object for the sequence's embedded objects.

You can also use referencing to duplicate an object's data without having to retype it. This is useful when you are creating a few identical Mesh data objects in an .X file, with each Mesh object being oriented differently inside various Frame objects.


posted on 2008-04-16 19:16 lovedday 閱讀(408) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            老司机午夜精品视频在线观看| 国产日韩一区二区| 裸体一区二区| 亚洲一区在线观看视频| 91久久线看在观草草青青| 国产麻豆9l精品三级站| 欧美久久久久久蜜桃| 欧美成年人网| 蜜臀久久99精品久久久久久9| 欧美一站二站| 性欧美1819性猛交| 欧美在线资源| 久久精品男女| 欧美日韩在线综合| 欧美色中文字幕| 国产精品久久久久久久久动漫| 国产精品成人播放| 亚洲第一搞黄网站| 久久国产精品久久精品国产| 久久精品免费| 欧美日韩国产在线看| 国产免费一区二区三区香蕉精| 黄色成人在线| 亚洲一区二区网站| 欧美a级一区| 亚洲尤物影院| 欧美精品免费视频| 亚洲福利视频一区| 欧美自拍偷拍| 国产精品久久久久免费a∨大胸| 欧美日韩视频第一区| 国产日韩欧美在线| 久久亚洲图片| 国产精品美女www爽爽爽| 激情欧美亚洲| 亚洲一区二区四区| 亚洲电影av| 亚洲欧美日韩国产一区| 欧美日韩一区二区三区在线视频| 欧美~级网站不卡| 国产精品爱久久久久久久| 国产一区二区在线免费观看| 99re6热在线精品视频播放速度| 在线视频日韩| 亚洲高清资源| 久久香蕉国产线看观看av| 国产真实乱子伦精品视频| 亚洲人成久久| 亚洲精品欧美专区| 欧美黄色大片网站| 91久久精品久久国产性色也91| 久久久久久久综合日本| 欧美亚洲在线播放| 99re6热只有精品免费观看| 老牛影视一区二区三区| 亚洲国产小视频| 亚洲人成在线观看| 香蕉成人伊视频在线观看| 国产精品日韩欧美一区| 亚洲男人天堂2024| 亚洲青涩在线| 欧美图区在线视频| 久久国产日韩| 欧美 日韩 国产在线| 一本色道久久综合精品竹菊| 一区二区三区高清不卡| 国产伦理一区| 欧美福利电影网| 欧美三级视频在线播放| 欧美一区二区三区四区在线观看| 欧美亚洲综合久久| 亚洲美女网站| 欧美一级欧美一级在线播放| 精品成人久久| 亚洲免费在线观看| 久久夜色精品亚洲噜噜国产mv | 一区二区三区日韩精品| 欧美日本一道本在线视频| 久久电影一区| 国产美女一区| 亚洲一区二区精品在线| 日韩写真视频在线观看| 欧美xx69| 日韩视频免费观看| 亚洲精品国精品久久99热一| 欧美一区免费| 欧美国产日韩一二三区| 欧美人妖在线观看| 国产精品久久久久久久免费软件| 亚洲国产成人av好男人在线观看| 国内精品久久久久久久影视麻豆 | 欧美大片在线看| 亚洲欧美一区二区三区极速播放 | 亚洲精品在线观| 一区二区免费在线播放| 国产精品久久91| 午夜一区二区三区在线观看| 欧美自拍丝袜亚洲| 黄页网站一区| 欧美11—12娇小xxxx| 亚洲黄色毛片| 欧美一区二区观看视频| 在线国产精品播放| 欧美日韩在线三区| 欧美在线1区| 日韩小视频在线观看| 久久久国产一区二区| 亚洲日本免费电影| 国产私拍一区| 国产精品福利在线| 久久夜色精品国产| 欧美大片va欧美在线播放| 亚洲免费在线精品一区| 一区一区视频| 欧美午夜欧美| 免费在线亚洲| 久久精品一区二区三区四区 | 麻豆91精品91久久久的内涵| 日韩网站在线观看| 亚洲国产色一区| 国产女优一区| 免费久久精品视频| 久久午夜电影| 久久久成人网| 老司机aⅴ在线精品导航| 欧美一区1区三区3区公司| 亚洲国产日本| 日韩亚洲欧美成人| 亚洲精品自在久久| 日韩视频一区二区| 亚洲欧美成人一区二区三区| 99re热精品| 亚洲一区二区三区中文字幕| 中文av字幕一区| 亚洲欧美国产三级| 久久精品一区二区三区四区 | 91久久视频| 亚洲激情视频在线观看| 欧美福利一区二区| 国产精品日本一区二区| 尤物九九久久国产精品的分类| 在线免费观看一区二区三区| 91久久综合亚洲鲁鲁五月天| 这里只有精品视频| 久久国产精品一区二区| 亚洲二区视频| 欧美成人a∨高清免费观看| 亚洲国产综合在线| 亚洲欧美视频在线观看| 欧美精品一区二区在线播放| 国产欧美日韩另类一区| 99国产欧美久久久精品| 久久米奇亚洲| 亚洲深夜福利在线| 亚洲欧美综合精品久久成人| 久久中文久久字幕| 亚洲免费一在线| 国产精品v片在线观看不卡 | 久久久天天操| 欧美怡红院视频| 国产主播喷水一区二区| 免费观看国产成人| 久久久亚洲影院你懂的| 亚洲国产精品热久久| 91久久综合亚洲鲁鲁五月天| 欧美日韩国产综合久久| 久久精品中文字幕一区| 麻豆精品精品国产自在97香蕉| 999亚洲国产精| 欧美亚洲视频在线观看| 伊人久久婷婷| 午夜精品99久久免费| 亚洲精品综合精品自拍| 亚洲一区二区伦理| 亚洲精品一品区二品区三品区| 亚洲视频网在线直播| 日韩视频免费观看| 久久资源av| 久久久精品国产免费观看同学| 欧美国产一区视频在线观看| 久久综合九九| 在线播放日韩| 久久久久国产精品www| 欧美一区二区三区婷婷月色 | 欧美国产精品久久| 老司机精品福利视频| 国产精品一卡二| 亚洲一区二区日本| 午夜精品在线看| 国产农村妇女精品| 欧美亚洲视频| 久久亚洲精品一区二区| 影音先锋另类| 久久久久久久97| 91久久黄色| 亚洲私人影院在线观看| 国产精品午夜av在线| 午夜视黄欧洲亚洲| 国产日产欧美一区| 欧美在线免费视频|