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

天行健 君子當自強而不息

Using the .X File Format(1)

Your 3D meshes need a place to liverather, you need a place to store your 3D mesh data (not to mention all that other data your game project requires). What's a developer to do−develop his own file format or go with a third−party format? With so many popular formats out there, it's an easy choice to make, but what about the restrictions some formats impose? Why can't you just use somebody else's file format and configure it to work the way you want?

That somebody else is none other than Microsoft, and the format to use is .X! Now uncross those eyes, mister−those .X files are really easy to use once you understand them, and this chapter will teach you what you need to know.

 

Working with .X Templates and Data Objects

If you haven't already, I invite you to take a look at one of those mysterious .X files that comes packaged with the DirectX SDK (located in the \Samples\Multimedia\Media directory of your DirectX install). Go on, I dare you. More than likely, you'll be greeted with something like this:

xof 0302txt 0032
template Header {
<3D82AB43−62DA−11cf−AB39−0020AF71E433>
DWORD major;
DWORD minor;
DWORD flags;
}
template Frame {
<3D82AB46−62DA−11cf−AB39−0020AF71E433>
[FrameTransformMatrix]
[Mesh]
}
Header {
1;
0;
1;
}
Frame Scene_Root {
FrameTransformMatrix {
1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
	Frame Pyramid_Frame {
FrameTransformMatrix {
1.000000, 0.000000, 0.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 1.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
		Mesh PyramidMesh {
5;
0.00000;10.00000;0.00000;,
−10.00000;0.00000;10.00000;,
10.00000;0.00000;10.00000;,
−10.00000;0.00000;−10.00000;,
10.00000;0.00000;−10.00000;;
6;
3;0,1,2;,
3;0,2,3;,
3;0,3,4;,
3;0,4,1;,
3;2,1,4;,
3;2,4,3;;
			MeshMaterialList {
1;
6;
0,0,0,0,0,0;;
				Material Material0 {
1.000000; 1.000000; 1.000000; 1.000000;;
0.000000;
0.050000; 0.050000; 0.050000;;
0.000000; 0.000000; 0.000000;;
}
}
}
}
}

Scary looking, isn't it? Actually, you can break down every .X file into a small handful of easy−to−manage components, which makes the files easy to understand and process. Let me explain what I mean. Every .X file starts with a small header, which in the preceding example looks like this:

xof 0302txt 0032

This small blurb of text informs programs that load the file that it is indeed an .X file. (The xof portion signifies an .X file.) It also informs programs that the file uses the DirectX .X file version 3.2 templates (represented by the 0302 text). Following the version number is txt, which signifies that all of the following .X data is stored in a text format as opposed to a binary format. The line of text ends with 0032, which defines the number of bits reserved for floating−point values (0032 for 32−bit or 0064 for 64−bit).

Note Binary, a second .X file storage format, is useful for compacting data into a format that is unreadable by humans. I won't discuss the binary format; however, the techniques used to process .X files in this chapter still apply to binary .X files, so don't worry about missing out on any good stuff!

After the file header there are a slew of data chunks, referred to as templates and data objects. You can tell the difference between a template and a data object because all templates begin with the word template. As you can see from the .X file code, templates look much like a C structure definition. Data objects are instances of those templates.

You use templates to define the information that data objects contain in the .X file. (A template defines the layout of a data object.) Each template can contain any type of data defined by a small set of data types, and any combination of data types can be used inside a template. A data object is merely an instance of a template. You can think of a template much like a C++ class−they both define the data that an instance of the object can contain.

Taking another look at the example .X file, you can see that the first template you'll encounter is Header, which is the template's class name. The Header template contains three DWORD values (as well as a large number called a GUID, which is enclosed in angle brackets), which you set when you create a data object from the template. Creating data objects is much like instancing a class or structure. In the previous .X file code, the instancing of the Header template looks like this:

Header {
  1; // major
  0; // minor
  1; // flags
}

Notice that you must define every variable contained in the Header template in your data object, and in the same order. You might be wondering about that large number (the template's GUID) defined in the template, however. What does that have to do with instancing your template? Nothing, actually, because DirectX uses that large number to identify templates as they are loaded. I'll get back to the template GUID (Globally Unique Identification Number) in a moment.

Tip Much like C/C++, you can also use the handy // operator to signify comments in your .X file.

The next template you'll see in the .X file is Frame. This is a special template−it doesn't define any data types, but it does reference other template classes. The other template classes, enclosed in square brackets, are named FrameTransformMatrix and Mesh. Using this manner of referencing other templates from within a template, you can create a hierarchy of data objects.

Also, by declaring additional templates within another template, you are creating a set of template restrictions, which enable you to create templates that only allow specific data objects to be embedded within another data object. In this case, only the data objects of the type FrameTransformMatrix and Mesh can be embedded in a Frame data object. You'll read more about template restrictions later in this chapter. For now, move on to examining the rest of the .X file.

Following the template definitions (which should also be at the beginning of the .X file) are the data objects. These are declared much like C data structures would be−you instance the structure by its template class name, followed by the data object's instance name. The instance name is optional, however, so don't worry if you come across some data objects that are missing it.

In the .X file you're examining, the first data object has an instance name of Scene_Root. The Scene_Root object is of the template class type Frame. You've already seen the Frame template defined. Looking back to that template definition, you can see that there is no data to store, but there are two optional data objects you can embed in Frame−FrameTransformMatrix and Mesh.

Just by a matter of luck, both a FrameTransformMatrix and a Mesh data object are embedded in Scene_Root. Missing from the .X file, however, are the template definitions for FrameTransformMatrix and Mesh. How are you supposed to know what data those objects contain? Well, an .X file doesn't have to define every template with the file itself−you can define those template definitions inside your program!

You'll get to see how to define these templates within your programs later in this chapter. For now, let's get back to the example. A data object of the template class type FrameTransformMatrix is embedded in the Scene_Root data object. This data object contains floating−point values that represent a transformation matrix. After that data object there is another data object of the template class type Mesh, which contains information about a mesh.

Okay, enough of this example−I'm sure you're getting the gist of it. As you can see, templates are completely user−defined, meaning that you can create any type of template to contain any type of data. Want to contain raw sound data in an .X file? How about storing heartbeat−sensor readings? Using .X, you can store sound data, heartbeat readings, and any other type of data you want!


posted on 2008-04-16 18:37 lovedday 閱讀(748) 評論(1)  編輯 收藏 引用

評論

# re: Using the .X File Format(1) 2010-11-16 23:38 可耕地

抄書嗎?  回復  更多評論   

公告

導航

統計

常用鏈接

隨筆分類(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>
            亚洲日本va午夜在线电影| 久久久精品性| 欧美视频在线观看 亚洲欧| 一区二区三区精品国产| 一区二区日韩伦理片| 国产精品xvideos88| 欧美专区在线| 老妇喷水一区二区三区| 日韩午夜精品| 亚洲一区二区欧美| 一区在线视频观看| 亚洲黄一区二区| 国产精品久在线观看| 久久精品视频网| 欧美国产在线电影| 久久精品国产99精品国产亚洲性色| 欧美主播一区二区三区| 亚洲精品视频啊美女在线直播| 一区二区高清视频在线观看| 一色屋精品视频在线看| 日韩亚洲欧美精品| 一区二区视频欧美| 亚洲四色影视在线观看| 亚洲第一区在线观看| 亚洲一级黄色片| 最新国产成人在线观看| 欧美一区1区三区3区公司| 亚洲精品久久久久久久久久久| 亚洲一区图片| 9色精品在线| 久久九九热免费视频| 亚洲在线中文字幕| 欧美国产先锋| 免费观看亚洲视频大全| 国产精品人成在线观看免费| 亚洲精品久久久一区二区三区| 国模精品娜娜一二三区| 亚洲午夜精品久久久久久app| 亚洲欧洲日夜超级视频| 久久精品国产77777蜜臀| 亚洲欧美日本在线| 欧美精品三区| 亚洲成人资源网| 亚洲人成7777| 尤物九九久久国产精品的分类| 亚洲视频在线二区| 亚洲天堂男人| 欧美日韩一区二区在线| 亚洲激情网址| 亚洲精品免费看| 久久性色av| 免费久久99精品国产自| 极品中文字幕一区| 欧美在线高清视频| 久久久久99| 国产一区二区成人久久免费影院| 亚洲视频1区| 亚洲欧美日韩电影| 国产精品a久久久久| 亚洲图中文字幕| 午夜精品剧场| 国产欧美丝祙| 久久精品国产亚洲一区二区三区| 欧美专区日韩视频| 国内不卡一区二区三区| 久久网站免费| 欧美激情自拍| 亚洲最新在线| 欧美日韩国产综合视频在线| av成人免费在线| 亚洲欧美中文字幕| 国产日韩在线看片| 久久青青草综合| 亚洲国产婷婷香蕉久久久久久| 日韩写真在线| 国产精品久久久久久久一区探花 | 亚洲一区在线免费观看| 香港成人在线视频| 怡红院av一区二区三区| 免费精品99久久国产综合精品| 欧美激情小视频| 亚洲一二三四久久| 国产一区二区日韩精品| 美女日韩欧美| 亚洲精品一二| 久久久www成人免费精品| 亚洲国产精品一区二区尤物区 | 久久精品99国产精品酒店日本| 欧美mv日韩mv国产网站| 亚洲免费观看高清在线观看| 国产精品国产三级国产| 久久精品欧洲| 日韩午夜在线| 久久躁日日躁aaaaxxxx| 一区二区三区四区五区精品| 国产一区在线看| 欧美激情视频在线播放| 欧美一区二区三区喷汁尤物| 亚洲国产黄色片| 欧美亚洲日本网站| 亚洲毛片在线看| 国产综合18久久久久久| 欧美另类亚洲| 欧美一区日本一区韩国一区| 亚洲国产精品一区二区www在线| 小黄鸭精品aⅴ导航网站入口| 亚洲国产裸拍裸体视频在线观看乱了中文| 欧美日韩另类在线| 久久在线免费视频| 欧美亚洲免费高清在线观看| 亚洲精品综合在线| 欧美成人黑人xx视频免费观看| 亚洲免费小视频| 日韩视频一区二区| 在线高清一区| 国产一区二区三区最好精华液| 欧美日韩午夜激情| 免费一级欧美片在线观看| 亚洲欧美日韩国产一区二区三区 | 老鸭窝91久久精品色噜噜导演| 亚洲一区二区视频在线| 亚洲精品视频一区| 亚洲国产精品久久91精品| 国产主播一区二区三区四区| 国产精品久久久久免费a∨| 欧美精品一区二区三区高清aⅴ| 久久久亚洲人| 久久九九久精品国产免费直播| 亚洲欧美日本国产有色| 亚洲午夜电影网| 一区二区三区你懂的| 99re热这里只有精品视频| 亚洲国产天堂网精品网站| 欧美xx69| 欧美黄色小视频| 欧美激情国产日韩| 亚洲二区视频| 亚洲国产一区二区视频| 最新国产成人av网站网址麻豆| 欧美国产日产韩国视频| 亚洲国产精选| 亚洲日本va午夜在线电影| 亚洲国产另类久久久精品极度| 亚洲第一主播视频| 亚洲欧洲在线播放| 在线中文字幕不卡| 亚洲自拍电影| 久久精品夜色噜噜亚洲a∨| 欧美在线一区二区三区| 久久久欧美一区二区| 米奇777在线欧美播放| 欧美国产日韩亚洲一区| 欧美调教vk| 国产亚洲精品福利| 亚洲国产三级在线| 亚洲视频中文字幕| 欧美一区二区三区免费视频| 久久免费国产| 亚洲电影免费在线| 宅男噜噜噜66国产日韩在线观看| 亚洲免费在线观看视频| 久久久精品国产免费观看同学| 老司机午夜精品| 欧美日韩国产bt| 国产精品尤物| 亚洲国产高清一区| 亚洲视频在线观看网站| 久久精品国产亚洲高清剧情介绍| 欧美高清在线一区| 在线亚洲欧美视频| 老色鬼精品视频在线观看播放| 欧美日韩免费一区| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲美女在线看| 久久久www免费人成黑人精品| 欧美激情aaaa| 午夜亚洲激情| 欧美伦理一区二区| 伊人婷婷久久| 亚洲欧美日韩精品久久亚洲区| 男女激情视频一区| 亚洲一二区在线| 欧美国产免费| 好看的亚洲午夜视频在线| 亚洲一区二区三区欧美| 免费一级欧美片在线观看| 亚洲视频在线观看免费| 欧美高清在线视频| 国内视频一区| 欧美亚洲综合在线| 亚洲精品日韩综合观看成人91| 久久国产一区二区| 国产精品日本欧美一区二区三区| 亚洲国产乱码最新视频| 久久亚洲精品网站| 亚洲欧美日韩在线| 国产精品成人一区二区三区吃奶| 亚洲精品久久视频| 免费视频一区| 久久精品国产亚洲5555|