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

天行健 君子當自強而不息

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>
            欧美啪啪成人vr| 欧美日韩亚洲综合在线| 国产亚洲亚洲| 久久精品一二三区| 久久久www| 亚洲精品日韩综合观看成人91| 欧美国产综合视频| 国产精品vvv| 久久久久久久久久看片| 免费中文日韩| 亚洲欧美资源在线| 久久久一区二区三区| 亚洲欧洲一区二区在线播放| 日韩一区二区久久| 国产一区日韩二区欧美三区| 美女主播精品视频一二三四| 欧美国产一区二区三区激情无套| 亚洲一二区在线| 久久久久九九九| 亚洲视频在线观看三级| 欧美一区影院| 亚洲视频欧美在线| 久久影视精品| 亚洲欧美日韩精品在线| 老司机久久99久久精品播放免费 | 性做久久久久久| 久久青草久久| 午夜久久久久| 欧美日韩成人综合天天影院| 久久免费国产| 国产精品区免费视频| 亚洲高清不卡一区| 国产精品揄拍一区二区| 亚洲人在线视频| 激情欧美一区二区| 亚洲欧美精品| 亚洲午夜一区| 欧美激情乱人伦| 麻豆av福利av久久av| 国产精品一区二区久久精品| 91久久久久久久久久久久久| 国产揄拍国内精品对白| 亚洲午夜精品17c| 一区二区三区国产| 欧美chengren| 欧美第十八页| 激情六月婷婷久久| 久久国产视频网站| 久久成人在线| 国产欧美日韩一区二区三区在线| 日韩亚洲精品电影| 99热这里只有成人精品国产| 麻豆91精品| 欧美大片免费久久精品三p| 国产婷婷色综合av蜜臀av| 亚洲综合国产精品| 午夜精品一区二区在线观看| 欧美午夜精品久久久久免费视| 亚洲国产精品一区二区久| 91久久综合| 欧美理论电影在线播放| 亚洲人成艺术| 亚洲视频在线观看视频| 国产精品啊啊啊| 亚洲一级二级在线| 欧美在线播放| 国产一区二区三区高清播放| 先锋影音网一区二区| 欧美在线免费观看视频| 国产精品永久免费视频| 亚洲专区在线视频| 久久尤物电影视频在线观看| 狠狠色综合一区二区| 久久天天狠狠| 亚洲精品美女91| 亚洲欧美福利一区二区| 国产欧美一区二区精品忘忧草| 午夜精品久久久久久久男人的天堂| 欧美在线一二三| 在线精品一区| 欧美人与性禽动交情品 | 亚洲区国产区| 亚洲欧美日韩人成在线播放| 久久精品动漫| 亚洲国内欧美| 国产精品v欧美精品v日韩| 小黄鸭视频精品导航| 免费看的黄色欧美网站| 一区二区三区视频免费在线观看| 国产精品jizz在线观看美国| 欧美一区=区| 亚洲人永久免费| 久久久久成人精品| 亚洲乱码国产乱码精品精| 国产精品入口66mio| 久久久久国产一区二区三区| 亚洲人被黑人高潮完整版| 欧美一区免费视频| 亚洲日本中文字幕| 国产欧美成人| 欧美日韩国产成人在线| 欧美在线视频不卡| 亚洲欧洲综合| 美女露胸一区二区三区| 亚洲一级在线观看| 亚洲国产另类久久精品| 国产精品毛片在线看| 免费观看国产成人| 午夜亚洲伦理| 一本一道久久综合狠狠老精东影业| 久久精品国产v日韩v亚洲| 亚洲九九精品| 黑人一区二区| 国产美女精品视频| 欧美肉体xxxx裸体137大胆| 久久深夜福利| 欧美精选在线| 久久成人免费视频| 在线综合欧美| 亚洲韩日在线| 欧美黄色日本| 可以看av的网站久久看| 亚洲男人第一网站| 在线视频欧美精品| 91久久精品一区二区三区| 韩国在线一区| 国产精品综合视频| 欧美午夜精品伦理| 欧美日韩一区二区免费在线观看| 快射av在线播放一区| 欧美一区三区二区在线观看| 亚洲视频在线看| 亚洲午夜激情网站| 亚洲一区二区三区色| 在线视频亚洲一区| 一区二区三区日韩在线观看| 亚洲精品乱码久久久久久按摩观| 免费在线日韩av| 久久尤物视频| 欧美va亚洲va国产综合| 麻豆精品一区二区综合av| 看欧美日韩国产| 免费影视亚洲| 亚洲成人在线视频播放 | 亚洲一区在线播放| 亚洲字幕一区二区| 亚洲欧美日韩在线综合| 午夜亚洲性色视频| 欧美在线首页| 久久综合九色综合久99| 久久一区中文字幕| 欧美国产精品久久| 最新国产の精品合集bt伙计| 最新国产成人在线观看| 亚洲美女91| 亚洲网站在线| 久久久www成人免费无遮挡大片 | 你懂的视频欧美| 欧美日韩成人综合天天影院| 国产精品电影网站| 国产亚洲一二三区| 亚洲黄色av| 亚洲综合不卡| 久热精品视频在线观看一区| 亚洲国产日韩欧美一区二区三区| 亚洲精品一区二区在线观看| 亚洲社区在线观看| 久久精品论坛| 欧美片第1页综合| 国产精品自拍网站| 91久久中文| 欧美在线观看网站| 亚洲电影免费| 亚洲自拍啪啪| 欧美精品成人在线| 国产欧美在线视频| 亚洲精品一二区| 久久久xxx| 99视频精品全部免费在线| 欧美一区三区二区在线观看| 欧美粗暴jizz性欧美20| 国产精品网站在线观看| 亚洲黄一区二区| 欧美影院成人| 99精品福利视频| 久久综合网络一区二区| 国产精品永久免费在线| 亚洲精选视频免费看| 久久九九免费视频| 亚洲精品一区二区三区在线观看| 欧美专区在线播放| 国产精品国内视频| 日韩亚洲欧美一区| 免费视频亚洲| 久久成人免费电影| 国产欧美视频在线观看| 正在播放亚洲| 亚洲国产一区二区三区在线播 | 欧美一区二区在线播放| 国产精品久久久对白|