Skip to main content
GameDev.net gamedev.net
🔒 Locked

Save Mesh Headache...

Started by QueSerraSerraBoY Jan 19, 2004 at 10:42 AM 1 replies 900+ views
Original Post
QueSerraSerraBoY
QueSerraSerraBoY
Hi! I seem to have problem saving a mesh to .x file. I have no problem saving the mesh info except for the TextureFilename which should appear within the material. I always get runtime exception whenever I try to save the TextureFilename. When I looked at the DX documentation, it says the TextureFilename uses the type STRING. I don''t know how to use this type so I just use char. However, the error still persist. Any idea what''s wrong? With regards, QueSerraSerraBoY
o/QueSerraSerraBoY /
neneboricua19
neneboricua19
If you''re using ID3DXMesh''s, then you don''t need to create the x file manually. You can use D3DXSaveMeshToX or D3DXSaveMeshHierarchyToFile.

neneboricua
DerMeister
DerMeister
Take a look in the sdk docs for the TOKEN_STRING reference, basically a string is structured like:

WORD token; //2 bytes
DWORD count; //4 bytes, count of chars in string
BYTE string[count];//the string you need (count length)
DWORD terminator;//a token that tells the end of the string.

I know this is used for binary access but it is almost the same procedure...
So first write the token (TextureFileName) with all the decorations (I mean "{", "}", etc), and write the size of the length of the string you want to write, the write each char in the string and finally put the terminator (the semicolon or comma, I don''t remember).

Hope this helps, and as neneboricua said you can use x files api which is much easier once you understand it...


No matter where you go... &this
No matter where you go... &this

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.