Hey Buckeyes,
First of all, thanks for the response. Appreciate you reading over my post and trying to help. Forgive me if some of my assumptions are incorrect as I work through your post, as I'm still new to DirectX.
First, it helps if you post the actual text you're using. You don't show where you use the keyword "template." What you've posted isn't valid templating.
I register the D3DRM_XTEMPLATES found in rmxftmpl.h. That way I don't need all of the template front matter in every single .X file. Plus I only use predefined templates, so D3DRM_XTEMPLATES is more than enough. Below is the contents of my .X file in it's original non-working format. As I originally stated, when I move the material out of the Root frame, so that it is the first template in the file, all of a sudden the material1 reference found in the MeshMaterialList is recognized by the GetChildren() call when parsing MeshMaterialList. See code example at end of post for clarification of this move.
Frame Root {
FrameTransformMatrix {
1.000000, 0.000000, 0.000000, 0.000000,
0.000000,-0.000000, 1.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
Material material1 {
0.000000;0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
TextureFilename {
"material1.bmp";
}
}
Frame Cube {
FrameTransformMatrix {
1.750000, 0.000000, 0.000000, 0.000000,
0.000000, 0.583333, 0.000000, 0.000000,
0.000000, 0.000000,16.291666, 0.000000,
-0.010820, 0.000000, 0.000000, 1.000000;;
}
Mesh {
8;
-0.304800;-0.304800;-0.304800;,
-0.304800; 0.304800;-0.304800;,
0.304800; 0.304800;-0.304800;,
0.304800;-0.304800;-0.304800;,
-0.304800;-0.304800; 0.304800;,
-0.304800; 0.304800; 0.304800;,
0.304800; 0.304800; 0.304800;,
0.304800;-0.304800; 0.304800;;
6;
4;0,1,5,4;,
4;1,2,6,5;,
4;2,3,7,6;,
4;3,0,4,7;,
4;3,2,1,0;,
4;4,5,6,7;;
MeshNormals {
6;
-1.000000; 0.000000; 0.000000;,
0.000000; 1.000000;-0.000000;,
1.000000; 0.000000;-0.000000;,
0.000000;-1.000000; 0.000000;,
-0.000000; 0.000000;-1.000000;,
-0.000000; 0.000000; 1.000000;;
6;
4;0,0,0,0;,
4;1,1,1,1;,
4;2,2,2,2;,
4;3,3,3,3;,
4;4,4,4,4;,
4;5,5,5,5;;
}
MeshMaterialList {
1;
6;
0,
0,
0,
0,
0,
0;;
{material1}
}
}
}
}
?
In any case, templates define structures in terms of a structure name, curly brackets, and contents described with known keywords.
I.e.,
template MyStuff { WORD someWord; STRING someString; ... }
Within MyStuff, WORD and STRING are recogninzed. In your first template (assuming it's a template), you have: MesMaterialList { { some-word } }
The parser doesn't know how you intend the inner structure { some-word } to be interpreted. It's an unnamed, undefined structure.
As far as I know the MeshMaterialList template for X-Files hasn't changed from IDirectXFile to ID3DX. I looked at the template format found on the Microsoft website and it still seems to look the same. Not sure why it would parse correctly in the past with GetNextObject(), but returns zero children with GetChildren(). But maybe I'm just not understanding your explanation correctly.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb147192(v=vs.85).aspx
Moreover, if the format of MeshMaterialList is incorrect, then it goes back to my original question of, why does it parse correctly when I move material1 outside of the Root frame. If {material1} is undefined when written in this way, then shouldn't GetChildren() similarly not recognize the reference when parsing the X-File with material1 outside of the Root frame?
For clarification, this is the adjustment to the X-File that causes the material1 reference to be recognized by GetChildren(). Again, I would make the edit to my X-Files, but the problem is, I have a bunch of X-Files that use the above format, and I rather not manually edit all of them. Much rather have a more robust parser if at all possible.
Material material1 {
0.000000;0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
TextureFilename {
"material1.bmp";
}
}
Frame Root {
FrameTransformMatrix {
1.000000, 0.000000, 0.000000, 0.000000,
0.000000,-0.000000, 1.000000, 0.000000,
0.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
Frame Cube {
FrameTransformMatrix {
1.750000, 0.000000, 0.000000, 0.000000,
0.000000, 0.583333, 0.000000, 0.000000,
0.000000, 0.000000,16.291666, 0.000000,
-0.010820, 0.000000, 0.000000, 1.000000;;
}
Mesh {
8;
-0.304800;-0.304800;-0.304800;,
-0.304800; 0.304800;-0.304800;,
0.304800; 0.304800;-0.304800;,
0.304800;-0.304800;-0.304800;,
-0.304800;-0.304800; 0.304800;,
-0.304800; 0.304800; 0.304800;,
0.304800; 0.304800; 0.304800;,
0.304800;-0.304800; 0.304800;;
6;
4;0,1,5,4;,
4;1,2,6,5;,
4;2,3,7,6;,
4;3,0,4,7;,
4;3,2,1,0;,
4;4,5,6,7;;
MeshNormals {
6;
-1.000000; 0.000000; 0.000000;,
0.000000; 1.000000;-0.000000;,
1.000000; 0.000000;-0.000000;,
0.000000;-1.000000; 0.000000;,
-0.000000; 0.000000;-1.000000;,
-0.000000; 0.000000; 1.000000;;
6;
4;0,0,0,0;,
4;1,1,1,1;,
4;2,2,2,2;,
4;3,3,3,3;,
4;4,4,4,4;,
4;5,5,5,5;;
}
MeshMaterialList {
1;
6;
0,
0,
0,
0,
0,
0;;
{material1}
}
}
}
}