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

天行健 君子當自強而不息

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

評論

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

抄書嗎?  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            农村妇女精品| 一区二区毛片| 久久久www| 黄色av日韩| 欧美aⅴ99久久黑人专区| 蜜桃久久av| 中文高清一区| 亚洲免费在线| 国产自产女人91一区在线观看| 久久久久久色| 免费不卡在线观看av| 9色国产精品| 亚洲一区网站| 在线欧美三区| 亚洲精品专区| 国产欧美一二三区| 欧美成人午夜激情| 欧美视频网站| 久久男人资源视频| 欧美日韩国产va另类| 性做久久久久久久久| 久久综合激情| 亚洲一区二区三区久久| 欧美一区视频| 日韩亚洲综合在线| 亚洲女性裸体视频| 亚洲精品乱码久久久久久日本蜜臀 | 国产精品久久一区主播| 久久综合九色综合欧美狠狠| 欧美极品在线播放| 久久久噜久噜久久综合| 欧美日本免费| 欧美+日本+国产+在线a∨观看| 欧美理论电影网| 久久久久国产精品www| 欧美精品久久天天躁| 久久久久中文| 国产精品久久久久久户外露出| 免费的成人av| 国产日韩在线看片| 99pao成人国产永久免费视频| 激情久久久久| 欧美一区二区精美| 亚洲一区二区精品在线| 免费观看成人网| 久久精品亚洲精品| 欧美成人一品| 欧美gay视频| 国产一区二区电影在线观看| 日韩视频―中文字幕| 亚洲高清资源| 久久日韩精品| 久久一二三国产| 国产欧美日韩中文字幕在线| 99精品免费视频| 亚洲精品国产精品久久清纯直播| 亚洲欧美经典视频| 午夜欧美大尺度福利影院在线看 | 欧美一级大片在线观看| 午夜精品网站| 欧美性猛交xxxx乱大交退制版| 亚洲第一视频| 亚洲第一页在线| 狼人天天伊人久久| 欧美成人激情视频| 亚洲第一精品影视| 久久综合婷婷| 亚洲高清二区| 亚洲美女视频在线观看| 嫩草国产精品入口| 亚洲全黄一级网站| 在线一区二区三区四区| 欧美日韩国产首页| 亚洲免费高清视频| 亚洲欧美日韩在线高清直播| 国产精品vip| 午夜精品网站| 久久久久免费观看| 亚洲电影第1页| 免费观看一区| 99pao成人国产永久免费视频| 一区二区三区精密机械公司| 欧美午夜不卡在线观看免费 | 亚洲精品美女在线观看| 一区二区欧美精品| 国产精品欧美一区二区三区奶水| 亚洲欧美日韩国产成人精品影院| 久久精品国产一区二区三| 韩国一区电影| 欧美刺激性大交免费视频 | 久久久久久久欧美精品| 精品成人国产在线观看男人呻吟| 久久亚洲影音av资源网| 亚洲精品免费在线观看| 亚洲欧美在线免费| 在线精品国精品国产尤物884a| 欧美刺激午夜性久久久久久久| 99re热这里只有精品免费视频| 欧美影院一区| 亚洲区中文字幕| 国产精品羞羞答答| 噜噜爱69成人精品| 亚洲视频在线观看视频| 嫩草伊人久久精品少妇av杨幂| 亚洲免费电影在线观看| 国产欧美91| 欧美成人精品一区| 欧美一区午夜精品| av不卡在线| 蜜臀91精品一区二区三区| 一本久道久久综合狠狠爱| 国产一区二区av| 欧美日韩国产小视频| 久久精品亚洲一区二区| 正在播放欧美一区| 亚洲国产婷婷综合在线精品| 久久精品国产欧美亚洲人人爽| 日韩小视频在线观看专区| 国产一区二区三区在线观看精品| 欧美人成在线| 玖玖视频精品| 久久精品三级| 午夜一级在线看亚洲| 日韩午夜激情电影| 亚洲第一狼人社区| 麻豆国产精品777777在线| 午夜精品久久久久久久蜜桃app| 91久久精品一区二区别| 国产日韩欧美电影在线观看| 国产精品成人一区二区艾草| 欧美电影在线观看| 久久影院亚洲| 久久久国产一区二区| 午夜欧美不卡精品aaaaa| 宅男在线国产精品| 一区二区高清视频| 9久草视频在线视频精品| 亚洲成色www久久网站| 免费在线欧美黄色| 久久综合图片| 麻豆精品网站| 女人天堂亚洲aⅴ在线观看| 裸体女人亚洲精品一区| 久久人人爽人人| 久久综合九色99| 美女爽到呻吟久久久久| 久久色中文字幕| 免费观看一级特黄欧美大片| 久久这里只有精品视频首页| 久久久久一本一区二区青青蜜月| 久久精品国产99| 久久久久久免费| 美女视频黄a大片欧美| 免费成人在线观看视频| 亚洲大胆视频| 亚洲精品中文字幕女同| 一区二区三区日韩欧美| 亚洲影院高清在线| 久久精品一本久久99精品| 久久综合图片| 欧美日本一区| 国产精品视频免费观看www| 国产一区自拍视频| 亚洲欧洲在线一区| 亚洲视频精品在线| 久久福利资源站| 欧美a级片网站| 9国产精品视频| 性欧美暴力猛交另类hd| 久久免费精品日本久久中文字幕| 农夫在线精品视频免费观看| 欧美日本一道本在线视频| 国产精品视频网址| 亚洲第一页在线| 亚洲一区免费看| 久久天天狠狠| 亚洲精品免费在线| 羞羞答答国产精品www一本| 久色婷婷小香蕉久久| 欧美日韩伦理在线免费| 国产一区二区高清| 亚洲精品自在在线观看| 久久成人18免费网站| 亚洲国产精品女人久久久| 亚洲深夜福利网站| 噜噜噜在线观看免费视频日韩 | 欧美在线播放一区| 欧美人与禽猛交乱配| 国产一区二区精品久久99| 一区二区三区四区精品| 久久国产精品99国产精| 亚洲人成网站色ww在线| 欧美一级理论片| 欧美午夜电影网| 亚洲日韩视频| 久久影音先锋| 亚洲综合999| 欧美日韩亚洲一区二区| 亚洲福利视频在线| 久久久久一区二区|