ID3DXSaveUserData Interface

 

 

' ****************************************************************************************
' ID3DXSaveUserData interface
' ****************************************************************************************

' ****************************************************************************************
' This interface is implemented by the application to save any additional user data
' embedded in .x files. An instance of this interface is passed to D3DXSaveMeshHierarchyToFile,
' and D3DX calls the appropriate method on this interface every time the appropriate data
' is encountered. For example, for each frame object in the .x file,
' ID3DXSaveUserData::AddFrameChildData is called and passed the child data.
' Interface Information
'    Stock Implementation   d3d9.dll
'    Custom Implementation  No
'    Inherits from  Nothing
'    Header     d3dx9anim.h
'    Import library     d3dx9.lib
'    Minimum operating systems  Windows 98
' ****************************************************************************************

' ****************************************************************************************
'DECLARE_INTERFACE(ID3DXSaveUserData)
'{
'    STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame,
'                            LPD3DXFILESAVEOBJECT pXofSave,
'                            LPD3DXFILESAVEDATA pXofFrameData) PURE;

'    STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer,
'                            LPD3DXFILESAVEOBJECT pXofSave,
'                            LPD3DXFILESAVEDATA pXofMeshData) PURE;

'    STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE;
'    STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE;

'    // callbacks for the user to register and then save templates to the XFile
'    STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE;
'    STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE;
'};
' ****************************************************************************************

' ****************************************************************************************
' IUnknown virtual table
' ****************************************************************************************
TYPE ID3DXSaveUserData_IUnknownVtbl
   ' IUnknown interface
   QueryInterface AS DWORD              ' Returns pointers to supported interfaces
   AddRef AS DWORD                      ' Increments reference count
   Release AS DWORD                     ' Decrements reference count
   ' ID3DXSaveUserData interface
   AddFrameChildData AS DWORD           ' AddFrameChildData method
   AddMeshChildData AS DWORD            ' AddMeshChildData method
   AddTopLevelDataObjectsPre AS DWORD   ' AddTopLevelDataObjectsPre method
   AddTopLevelDataObjectsPost AS DWORD  ' AddTopLevelDataObjectsPost method
   RegisterTemplates AS DWORD           ' RegisterTemplates method
   SaveTemplates AS DWORD               ' Save templates method
   ' Custom data
   pVtblAddr AS DWORD                   ' Address of the virtual table
   cRef AS DWORD                        ' Reference counter
   pthis AS DWORD                       ' IUnknown of the control that fires the events
END TYPE
' ****************************************************************************************

