|
|
|
ID3DXLoadUserData Interface |
|
' ****************************************************************************************
' ID3DXLoadUserData 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 D3DXLoadMeshHierarchyFromX,
' 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, ID3DXLoadUserData::LoadFrameChildData
' 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(ID3DXLoadUserData)
'{
' STDMETHOD(LoadTopLevelData)(LPD3DXFILEDATA pXofChildData) PURE;
' STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame,
' LPD3DXFILEDATA pXofChildData) PURE;
' STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer,
' LPD3DXFILEDATA pXofChildData) PURE;
'};
' ****************************************************************************************
' ****************************************************************************************
' ID3DXLoadUserData Interface
' ****************************************************************************************
' ****************************************************************************************
' This interface is implemented by the application to allocate or free frame and mesh
' container objects. Methods on this are called during loading and destroying frame
' hierarchies.
' Interface Information
' Stock Implementation d3d9.dll
' Custom Implementation No
' Inherits from IUnknown
' Header d3dx9anim.h
' Import library d3dx9.lib
' Minimum operating systems Windows 98
' ****************************************************************************************
' ****************************************************************************************
'DECLARE_INTERFACE(ID3DXLoadUserData)
'{
' STDMETHOD(CreateFrame)(THIS_ LPCSTR Name,
' LPD3DXFRAME *ppNewFrame) PURE;
' STDMETHOD(CreateMeshContainer)(THIS_
' LPCSTR Name,
' CONST D3DXMESHDATA *pMeshData,
' CONST D3DXMATERIAL *pMaterials,
' CONST D3DXEFFECTINSTANCE *pEffectInstances,
' DWORD NumMaterials,
' CONST DWORD *pAdjacency,
' LPD3DXSKININFO pSkinInfo,
' LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE;
' STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE;
' STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE;
'};
' ****************************************************************************************
' ****************************************************************************************
' IUnknown virtual table
' ****************************************************************************************
TYPE ID3DXLoadUserData_IUnknownVtbl
' IUnknown interface
QueryInterface AS DWORD ' Returns pointers to supported interfaces
AddRef AS DWORD ' Increments reference count
Release AS DWORD ' Decrements reference count
' ID3DXLoadUserData interface
LoadTopLevelData AS DWORD ' LoadTopLevelData method
LoadFrameChildData AS DWORD ' LoadFrameChildData method
LoadMeshChildData AS DWORD ' LoadMeshChildData 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 ID3DXLoadUserData_BuildVtbl (BYVAL pthis AS DWORD) AS DWORD
LOCAL pVtbl AS ID3DXLoadUserData_IUnknownVtbl PTR
LOCAL pUnk AS ID3DXLoadUserData_IUnknownVtbl PTR
pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
IF pVtbl = 0 THEN EXIT FUNCTION
@pVTbl.QueryInterface = CODEPTR(ID3DXLoadUserData_QueryInterface)
@pVTbl.AddRef = CODEPTR(ID3DXLoadUserData_AddRef)
@pVTbl.Release = CODEPTR(ID3DXLoadUserData_Release)
@pVTbl.LoadTopLevelData = CODEPTR(ID3DXLoadUserData_LoadTopLevelData)
@pVTbl.LoadFrameChildData = CODEPTR(ID3DXLoadUserData_LoadFrameChildData)
@pVTbl.LoadMeshChildData = CODEPTR(ID3DXLoadUserData_LoadMeshChildData)
@pVtbl.pVtblAddr = pVtbl
@pVtbl.pthis = pthis
pUnk = VARPTR(@pVtbl.pVtblAddr)
FUNCTION = pUnk
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' UI4 AddRef()
' Increments the reference counter.
' ****************************************************************************************
FUNCTION ID3DXLoadUserData_AddRef (BYVAL pthis AS ID3DXLoadUserData_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 ID3DXLoadUserData_QueryInterface (BYVAL pthis AS ID3DXLoadUserData_IUnknownVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS DWORD
ppvObj = pthis
ID3DXLoadUserData_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 ID3DXLoadUserData_Release (BYVAL pthis AS ID3DXLoadUserData_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
' ****************************************************************************************
' ****************************************************************************************
' LoadTopLevelData Method
' Load top level data from a .x file.
' Parameters
' pXofChildData
' [in] Pointer to a .x file data structure. This is defined in Dxfile.h.
' 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 ID3DXLoadUserData_LoadTopLevelData ( _
BYVAL pthis AS DWORD PTR, _
BYVAL pXofChildData AS DWORD _
) AS LONG
' *** Put your code here ***
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' LoadFrameChildData Method
' Load frame child data from a .x file.
' Parameters
' pFrame
' [in] Pointer to a mesh container. See D3DXFRAME.
' pXofChildData
' [in] Pointer to a .x file data structure. This is defined in Dxfile.h.
' 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 ID3DXLoadUserData_LoadFrameChildData ( _
BYVAL pthis AS DWORD PTR, _
BYVAL pFrame AS DWORD, _
BYVAL pXofChildData AS DWORD _
) AS LONG
' *** Put your code here ***
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' LoadMeshChildData Method
' Load mesh child data from a .x file.
' Parameters
' pMeshContainer
' [in] Pointer to a mesh container. See D3DXMESHCONTAINER.
' pXofChildData
' [in] Pointer to a .x file data structure. This is defined in Dxfile.h.
' 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 ID3DXLoadUserData_LoadMeshChildData ( _
BYVAL pthis AS DWORD PTR, _
BYVAL pMeshContainer AS DWORD, _
BYVAL pXofChildData AS DWORD _
) AS LONG
' *** Put your code here ***
END FUNCTION
' ****************************************************************************************
|
Page last updated on Wednesday, 15 March 2006 02:18:29 +0100