• Advertisement
Sign in to follow this  

Can't create ID3DXFileSaveData

This topic is 977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The TID_WalkableTiles_Data GUID is defined using DEFINE_GUID

followed by a series of bytes

 

 

AddDataObject error (Data) is displayed

 

 

 

Any quick fix for me?

Thanks

Jack

ID3DXFile* tileFile = NULL;
    HRESULT hr = D3DXFileCreate(&tileFile);

    

    // save tiles information
    tileFile->RegisterTemplates((void*)D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES);
    
    if (SUCCEEDED(tileFile->RegisterTemplates(WalkableTilesTemplate, strlen(WalkableTilesTemplate))))
    {

        ID3DXFileSaveObject* xFileSave = NULL;
        if (SUCCEEDED(tileFile->CreateSaveObject("D:\\tiles.x", D3DXF_FILESAVE_TOFILE, D3DXF_FILEFORMAT_TEXT, &xFileSave)))
        {

            ID3DXFileSaveData *xFileSaveRoot = NULL;            
            if (SUCCEEDED(xFileSave->AddDataObject(TID_D3DRMFrame, "Root", NULL, 0, NULL, &xFileSaveRoot)))
            {

                DWORD size = 2 * sizeof(float) + sizeof(bool);


                //while (1) {
                DWORD x = 0;
                DWORD z = 0;
                bool walkable = false;

                // get data from navmesh


                size_t* pbData = new size_t[3];

                pbData[0] = x;
                pbData[1] = z;
                pbData[2] = walkable;


                ID3DXFileSaveData *pRootTransform = NULL;
                if (SUCCEEDED(xFileSaveRoot->AddDataObject(TID_WalkableTiles_Data,
                    "WalkableTiles", NULL, size, pbData, &pRootTransform))) {
            
                    
                    xFileSave->Save();
                }
                else {
                    cout << "AddDataObject error (Data)" << endl;
                }

            }
            else {
                cout << "AddDataObject error " << endl;
            }
        }




        else {
            cout << "CreateSaveObject Error " << endl;
        }
    }
    else
    {
        cout << "RegisterTemplates error " << endl;
    }
Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement