Milkshape3D to Direct3D9c X-file conversion

Started by
11 comments, last by CyberGhost 18 years, 10 months ago
Hi, Sorry if this has already been posted else where on the site. I have had a quick look but cannot find anything about. I am currently creating 3D models using MilkShape3D 1.74 and trying to export to Microsoft's Direct3D9c X-File format. (SDK April 2005) The problem is between sometime between December 2004 and the current version (April 2005) of the DirectX SDK. Microsoft has changed the format of the X-file and as a result old X-file's do not load (great backwards compatibly). Luckly I still have my MilkShape model projects, but have tried using the various DirectX export settings but cant get one that Direct3D will load. Has anyone else had this problem and have found a way round this either via setting certain settings or using some other conversion software. Thanx, CyberGhost
Advertisement
You could use other formats that MilkShape supports (which means you have to
load it yourself), I think there's an ASCII format which is quite easy to read.

Anyway, did you try to ask the MilkShape developers, maybe they know
where to download new versions of the X-File Exporter?!
Thank you for your response,
Well I could using one of the other formats although this is not ideal. Ideally it would be nice to make use of the X-File format as its quite simple to use and do not have to write loads of loading code.

Regards asking developers of MilkShape, that was going to be my next move but thought I would just check on here first incase other people have had the same problem..which they must have.
Thanx,

CyberGhost
I ran into the same problem and was able to get around it by exporting the models to .x differently. Unfortunately, I'm not at the pc with milkshape on it right now, so this is all going from memory--but I'm pretty sure exporting as a 'managed directx (.jt)' file works. During the export process, select the save name as a .x, and export as binary.

I'll verify the process once I get back to that computer.
Thanks Toraque,
Thats helped loads. To confirm for yours and others reference. When exporting select DirectX (JT) select your output file name with the extension .x
Next select DirectX Retained Mode as the format and you can either export as Binary (select binary check) or text by deselecting all checks.

However as these things are never simple. There appears to be some bugs in the exporter. If you have a model that has more then one texture material only the first is used and textures will always be looked for in the current directory.
Which means you either have to manually edit the x file and add relative paths or modify your texture loading.
So I'll probably submit a bug report to chUmbaLum sOft regarding the textures see what they say.
Thanks for you help.

