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

天行健 君子當自強而不息

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 閱讀(413) 評論(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>
            欧美激情第六页| 欧美一区二区三区免费看 | 久久久国产精品一区| 亚洲欧美日韩一区在线观看| 亚洲综合视频网| 亚洲自拍偷拍视频| 欧美在线综合视频| 欧美.日韩.国产.一区.二区| 欧美精品一区二区三区久久久竹菊 | 亚洲激情欧美| 亚洲精品久久久蜜桃 | 欧美福利在线| 99这里只有久久精品视频| 亚洲影视九九影院在线观看| 欧美诱惑福利视频| 欧美精品成人| 亚洲一区二区三区精品动漫| 亚洲一区制服诱惑| 国产精品一区二区久激情瑜伽| 国产精品一区免费观看| 国产有码在线一区二区视频| 亚洲人成在线影院| 欧美在线国产| 亚洲精品久久久蜜桃 | 欧美暴力喷水在线| 在线亚洲成人| 免费国产自线拍一欧美视频| 国产精品高潮粉嫩av| 亚洲国产高潮在线观看| 亚欧成人精品| 亚洲国产免费| 久久国产精品久久久久久电车| 久久综合综合久久综合| 国产精品久久久久久影视| 亚洲欧洲在线一区| 久久久久久电影| 亚洲视频每日更新| 欧美激情综合在线| 在线日韩欧美| 久久视频在线视频| 亚洲免费视频一区二区| 欧美日韩一区二区三区在线| 亚洲娇小video精品| 久久综合色播五月| 欧美一级在线亚洲天堂| 欧美三级网址| 亚洲视频专区在线| 亚洲美女福利视频网站| 欧美韩国一区| 亚洲精品中文字| 欧美激情成人在线| 美女精品在线观看| 激情丁香综合| 玖玖国产精品视频| 久久国产精品72免费观看| 国产情侣久久| 欧美亚洲一区二区在线| 亚洲视频1区2区| 国产精品日韩专区| 欧美影视一区| 欧美专区在线观看一区| 黄色成人av网站| 欧美成人激情在线| 欧美韩日视频| 中文av一区二区| 夜夜嗨av一区二区三区网站四季av| 欧美日韩国产成人在线| 亚洲一区在线观看视频| 亚洲欧美激情精品一区二区| 国产一区二区久久精品| 久久夜色精品国产亚洲aⅴ| 久久全球大尺度高清视频| 亚洲电影av在线| 亚洲成色777777女色窝| 99re这里只有精品6| 亚洲乱码国产乱码精品精天堂 | 国产精品自拍三区| 久久久久久高潮国产精品视| 久久综合网络一区二区| 日韩一本二本av| 亚洲一区二区三区精品动漫| 国产婷婷97碰碰久久人人蜜臀| 久久久噜噜噜久久中文字免| 免费日韩成人| 亚洲淫片在线视频| 欧美在线三级| 99re视频这里只有精品| 亚洲自拍偷拍一区| 亚洲第一区在线观看| 亚洲乱码国产乱码精品精 | 亚洲欧美在线磁力| 久久精品一区二区三区四区| 99综合电影在线视频| 亚洲男人第一网站| 最新日韩精品| 亚洲综合首页| 日韩一本二本av| 久久激情五月激情| 亚洲图片自拍偷拍| 久久亚洲一区二区三区四区| 亚洲在线中文字幕| 久久婷婷国产综合国色天香| 亚洲一区欧美| 欧美波霸影院| 久久亚洲春色中文字幕久久久| 欧美日韩色一区| 欧美粗暴jizz性欧美20| 国产乱码精品一区二区三区五月婷 | 在线观看视频一区二区| 一区二区三区国产| 亚洲韩国日本中文字幕| 欧美一区二区播放| 亚洲——在线| 欧美日本免费一区二区三区| 免费黄网站欧美| 国产日韩一区| 亚洲午夜一区二区| 一区二区不卡在线视频 午夜欧美不卡'| 先锋影音网一区二区| 中日韩男男gay无套| 欧美精品入口| 亚洲国产日本| 亚洲精品久久久蜜桃| 久久蜜桃资源一区二区老牛 | 欧美视频在线观看免费| 欧美激情视频在线播放| 极品少妇一区二区三区| 欧美一区二区三区在线播放| 午夜一级在线看亚洲| 欧美一级黄色网| 一区二区高清视频| 久久频这里精品99香蕉| 欧美一区综合| 国产精品欧美久久| 一区二区三区久久| 亚洲无线视频| 欧美色图麻豆| 一区二区三区欧美在线观看| 亚洲一区二区三区三| 欧美视频中文一区二区三区在线观看 | 国产人久久人人人人爽| 亚洲系列中文字幕| 欧美一区二区三区在线视频| 国产精品男人爽免费视频1| 国产精品99久久久久久白浆小说| 亚洲色诱最新| 国产精品免费小视频| 午夜精品久久久久久久久久久久久| 欧美一级片久久久久久久| 国产视频精品xxxx| 久久狠狠亚洲综合| 欧美肥婆bbw| 一本色道久久加勒比88综合| 欧美视频在线观看免费| 先锋影音网一区二区| 欧美激情精品| 亚洲欧美日韩在线不卡| 狠狠色2019综合网| 欧美另类专区| 亚洲欧美另类在线观看| 卡一卡二国产精品| 99精品久久久| 国产精品日韩久久久| 久久久久久久精| 99精品免费| 久久一区二区三区av| 亚洲最新在线视频| 国产日产欧产精品推荐色| 久久先锋影音av| 亚洲美女在线国产| 老牛嫩草一区二区三区日本| 亚洲午夜性刺激影院| 韩国欧美一区| 欧美视频在线观看一区| 可以免费看不卡的av网站| 在线亚洲精品| 欧美激情视频一区二区三区在线播放 | 亚洲影视中文字幕| 激情欧美国产欧美| 欧美亚州一区二区三区| 久久中文字幕导航| 亚洲男人av电影| 亚洲人成人99网站| 久久久人成影片一区二区三区观看| 99视频日韩| 亚洲成色777777女色窝| 国产农村妇女精品一区二区| 欧美激情一区二区久久久| 欧美有码在线视频| 日韩一级在线观看| 国产精品av免费在线观看| 久久久久综合一区二区三区| 亚洲一区二区免费看| 亚洲激情图片小说视频| 久久中文欧美| 久久久免费精品视频| 香蕉久久夜色精品国产| 亚洲少妇在线| 一区二区冒白浆视频| 亚洲精品亚洲人成人网|