' ****************************************************************************************
' Builds the IUnknown Virtual Table
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_BuildVtbl (BYVAL pthis AS DWORD) AS DWORD

   LOCAL pVtbl AS ID3DXSaveUserData_IUnknownVtbl PTR
   LOCAL pUnk AS ID3DXSaveUserData_IUnknownVtbl PTR

   pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
   IF pVtbl = 0 THEN EXIT FUNCTION

   @pVTbl.QueryInterface             = CODEPTR(ID3DXSaveUserData_QueryInterface)
   @pVTbl.AddRef                     = CODEPTR(ID3DXSaveUserData_AddRef)
   @pVTbl.Release                    = CODEPTR(ID3DXSaveUserData_Release)
   @pVTbl.AddFrameChildData          = CODEPTR(ID3DXSaveUserData_AddFrameChildData)
   @pVTbl.AddMeshChildData           = CODEPTR(ID3DXSaveUserData_AddMeshChildData)
   @pVTbl.AddTopLevelDataObjectsPre  = CODEPTR(ID3DXSaveUserData_AddTopLevelDataObjectsPre)
   @pVTbl.AddTopLevelDataObjectsPost = CODEPTR(ID3DXSaveUserData_AddTopLevelDataObjectsPost)
   @pVTbl.RegisterTemplates          = CODEPTR(ID3DXSaveUserData_RegisterTemplates)
   @pVTbl.SaveTemplates              = CODEPTR(ID3DXSaveUserData_SaveTemplates)
   @pVtbl.pVtblAddr                  = pVtbl
   @pVtbl.pthis                      = pthis

   pUnk = VARPTR(@pVtbl.pVtblAddr)
   FUNCTION = pUnk

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' UI4 AddRef()
' Increments the reference counter.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_AddRef (BYVAL pthis AS ID3DXSaveUserData_IUnknownVtbl PTR) AS DWORD
   INCR @@pthis.cRef
   FUNCTION = @@pthis.cRef
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' HRESULT QueryInterface([in] *GUID riid, [out] **VOID ppvObj)
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_QueryInterface (BYVAL pthis AS ID3DXSaveUserData_IUnknownVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS DWORD
   ppvObj = pthis
   ID3DXSaveUserData_AddRef pthis
   FUNCTION = %D3D_OK
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' UI4 Release()
' Releases our class if there is only a reference to him and decrements the reference
' counter.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_Release (BYVAL pthis AS ID3DXSaveUserData_IUnknownVtbl PTR) AS DWORD
   LOCAL pVtblAddr AS DWORD
   IF @@pCookie.cRef = 1 THEN
      pVtblAddr = @@pCookie.pVtblAddr
      IF ISTRUE HeapFree(GetProcessHeap(), 0, BYVAL pVtblAddr) THEN
         FUNCTION = 0
         EXIT FUNCTION
      ELSE
         FUNCTION = @@pCookie.cRef
         EXIT FUNCTION
      END IF
   END IF
   DECR @@pCookie.cRef
   FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' AddFrameChildData method
' Add child data to the frame.
' Parameters
'    pFrame
'        [in] Pointer to a mesh container. See D3DXFRAME.
'    pXofSave
'        [in] Pointer to a .x file save object. Use the pointer to call
'        ID3DXFileSaveObject::AddDataObject to add a child data object. Do not save the
'        data with ID3DXFileSaveObject::Save.
'    pXofFrameData
'        [in] Pointer to a .x file data node. Use the pointer to call
'        ID3DXFileSaveData::AddDataObject to add a child data object.
' Return Value
'    The return values of this method are implemented by an application programmer. In
'    general, if no error occurs, program the method to return D3D_OK. Otherwise, program
'    the method to return an appropriate error message from D3DERR or D3DXERR, as this
'    will cause D3DXLoadMeshHierarchyFromX to fail also, and return the error.
' Remarks
'    ID3DXSaveUserData::RegisterTemplates and ID3DXSaveUserData::SaveTemplates provide a
'    mechanism for adding a template to a .x file for saving user data.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_AddFrameChildData ( _
    BYVAL pthis AS DWORD PTR, _
    BYVAL pFrame AS DWORD, _
    BYVAL pXofSave AS DWORD, _
    BYVAL pXofFrameData AS DWORD _
    ) AS LONG

    ' *** Put your code here ***

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' AddMeshChildData method
' Add child data to a mesh.
' Parameters
'    pMeshContainer
'        [in] Pointer to a mesh container. See D3DXMESHCONTAINER.
'    pXofSave
'        [in] Pointer to a .x file save object. Use the pointer to call
'        ID3DXFileSaveObject::AddDataObject to add a child data object. Do not save the
'        data with ID3DXFileSaveObject::Save.
'    pXofMeshData
'        [in] Pointer to a .x file data node. Use the pointer to call
'        ID3DXFileSaveData::AddDataObject to add a child data object.
' Return Value
'    The return values of this method are implemented by an application programmer. In
'    general, if no error occurs, program the method to return D3D_OK. Otherwise, program
'    the method to return an appropriate error message from D3DERR or D3DXERR, as this
'    will cause D3DXLoadMeshHierarchyFromX to fail also, and return the error.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_AddMeshChildData ( _
    BYVAL pthis AS DWORD PTR, _
    BYREF pMeshCOntainer AS D3DXMESHCONTAINER, _
    BYVAL pXofSave AS DWORD, _
    BYVAL pXofMeshData AS DWORD _
    ) AS LONG

    ' *** Put your code here ***

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' AddTopLevelDataObjectsPre method
' Add a top level object before the frame hierarchy.
' Parameters
'    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.
' Return Value
'    The return values of this method are implemented by an application programmer. In
'    general, if no error occurs, program the method to return D3D_OK. Otherwise, program
'    the method to return an appropriate error message from D3DERR or D3DXERR, as this
'    will cause D3DXLoadMeshHierarchyFromX to fail also, and return the error.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_AddTopLevelDataObjectsPre ( _
    BYVAL pthis AS DWORD PTR, _
    BYVAL pXofSave AS DWORD _
    ) AS LONG

    ' *** Put your code here ***

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' AddTopLevelDataObjectsPost method
' Add a top level object after the frame hierarchy.
' Parameters
'    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.
' Return Value
'    The return values of this method are implemented by an application programmer. In
'    general, if no error occurs, program the method to return D3D_OK. Otherwise, program
'    the method to return an appropriate error message from D3DERR or D3DXERR, as this
'    will cause D3DXLoadMeshHierarchyFromX to fail also, and return the error.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_AddTopLevelDataObjectsPost ( _
    BYVAL pthis AS DWORD PTR, _
    BYVAL pXofSave AS DWORD _
    ) AS LONG

    ' *** Put your code here ***

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' RegisterTemplates method
' A callback for the user to register a .x file template.
' Parameters
'    pXFileApi
'        [in] Use this pointer to register user-defined .x file templates. See ID3DXFile.
'        Do not use this parameter to add data objects.
' Return Value
'    The return values of this method are implemented by an application programmer. In
'    general, if no error occurs, program the method to return D3D_OK. Otherwise, program
'    the method to return an appropriate error message from D3DERR or D3DXERR, as this
'    will cause D3DXLoadMeshHierarchyFromX to fail also, and return the error.
' Remarks
'    ID3DXSaveUserData::RegisterTemplates and ID3DXSaveUserData::SaveTemplates provide a
'    mechanism for adding a template to a .x file for saving user data.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_RegisterTemplates ( _
    BYVAL pthis AS DWORD PTR, _
    BYVAL pXFileApi AS DWORD _
    ) AS LONG

    ' *** Put your code here ***

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SaveTemplates method
' A callback for the user to save a .x file template.
' Parameters
'    pXofSave
'        [in] Pointer to a .x file save object. Do not use this parameter to add data
'        objects.
'        See ID3DXFileSaveObject.
' Return Value
'    The return values of this method are implemented by an application programmer. In
'    general, if no error occurs, program the method to return D3D_OK. Otherwise, program
'    the method to return an appropriate error message from D3DERR or D3DXERR, as this
'    will cause D3DXLoadMeshHierarchyFromX to fail also, and return the error.
' Remarks
'    ID3DXSaveUserData::RegisterTemplates and ID3DXSaveUserData::SaveTemplates provide a
'    mechanism for adding a template to a .x file for saving user data.
' ****************************************************************************************
FUNCTION ID3DXSaveUserData_SaveTemplates ( _
    BYVAL pthis AS DWORD PTR, _
    BYVAL pXofSave AS DWORD _
    ) AS LONG

    ' *** Put your code here ***

END FUNCTION
' ****************************************************************************************
 

 

Page last updated on Wednesday, 15 March 2006 02:20:40 +0100