Now to get my Collision Detection work :(
The problem has to do with an extra "}" being put into the .X file at the end of the materials list when exported by Milkshape. You simply need to open the file in notepad and remove it. It will work fine after that.
Author Freeworld3Dhttp://www.freeworld3d.org
I think I am miss understanding,
I have just tried editing the file and there appears to be no extra "}" character. I have tried hacking about removing the "}" after the materials listed in the materiallist group however that breaks the file.
Where exactly should the edit be made.

Thanx,

CyberGhost
Here is a .x export of a single box from Milkshape with a single texture.

xof 0303txt 0032template XSkinMeshHeader { <3cf169ce-ff7c-44ab-93c0-f78f62d172e2> WORD nMaxSkinWeightsPerVertex; WORD nMaxSkinWeightsPerFace; WORD nBones;}template VertexDuplicationIndices {<b8d65549-d7c9-4995-89cf-53a9a8b031e3> DWORD nIndices; DWORD nOriginalVertices; array DWORD indices[nIndices];}template SkinWeights { <6f0d123b-bad2-4167-a0d0-80224f25fabb> STRING transformNodeName; DWORD nWeights; array DWORD vertexIndices[nWeights]; array FLOAT weights[nWeights]; Matrix4x4 matrixOffset;}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 Box01 {   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 {    24;    -0.300000;0.975000;-0.950000;,    -0.300000;-0.925000;-0.950000;,    1.525000;0.975000;-0.950000;,    1.525000;-0.925000;-0.950000;,    1.525000;0.975000;-0.950000;,    1.525000;-0.925000;-0.950000;,    1.525000;0.975000;0.950000;,    1.525000;-0.925000;0.950000;,    1.525000;0.975000;0.950000;,    1.525000;-0.925000;0.950000;,    -0.300000;0.975000;0.950000;,    -0.300000;-0.925000;0.950000;,    -0.300000;0.975000;0.950000;,    -0.300000;-0.925000;0.950000;,    -0.300000;0.975000;-0.950000;,    -0.300000;-0.925000;-0.950000;,    -0.300000;0.975000;-0.950000;,    1.525000;0.975000;-0.950000;,    -0.300000;-0.925000;-0.950000;,    1.525000;-0.925000;-0.950000;,    -0.300000;0.975000;0.950000;,    1.525000;0.975000;0.950000;,    -0.300000;-0.925000;0.950000;,    1.525000;-0.925000;0.950000;;    12;    3;0,2,1;,    3;1,2,3;,    3;4,6,5;,    3;5,6,7;,    3;8,10,9;,    3;9,10,11;,    3;12,14,13;,    3;13,14,15;,    3;20,21,16;,    3;16,21,17;,    3;18,19,22;,    3;22,19,23;;    MeshNormals {     24;     0.000000;0.000000;-1.000000;,     0.000000;0.000000;-1.000000;,     0.000000;0.000000;-1.000000;,     0.000000;0.000000;-1.000000;,     1.000000;0.000000;0.000000;,     1.000000;0.000000;0.000000;,     1.000000;0.000000;0.000000;,     1.000000;0.000000;0.000000;,     0.000000;0.000000;1.000000;,     0.000000;0.000000;1.000000;,     0.000000;0.000000;1.000000;,     0.000000;0.000000;1.000000;,     -1.000000;0.000000;0.000000;,     -1.000000;0.000000;0.000000;,     -1.000000;0.000000;0.000000;,     -1.000000;0.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;-1.000000;0.000000;,     0.000000;-1.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;-1.000000;0.000000;,     0.000000;-1.000000;0.000000;;     12;     3;0,2,1;,     3;1,2,3;,     3;4,6,5;,     3;5,6,7;,     3;8,10,9;,     3;9,10,11;,     3;12,14,13;,     3;13,14,15;,     3;20,21,16;,     3;16,21,17;,     3;18,19,22;,     3;22,19,23;;    }    MeshTextureCoords {     24;     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;1.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     1.000000;0.000000;,     0.000000;0.000000;,     1.000000;0.000000;,     0.000000;1.000000;,     1.000000;1.000000;;    }    VertexDuplicationIndices {     24;     20;     0,     1,     2,     3,     4,     5,     6,     7,     8,     9,     10,     11,     12,     13,     14,     15,     16,     17,     18,     19,     12,     6,     13,     7;    }    MeshMaterialList {     1;     12;     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,     0;     Material Material01 {      0.800000;0.800000;0.800000;1.000000;;      0.000000;      0.000000;0.000000;0.000000;;      0.000000;0.000000;0.000000;;      TextureFilename {       "ed2.jpg";      }     }    }    XSkinMeshHeader {     1;     3;     0;    }   } } }}AnimationSet AnimationSet0 { Animation {  AnimationKey {   4;   2;   0; 16; 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;;,   -1; 16; 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;;;  }  { Scene_Root } }}


