Sign in to follow this  
RossGeorge

ID3DXFileSaveObject Interface

Recommended Posts

Hello all this my first post :) I’ve always found these forums immensely helpful and a majority of the problems I’ve ran into have been solved by a quick browse of the gamedev forums. This time however I can find barely any information about my problem so I thought I’d post it and see if anyone can give me some pointers. What I’m trying to do is take a .X file containing lots of different types of information such as mesh, animation etc… and strip it down to just the definition of the mesh (for reasons I won’t go into now :) ) and export that info into a new .X file. I figured the easy way to do this would be to use the built in DirectX interface ID3DXFile and its member interfaces (CreateEnumObject, CreateSaveObject etc…) . The problem I’m having is when I finally get round to putting the data I want to store into a data buffer and saving it. Here is some code which might clarify things: //////////////////////////////////////////////////////////////////////////////// /*g_pMesh – A LPD3DXMESH filled with the mesh information I’m going to being saving to a .X file.*/ ID3DXFileSaveObject* pXSave = NULL; ID3DXFileSaveData* pXSDataRoot = NULL; ID3DXFileSaveData* pXSDataMesh = NULL; /*Add an empty frame to the XFile:*/ pXSave->AddDataObject( TID_D3DRMFrame, "Scene_Root_Frame", NULL, 0, NULL, &pXSDataRoot ); /*Calculate the number of bytes in the mesh data object:*/ const DWORD NumV = g_pMesh->GetNumVertices(); const DWORD NumF = g_pMesh->GetNumFaces(); const DWORD dByteSize = ( ( 2*sizeof(DWORD) )+( 3*sizeof(float) )*NumV +( 4*sizeof(DWORD) )*NumF ); /*This my (poor) attempt at making a data buffer which contains vertices that are all of value 10.0 and faces that are all of value 5 */ byte* pPtr = new byte[dByteSize]; ZeroMemory( pPtr, dByteSize ); DWORD pPtrIterator = 0; pPtr[pPtrIterator] = NumV; pPtrIterator += sizeof( DWORD ); for (DWORD i = 0; i < NumV*3; i++) { pPtr[pPtrIterator] = 10.0f; pPtrIterator += sizeof( float ); } pPtr[pPtrIterator] = NumF; pPtrIterator += sizeof( DWORD ); for (DWORD i = 0; i < NumF*4; i++) { pPtr[pPtrIterator] = 5; pPtrIterator += sizeof( DWORD ); } /*Finally add a new mesh object to the empty frame we created earlier using the data pointer and save:*/ pXSDataRoot->AddDataObject( TID_D3DRMMesh, "MeshData", NULL, dByteSize, pPtr, &pXSDataMesh ) pXSave->Save(); //////////////////////////////////////////////////////////////////////////////// I have read through the ‘toymaker’ programming tutorial for saving to a .x file and manage to export a simple transform matrix template object but it doesn’t really go into much depth with regard to writing complex template object such as a mesh objects. I tried writing a structure which replicated the mesh template and use that as the data pointer but this was also unsuccessful. Any help will welcome thanks :)

Share this post


Link to post
Share on other sites
Thanks Trip99 but I have already read that article; it was helpful in respect to saving basic data but it doesn't really demonstrate how to save more complex data.
Thank anyway tho :)

I still haven't been able to figure this problem out so if anyones got any other suggestions I would be grateful.

Share this post


Link to post
Share on other sites
Ah I see - sorry I did not read your first post through fully. Perhaps I could post you some code I use to export a mesh in an app. PM me if you want it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this