详解.X文件

  • 格式:pdf
  • 大小:103.57 KB
  • 文档页数:12
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;;
} template OpenTemplate { <4C9D055B-C64D-4bff-A7D9-981F507E45FF> DWORD OpenData; [...] } template RestrictedTemplate { <4C9D055B-C64D-4c00-A7D9-981F507E45FF> DWORD RestrictedData; [ClosedTemplate] [OpenTemplate] } ate 是标准的模版声明。 OpenTemplate 中包含一个[...],表示这是一个开放模版。开放模版允许在[]中 内嵌任何数据对象。例如
20。
DWORD ArraySize; array STRING Names[ArraySize]; //可以将大小设置为变量。
声明一个 ContactEntry 模版: 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 } 实例化一个模版对象: ContactEntry JimsEntry { "Jim Adams"; "(800) 555-1212"; 30; } {JimsEntry} 可以用这样的形式引用一个数据对象。例如,在一个 animation sequence template 中引用
Contains the material for
face-mapping values.
MeshNormals:
Holds normals used for mesh
data.
MeshTextureCoords:
Holds texture coordinates used
for mesh data.
Contains an array of
floating-point values.
FrameTransformMatrix:
Holds the transformation matrix for a
parent Frame template.
Frame:
A
frame-of-reference template that defines a hierarchy.
Header:
The .X file header that
contains version numbers.
IndexedColor:
Contains an indexed color
value.
Material:
Contains material color
values.
Matrix4x4:
Holds a 4x4 homogenous
to use for a material.
TimedFloatKeys:
} } }
} } xof 0302txt 0032 xof 表示这是一个真正的 X 文件。0302txt 表示通知程序使用 Directx 的 X 文件, 版本为 3.2 的模版,其中 txt 表示此文件为文本文件,可读,并非是一个 2 进制 文件。0032 表示一个浮点数的位数为 32,如果想要用 64 位的浮点数,可以写成 0064。
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;;
,你可以实例化 OpenTemplate,在里面定义一个 OpenData 变量和内嵌一个 ClosedTemplate 的实例。 RestrictedTemplate 为约束模版。约束模版实例化时只允许包含它列出的数据 对象,如,不能在
RestrictedTemplate 包含[ClosedTemplate],[OpenTemplate]以外的数据对象。
ColorRGB:
Contains red, green, and
blue color values.
ColorRGBA:
Contains red, green,
blue, and alpha color values.
Coords2d:
Defines two coordinate
values.
FloatKeys:
用 DirectX .X Standard Templates 工作:\\\\\\\\\\\\\\\\\X 文件广泛用于
包含一个 mesh 信息。一个 Standard Templates 包含了过多的信息。
Table 3.2: DirectX .X Standard Templates
Template Name
matrix container.
Mesh:
Contains a single
mesh's data.
MeshFace:
Holds a mesh's face data.
MeshFaceWraps:
Contains the texture
wrapping for mesh faces.
MeshMaterialList:
MeshVertexColors:
Holds vertex color information
used for mesh vertices.
Patch:
Defines a control
patch.
PatchMesh:
Contains a patch mesh
(much like the Mesh template).
下面将分别介绍各个主题。
声明一个模版:\\\\\\\\\\\\\\假设声明 template ContactEntry 首先需要用 guidgen.exe 产生一个 GUID。产生的 GUID 如下: // {4C9D055B-C64D-4bfe-A7D9-981F507E45FF} DEFINE_GUID(<<name>>, 0x4c9d055b, 0xc64d, 0x4bfe, 0xa7, 0xd9, 0x98, 0x1f, 0x50, 0x7e, 0x45, 0xff); 之后需要在程序代码中加入: #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); 还要在 X 文件中加入:
X 文件的使用(完整)
有很多朋友也许想更加了解 X 文件,正好,本文将全面的介绍 X 文件的 使用。我想这是一篇纯技术性的文档,我就不加以诗篇歌颂润色了。相信读我的 文章,就像啃牙签;)好了,我们板起面孔。首先给你一个完整的印象----传说 中的 X 文件: xof 0302txt 0032
template Header { <3D82AB43-62DA-11cf-AB39-0020AF71E433> DWORD major; DWORD minor; DWORD flags; }
} 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;,
Description
Animation:
Defines animation data
for a single frame.
AnimationKey:
Defines a single key frame
for the parent animation template.