Here is the edited version
xof 0303txt 0032template XSkinMeshHeader { <3cf169ce-ff7c-44ab-93c0-f78f62d172e2> WORD nMaxSkinWeightsPerVertex; WORD nMaxSkinWeightsPerFace; WORD nBones;}template VertexDuplicationIndices {<b8d65549-d7c9-4995-89cf-53a9a8b031e3> DWORD nIndices; DWORD nOriginalVertices; array DWORD indices[nIndices];}template SkinWeights { <6f0d123b-bad2-4167-a0d0-80224f25fabb> STRING transformNodeName; DWORD nWeights; array DWORD vertexIndices[nWeights]; array FLOAT weights[nWeights]; Matrix4x4 matrixOffset;}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 Box01 {   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 {    24;    -0.300000;0.975000;-0.950000;,    -0.300000;-0.925000;-0.950000;,    1.525000;0.975000;-0.950000;,    1.525000;-0.925000;-0.950000;,    1.525000;0.975000;-0.950000;,    1.525000;-0.925000;-0.950000;,    1.525000;0.975000;0.950000;,    1.525000;-0.925000;0.950000;,    1.525000;0.975000;0.950000;,    1.525000;-0.925000;0.950000;,    -0.300000;0.975000;0.950000;,    -0.300000;-0.925000;0.950000;,    -0.300000;0.975000;0.950000;,    -0.300000;-0.925000;0.950000;,    -0.300000;0.975000;-0.950000;,    -0.300000;-0.925000;-0.950000;,    -0.300000;0.975000;-0.950000;,    1.525000;0.975000;-0.950000;,    -0.300000;-0.925000;-0.950000;,    1.525000;-0.925000;-0.950000;,    -0.300000;0.975000;0.950000;,    1.525000;0.975000;0.950000;,    -0.300000;-0.925000;0.950000;,    1.525000;-0.925000;0.950000;;    12;    3;0,2,1;,    3;1,2,3;,    3;4,6,5;,    3;5,6,7;,    3;8,10,9;,    3;9,10,11;,    3;12,14,13;,    3;13,14,15;,    3;20,21,16;,    3;16,21,17;,    3;18,19,22;,    3;22,19,23;;    MeshNormals {     24;     0.000000;0.000000;-1.000000;,     0.000000;0.000000;-1.000000;,     0.000000;0.000000;-1.000000;,     0.000000;0.000000;-1.000000;,     1.000000;0.000000;0.000000;,     1.000000;0.000000;0.000000;,     1.000000;0.000000;0.000000;,     1.000000;0.000000;0.000000;,     0.000000;0.000000;1.000000;,     0.000000;0.000000;1.000000;,     0.000000;0.000000;1.000000;,     0.000000;0.000000;1.000000;,     -1.000000;0.000000;0.000000;,     -1.000000;0.000000;0.000000;,     -1.000000;0.000000;0.000000;,     -1.000000;0.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;-1.000000;0.000000;,     0.000000;-1.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;1.000000;0.000000;,     0.000000;-1.000000;0.000000;,     0.000000;-1.000000;0.000000;;     12;     3;0,2,1;,     3;1,2,3;,     3;4,6,5;,     3;5,6,7;,     3;8,10,9;,     3;9,10,11;,     3;12,14,13;,     3;13,14,15;,     3;20,21,16;,     3;16,21,17;,     3;18,19,22;,     3;22,19,23;;    }    MeshTextureCoords {     24;     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     0.000000;1.000000;,     1.000000;0.000000;,     1.000000;1.000000;,     0.000000;1.000000;,     1.000000;1.000000;,     0.000000;0.000000;,     1.000000;0.000000;,     0.000000;0.000000;,     1.000000;0.000000;,     0.000000;1.000000;,     1.000000;1.000000;;    }    VertexDuplicationIndices {     24;     20;     0,     1,     2,     3,     4,     5,     6,     7,     8,     9,     10,     11,     12,     13,     14,     15,     16,     17,     18,     19,     12,     6,     13,     7;    }    MeshMaterialList {     1;     12;     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,     0;     Material Material01 {      0.800000;0.800000;0.800000;1.000000;;      0.000000;      0.000000;0.000000;0.000000;;      0.000000;0.000000;0.000000;;      TextureFilename {       "ed2.jpg";      }     }    }    XSkinMeshHeader {     1;     3;     0;    }   } }}AnimationSet AnimationSet0 { Animation {  AnimationKey {   4;   2;   0; 16; 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;;,   -1; 16; 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;;;  }  { Scene_Root } }}


The place that was edited was the part containing this:

Material Material01 {
0.800000;0.800000;0.800000;1.000000;;
0.000000;
0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
TextureFilename {
"ed2.jpg";
}
}
}

XSkinMeshHeader {
1;
3;
0;
}

}
}
}
}


It was changed to:

Material Material01 {
0.800000;0.800000;0.800000;1.000000;;
0.000000;
0.000000;0.000000;0.000000;;
0.000000;0.000000;0.000000;;
TextureFilename {
"ed2.jpg";
}
}
}

XSkinMeshHeader {
1;
3;
0;
}

}
}
}

One of the braces right after XSkinMeshHeader was removed.
Author Freeworld3Dhttp://www.freeworld3d.org
I think theres a confusion,
That code sample is from an exported X-File that is using template format not binary or text. Which doing so does not seem to load with the new Direct3D.
The text version of the output appears to be correct (all braces are in matched pairs).

Anyone else got any bright ideas?

Thanx

CyberGhost
I use this format with the DirectX 9c SDK. It works fine.
Author Freeworld3Dhttp://www.freeworld3d.org

This topic is closed to new replies.

Advertisement