How to save custom data in .x file?

Started by
1 comment, last by JoystickX 18 years, 9 months ago
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
Advertisement
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.
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

This topic is closed to new replies.

Advertisement