Sign in to follow this  
JoystickX

How to save custom data in .x file?

Recommended Posts

JoystickX    114
Hi My approach is that firstly I register my template via IDirectXFile::RegisterTemplates. Than I create save object with IDirectXFile::CreateSaveObject and save my custom data. Unfortunately in the output .x file are only data that I saved and not data that file previously contain. This is probably not good way. Than I discover ID3DXSaveUserData interface passed to the D3DXSaveMeshHierarchyToFile function. I think microsoft wants to totally confuse the programmers with mixing the legacy interfaces with new ones, e.g. LPD3DXFILESAVEOBJECT - LPDIRECTXFILESAVEOBJECT and so on. This is total chaos. Has anyone idea of how I could append new custom data to .x file? Has anybody working on this? Known some links? thanks very much and sorry for my english

Share this post


Link to post
Share on other sites
Stevieboy    238
I'm not sure exactly, but I think the new api might be more geared towards saving with anomation, don't mix them up though, try to use either one or the other. I think the new one is based on using callbacks & ID3DXSaveUserData. The only thing I think you can't easily do with tht new api, is to define your own template types. You say you lose the original data in the file, is there an "append" method or something? Otherwise I think it writes a new file, if thats got the same name as your old one then maybe it gets overwritten. Maybe you need to load all of your old file into memory first, then get your new data, then save the whole lot at once.

Share this post


Link to post
Share on other sites
JoystickX    114
Using ID3DXSaveUserData interface and D3DXSaveMeshHierarchyToFile function should not overwrite previous data. But there is still few things that I can't realize. For example if you look at ID3DXSaveUserData::AddTopLevelDataObjectsPre function in SDK - DX 9.0 You will see something like this:

HRESULT AddTopLevelDataObjectsPre (LPD3DXFILESAVEOBJECT pXofSave);

and parameter description:
pXofSave
[in] Pointer to a .x file save object. Use this pointer to call IDirectXFileSaveObject::CreateDataObject to create the data object to be saved. Then call IDirectXFileSaveObject::SaveData to save the data.

That is parameter is of type LPD3DXFILESAVEOBJECT, but description refer to LPDIRECTXFILESAVEOBJECT. That's a mess.

help someone pls

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