The picture below is a .X file opened by DirectX Mesh View. Today, we look at the X file's detail information. I strongly recommand readers search "X File Format Reference" topic in DirectX SDK documentation.
The variable-length header is compulsory and must be at the beginning of the data stream. The header contains the following data.
Type | Required | Size (in bytes) | Value | Description |
Magic Number | x | 4 | "xof " | |
Version Number | x | 2 | "03" | Major version 3 |
| | "03" | Minor version 3 | |
Format Type | x | 4 | "txt " | Text File |
| | "bin " | Binary file | |
| | "tzip" | MSZip compressed text file | |
| | "bzip" | MSZip compressed binary file | |
Float Size | x | "0064" | 64-bit floats | |
x | "0032" | 32-bit floats |
xof 0302txt 0032 //Header
Material PDX01_-_Default {
1.000000;1.000000;1.000000;1.000000;; //Face color
0.000000; //Power - the power is the specular exponent of the material
0.900000;0.900000;0.900000;; //Material specular color
0.000000;0.000000;0.000000;; //Material emissive color
TextureFilename {
"wood.boards.bmp";
}
}
Frame Box01 {
FrameTransformMatrix { // Defines a local transform for a frame(Optional)
1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-4.720104,0.000000,3.721657,1.000000;;
}
Mesh {
8; //Number of vertices.
-19.277889;-15.037872;0.000000;, //Array of vertices, each of type Vector
9.837681;-15.037872;0.000000;,
-19.277889;22.481186;0.000000;,
9.837681;22.481186;0.000000;,
-19.277889;-15.037872;13.356144;,
9.837681;-15.037872;13.356144;,
-19.277889;22.481186;13.356144;,
9.837681;22.481186;13.356144;;
12; //Number of faces(triangle)
3;0,2,3;, //Array of indices
3;3,1,0;,
3;4,5,7;,
3;7,6,4;,
3;0,1,5;,
3;5,4,0;,
3;1,3,7;,
3;7,5,1;,
3;3,2,6;,
3;6,7,3;,
3;2,0,4;,
3;4,6,2;;
MeshNormals { //Optional
6; //Number of normals.
0.000000;0.000000;-1.000000;, //Array of normals
0.000000;0.000000;1.000000;,
0.000000;-1.000000;0.000000;,
1.000000;0.000000;0.000000;,
0.000000;1.000000;0.000000;,
-1.000000;0.000000;0.000000;;
12; //Number of face normals, equal face's number!
3;0,0,0;, //Array of mesh face normals
3;0,0,0;,
3;1,1,1;,
3;1,1,1;,
3;2,2,2;,
3;2,2,2;,
3;3,3,3;,
3;3,3,3;,
3;4,4,4;,
3;4,4,4;,
3;5,5,5;,
3;5,5,5;;
}
MeshMaterialList { //Optional
1; //The number of materials.
12; //The number of indices. equal face's number
0, //An arrray of DWORDs containing the face indices
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0;
{ PDX01_-_Default } //Reference to the material we define
}
MeshTextureCoords { //Optional
8; //Number of texture coordinates
0.000000;0.000000;, //Array of 2D texture coordinates.
1.000000;0.000000;,
0.000000;-1.000000;,
1.000000;-1.000000;,
0.000000;0.000000;,
1.000000;0.000000;,
0.000000;-1.000000;,
1.000000;-1.000000;;
}
}
}
http://www.waitingfy.com/?p=460