I probably should've kept my big mouth shut! It's not as easy as I made it sound to just "pluck" the desired mesh out of the .x file. I'll describe the procedure anyway, at the very least it may be informative.
If you're familiar with the direct x ascii file format, then you already are way ahead of the game! If not then here goes:
The .x file format is essentially broken up into Templates. Each template contains the necessary information to "draw" a 3d object (hey this isn't so bad after all!). Similar to C, template information is contained within braces { } . The opening brace { is the start of the block , the closing brace } is the end of the block.
An individual mesh, BARE MINIMUM number of templates include :
Material
Mesh
MeshMaterialList
MeshNormals
A more complicated template structure may include Frames, frame transform matrix, textures, uv coordinates, and animations. Most templates will have a name to reference a specific mesh, material or frame. Thus the layout looks like:
Material <name> {
TextureFileName { <bitmap file.bmp> }
}
Frame <name> {
FrameTransformMatrix {
}
Mesh <name> {
MeshMaterialList{
{<material name reference 1>}
{<material name reference 2>}
...
{<material name reference N>}
}
MeshNormals {
}
MeshTextureCoordinates {
}
}
}
AnimationSet <name> {
Animation {
{<frame name reference>}
AnimationKey {
}
}
Animation {
{<frame name reference>}
AnimationKey {
}
}
}
Using a text editor, you can cut and paste blocks of templates to create a new .x file containing only the object that you want.
Steps:
1. make an empty text document and at the top put:
xof 0302txt 0032
Header {
1;
0;
1;
}
2. Open the .x file you want to grab an object out of
3. Select ALL of the material template blocks and copy and paste them into your new text file
4. Look for the Frame Block that identifies the mesh you want. There should be a name for the frame or for the mesh that it contains. This will give you a clue as to which block you want.
5. Copy and paste everything from Frame { until the closing brace before the next } Frame template or AnimationSet begins - into your text file.
6. At this point you should be avle to save your text file with the .x extension and you're done!
Here's an example of a file with 2 cubes. I want to create a new one with only the first cube in it. This isn't a very complex template and I don't use textures so there's no texture name.
Here's the original:
xof 0302txt 0064
Header {
1;
0;
1;
}
//2006-08-16 14:36:03.750000
//File Created with DB_XEporter.py version 1.00 - 747575 Latch Grapple
Material mat_Material_0 {
0.800000; 0.800000; 0.800000; 1.000000;;
0.500000;
1.000000; 1.000000; 1.000000;;
0.000000; 0.000000; 0.000000;;
}
Material mat_blue_0 {
0.259160; 0.096173; 0.911111; 1.000000;;
0.500000;
1.000000; 1.000000; 1.000000;;
0.000000; 0.000000; 0.000000;;
}
Frame Cube_frame {
FrameTransformMatrix {
93.058495, 0.000000, 0.000000, 0.000000,
0.000000, 93.058495, 0.000000, 0.000000,
0.000000, 0.000000, 93.058495, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
Mesh mesh_Cube {
24;
1.000000; -1.000000; -1.000000;,
1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
-1.000000; 1.000000; -1.000000;,
-1.000000; 1.000000; 1.000000;,
0.999999; 1.000000; 1.000001;,
1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
0.999999; 1.000000; 1.000001;,
1.000000; -1.000000; 1.000000;,
1.000000; -1.000000; 1.000000;,
0.999999; 1.000000; 1.000001;,
-1.000000; 1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; 1.000000; 1.000000;,
-1.000000; 1.000000; -1.000000;,
-1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
1.000000; -1.000000; -1.000000;,
-1.000000; -1.000000; -1.000000;,
-1.000000; 1.000000; -1.000000;;
6;
4;0,1,2,3;,
4;4,5,6,7;,
4;8,9,10,11;,
4;12,13,14,15;,
4;16,17,18,19;,
4;20,21,22,23;;
MeshMaterialList {
1;
6;
0,
0,
0,
0,
0,
0;;
{mat_Material_0}
}
MeshNormals {
8;
-0.577349; 0.577349; -0.577349;,
-0.577349; 0.577349; 0.577349;,
0.577349; 0.577349; 0.577349;,
0.577349; 0.577349; -0.577349;,
-0.577349; -0.577349; -0.577349;,
-0.577349; -0.577349; 0.577349;,
0.577349; -0.577349; 0.577349;,
0.577349; -0.577349; -0.577349;;
6;
4;0,1,2,3;,
4;4,7,6,5;,
4;0,4,5,1;,
4;1,5,6,2;,
4;2,6,7,3;,
4;4,0,3,7;;
}
} //End of Mesh Definition
Frame Cube001_frame {
FrameTransformMatrix {
93.058495, 0.000000, 0.000000, 0.000000,
0.000000, 93.058495, 0.000000, 0.000000,
0.000000, 0.000000, 93.058495, 0.000000,
4.033787, 0.000000, -0.063028, 1.000000;;
}
Mesh mesh_Cube001 {
24;
1.000000; -1.000000; -1.000000;,
1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
-1.000000; 1.000000; -1.000000;,
-1.000000; 1.000000; 1.000000;,
0.999999; 1.000000; 1.000001;,
1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
0.999999; 1.000000; 1.000001;,
1.000000; -1.000000; 1.000000;,
1.000000; -1.000000; 1.000000;,
0.999999; 1.000000; 1.000001;,
-1.000000; 1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; 1.000000; 1.000000;,
-1.000000; 1.000000; -1.000000;,
-1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
1.000000; -1.000000; -1.000000;,
-1.000000; -1.000000; -1.000000;,
-1.000000; 1.000000; -1.000000;;
6;
4;0,1,2,3;,
4;4,5,6,7;,
4;8,9,10,11;,
4;12,13,14,15;,
4;16,17,18,19;,
4;20,21,22,23;;
MeshMaterialList {
1;
6;
0,
0,
0,
0,
0,
0;;
{mat_blue_0}
}
MeshNormals {
8;
-0.577349; 0.577349; -0.577349;,
-0.577349; 0.577349; 0.577349;,
0.577349; 0.577349; 0.577349;,
0.577349; 0.577349; -0.577349;,
-0.577349; -0.577349; -0.577349;,
-0.577349; -0.577349; 0.577349;,
0.577349; -0.577349; 0.577349;,
0.577349; -0.577349; -0.577349;;
6;
4;0,1,2,3;,
4;4,7,6,5;,
4;0,4,5,1;,
4;1,5,6,2;,
4;2,6,7,3;,
4;4,0,3,7;;
}
} //End of Mesh Definition
} //end of child frame
} //end of parent frame
AnimationSet animset {
Animation {
{Cube_frame}
AnimationKey {
0;
0;
;
}
AnimationKey {
1;
0;
;
}
AnimationKey {
2;
1;
0;3;0.000000,0.000000,0.000000;;;
0;
;
}
}
Animation {
{Cube001_frame}
AnimationKey {
0;
1;
0;4;1.000000,0.000000,0.000000,0.000000;;;
}
AnimationKey {
1;
0;
;
}
AnimationKey {
2;
4;
0;3;4.033787,0.000000,-0.063028;;,
10;3;3.306870,4.585924,-0.063028;;,
20;3;-2.938585,4.517296,-0.063028;;,
30;3;-4.612711,0.139404,-0.063028;;;
}
}
}
Now here's my cut and paste file:
xof 0302txt 0032
Header {
1;
0;
1;
}
Material mat_Material_0 {
0.800000; 0.800000; 0.800000; 1.000000;;
0.500000;
1.000000; 1.000000; 1.000000;;
0.000000; 0.000000; 0.000000;;
}
Material mat_blue_0 {
0.259160; 0.096173; 0.911111; 1.000000;;
0.500000;
1.000000; 1.000000; 1.000000;;
0.000000; 0.000000; 0.000000;;
}
Frame Cube_frame {
FrameTransformMatrix {
93.058495, 0.000000, 0.000000, 0.000000,
0.000000, 93.058495, 0.000000, 0.000000,
0.000000, 0.000000, 93.058495, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
Mesh mesh_Cube {
24;
1.000000; -1.000000; -1.000000;,
1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
-1.000000; 1.000000; -1.000000;,
-1.000000; 1.000000; 1.000000;,
0.999999; 1.000000; 1.000001;,
1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
0.999999; 1.000000; 1.000001;,
1.000000; -1.000000; 1.000000;,
1.000000; -1.000000; 1.000000;,
0.999999; 1.000000; 1.000001;,
-1.000000; 1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; -1.000000; 1.000000;,
-1.000000; 1.000000; 1.000000;,
-1.000000; 1.000000; -1.000000;,
-1.000000; -1.000000; -1.000000;,
1.000000; 1.000000; -0.999999;,
1.000000; -1.000000; -1.000000;,
-1.000000; -1.000000; -1.000000;,
-1.000000; 1.000000; -1.000000;;
6;
4;0,1,2,3;,
4;4,5,6,7;,
4;8,9,10,11;,
4;12,13,14,15;,
4;16,17,18,19;,
4;20,21,22,23;;
MeshMaterialList {
1;
6;
0,
0,
0,
0,
0,
0;;
{mat_Material_0}
}
MeshNormals {
8;
-0.577349; 0.577349; -0.577349;,
-0.577349; 0.577349; 0.577349;,
0.577349; 0.577349; 0.577349;,
0.577349; 0.577349; -0.577349;,
-0.577349; -0.577349; -0.577349;,
-0.577349; -0.577349; 0.577349;,
0.577349; -0.577349; 0.577349;,
0.577349; -0.577349; -0.577349;;
6;
4;0,1,2,3;,
4;4,7,6,5;,
4;0,4,5,1;,
4;1,5,6,2;,
4;2,6,7,3;,
4;4,0,3,7;;
}
} //End of Mesh Definition
} // I had to add an extra brace because original frame actually
// contains another frame inside it (parent - child).
// I have to make sure the Frame Block is closed.
The process isn't complicated, it just might take time to hunt through the .x file for the mesh that you want.
Since your goal is to just make a limb, you don't really need to copy the animation information - I assume you will animate your limb when you add it to your tank in DBC.
Enjoy your day.