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

天行健 君子當自強而不息

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 閱讀(421) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(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>
            亚洲午夜久久久| 亚洲中字在线| 国产亚洲欧美激情| 日韩午夜三级在线| 在线激情影院一区| 小嫩嫩精品导航| 亚洲免费网站| 欧美日韩精品免费| 亚洲高清成人| 在线播放精品| 欧美中文日韩| 久久精品视频在线| 国产精品亚洲美女av网站| 亚洲狼人精品一区二区三区| 亚洲激情在线观看视频免费| 久久久久亚洲综合| 免费短视频成人日韩| 激情久久五月| 久久久亚洲国产天美传媒修理工| 欧美在线影院| 国产亚洲欧美另类一区二区三区| 亚洲一区在线免费观看| 亚洲欧美偷拍卡通变态| 国产精品久久久久久影视| 在线亚洲欧美专区二区| 亚洲天堂激情| 国产精品第一页第二页第三页| 亚洲欧洲精品一区| 中文日韩在线视频| 国产精品久久久久久久电影| 一区二区三区毛片| 香蕉精品999视频一区二区 | 久久亚洲美女| 欧美成人中文| 亚洲精品国产精品国自产在线| 免费黄网站欧美| 亚洲国产日韩欧美在线99| 亚洲精品乱码视频| 欧美日韩精品系列| 亚洲无线视频| 久久人人97超碰精品888| 狠狠色狠色综合曰曰| 久久久噜噜噜久久人人看| 欧美激情一二三区| 99视频超级精品| 国产精品电影在线观看| 欧美一区二区三区啪啪 | 午夜亚洲视频| 国产一区二区精品丝袜| 久久网站热最新地址| 亚洲久久一区二区| 久久大综合网| 亚洲精品偷拍| 国产精品久久久久一区二区三区| 欧美一区在线看| 欧美激情综合色| 亚洲欧美日韩国产另类专区| 黄色亚洲精品| 欧美日韩高清在线播放| 亚洲欧美另类国产| 亚洲成在人线av| 欧美日韩视频在线一区二区观看视频| 一区二区三区日韩精品| 久久天堂精品| 亚洲欧美大片| 亚洲激情小视频| 国产欧美视频在线观看| 欧美激情亚洲激情| 午夜一区在线| 日韩午夜高潮| 久色婷婷小香蕉久久| 亚洲欧美成人在线| 亚洲精品小视频在线观看| 国产农村妇女精品一区二区| 欧美激情四色 | 亚洲女性裸体视频| 欧美成人性网| 欧美在线一二三| 亚洲少妇一区| 亚洲人成亚洲人成在线观看| 国产一区白浆| 国产精品亚洲产品| 欧美日韩在线一区二区三区| 久久亚洲不卡| 欧美一区二区三区另类| 一区二区三区视频观看| 亚洲片区在线| 免费久久99精品国产自| 久久久7777| 欧美一区二区视频在线| 亚洲视频精品在线| 亚洲国产影院| 亚洲国产1区| 在线观看三级视频欧美| 激情亚洲一区二区三区四区| 国产精品三级视频| 国产精品美女视频网站| 欧美日韩视频在线一区二区| 欧美黑人一区二区三区| 欧美69wwwcom| 欧美国产在线电影| 欧美第一黄色网| 猛干欧美女孩| 女仆av观看一区| 欧美jjzz| 欧美黄色aaaa| 欧美精品激情blacked18| 欧美a级一区| 欧美大片免费观看| 欧美激情精品久久久久久蜜臀| 久久久久久久波多野高潮日日| 欧美主播一区二区三区美女 久久精品人 | 亚洲欧洲日本mm| 亚洲国产女人aaa毛片在线| 欧美成人黄色小视频| 欧美国产综合一区二区| 亚洲国产欧美日韩另类综合| 亚洲激情偷拍| 99精品欧美一区二区三区| 一本色道久久88综合亚洲精品ⅰ| 99re6这里只有精品视频在线观看| 亚洲精品一区在线| 一区二区欧美激情| 亚洲欧美日韩精品久久奇米色影视| 亚洲综合日韩在线| 久久国产精品色婷婷| 久久噜噜噜精品国产亚洲综合| 老司机成人网| 欧美日韩视频一区二区三区| 国产精品香蕉在线观看| 精品成人在线| 一本色道久久88精品综合| 亚洲一区二区欧美日韩| 久久久成人网| 亚洲大胆女人| 亚洲视频狠狠| 久久精品在线免费观看| 欧美大胆成人| 国产精品视频观看| 亚洲国产高潮在线观看| 亚洲午夜影视影院在线观看| 久久精选视频| 91久久极品少妇xxxxⅹ软件| 亚洲天堂免费观看| 久久色中文字幕| 国产精品爱啪在线线免费观看| 国产午夜精品久久久| 亚洲免费久久| 久久久国产精品亚洲一区 | 亚洲日本视频| 欧美一级大片在线免费观看| 免费看成人av| 国产欧美日韩视频一区二区三区| 亚洲国产精品传媒在线观看| 午夜国产精品影院在线观看| 欧美激情成人在线| 亚洲曰本av电影| 久久综合狠狠| 国产日韩欧美不卡| 日韩香蕉视频| 欧美freesex交免费视频| 亚洲在线观看视频网站| 欧美韩国日本一区| 曰本成人黄色| 欧美在线欧美在线| 亚洲精品一线二线三线无人区| 久久久伊人欧美| 国产日韩欧美日韩大片| 中国亚洲黄色| 亚洲黄色在线观看| 久久精品视频播放| 国产情侣久久| 亚洲一区亚洲二区| 亚洲日本一区二区| 麻豆av一区二区三区久久| 国产日韩综合| 欧美一级片一区| 亚洲少妇在线| 国产精品分类| 亚洲一区二区三区在线看 | 久久中文字幕一区| 狠狠狠色丁香婷婷综合激情| 亚洲欧美日韩精品久久亚洲区| 亚洲久久在线| 欧美美女日韩| 日韩一级片网址| 亚洲国产成人久久综合| 裸体丰满少妇做受久久99精品| 国产亚洲成年网址在线观看| 久久国产主播精品| 亚洲在线观看| 国产日韩精品久久| 久久久久9999亚洲精品| 亚洲欧美成人精品| 国产女主播在线一区二区| 香蕉久久a毛片| 欧美一区二区三区免费看| 国产午夜一区二区三区| 久久久久久久久伊人| 久久九九久久九九|