Archived

This topic is now archived and is closed to further replies.

Nims

Custom Binary .X files

Recommended Posts

Nims    148
Okay, I posted this before but no one answered, seems like if you explain the question, It becomes long and noone will read it. here it goes: How can I put some .X files into a single file then access them later?
www.users.bigpond.com/nimak

Share this post


Link to post
Share on other sites
Lionheartadi    154
Do you mean packing? Then try something like gzip or try to create one for your self. You may try to read the wanted files in binary and save them as binary single file. Refer to your programming languages help or something.

Share this post


Link to post
Share on other sites
Nims    148
Thats correct, I meant packing, and I have no problem reading or writing them. The problem pops on when I want to actually use the data. for instance I have a mesh and I want to load it. The mesh is packed in the file.

I can extract it and load it into memory but I can''t actually use it to load meshes. Thats my problem.

I don''t know how to use that kind of data for meshes. Since LoadMeshFromXof Uses DirectXFileData objects, I thought I can use them , but I don''t know how to load the data into them .

Can someone point out a tutorial (not the one on GDev, I''ve read that) or explain this to me?

Thanks

-Nims

Share this post


Link to post
Share on other sites
Hi - what you want to do is something like this:


BYTE* MeshData = NULL;

MeshData = new BYTE [dwFileSize];

memcpy( &MeshData, &XFileDataFromPack, dwFileSize );

D3DXLoadMeshFromXInMemory( &MeshData, dwFileSize, D3DXMESH_MANAGED, &m_D3DDevice, NULL, &D3DMaterial, 1, &m_Mesh );

delete [] MeshData;


So you create a BYTE array the same size as the X file you want. Copy the data (perhaps BYTE at a time from your PAK would be easier) in to the BYTE array and supply the parameters to D3DXLoadMeshFromXInMemory();

I wrote an articles about creating a custom PAK format but Gamedev never printed it

Edit: Added the delete command - Don't forget to free your memory once you've used it!

[edited by - Ethereal on July 7, 2003 6:50:49 AM]

Share this post


Link to post
Share on other sites
Nims    148
Yeah, um this works but I have a little question.
When savign like that, I have to save the whole file but I want to parse the file and only save the thing that I want.

Can someone explain to me how to use the data in DirectXFileData objects to create custom direct X files?

So that a program can parse through a file, store all the fileData objects it needs to save and then somehow (I don''t know how) Save them to a file.

And then again load them using some technic. thanks.

Share this post


Link to post
Share on other sites