0001:
0002:
0003:
0004:
0005:
0006: #ifndef D3DFILE_H
0007: #define D3DFILE_H
0008: #include <tchar.h>
0009: #include <d3d8.h>
0010: #include <d3dx8.h>
0011:
0012:
0013:
0014:
0015:
0016:
0017:
0018:
0019:
0020: class CD3DMesh
0021: {
0022: public:
0023: TCHAR m_strName[512];
0024:
0025: LPD3DXMESH m_pSysMemMesh;
0026: LPD3DXMESH m_pLocalMesh;
0027:
0028: DWORD m_dwNumMaterials;
0029: D3DMATERIAL8* m_pMaterials;
0030: LPDIRECT3DTEXTURE8* m_pTextures;
0031: BOOL m_bUseMaterials;
0032:
0033: public:
0034:
0035: HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice,
0036: BOOL bDrawOpaqueSubsets = TRUE,
0037: BOOL bDrawAlphaSubsets = TRUE );
0038:
0039:
0040: LPD3DXMESH GetSysMemMesh() { return m_pSysMemMesh; }
0041: LPD3DXMESH GetLocalMesh() { return m_pLocalMesh; }
0042:
0043:
0044: VOID UseMeshMaterials( BOOL bFlag ) { m_bUseMaterials = bFlag; }
0045: HRESULT SetFVF( LPDIRECT3DDEVICE8 pd3dDevice, DWORD dwFVF );
0046:
0047:
0048: HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
0049: HRESULT InvalidateDeviceObjects();
0050:
0051:
0052: HRESULT Create( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strFilename );
0053: HRESULT Create( LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECTXFILEDATA pFileData );
0054: HRESULT Destroy();
0055:
0056: CD3DMesh( TCHAR* strName = _T("CD3DFile_Mesh") );
0057: virtual ~CD3DMesh();
0058: };
0059:
0060:
0061:
0062:
0063:
0064:
0065:
0066:
0067: class CD3DFrame
0068: {
0069: public:
0070: TCHAR m_strName[512];
0071: D3DXMATRIX m_mat;
0072: CD3DMesh* m_pMesh;
0073: TCHAR m_strMeshName[512];
0074:
0075: CD3DFrame* m_pNext;
0076: CD3DFrame* m_pChild;
0077:
0078: public:
0079:
0080: VOID SetMatrix( D3DXMATRIX* pmat ) { m_mat = *pmat; }
0081: D3DXMATRIX* GetMatrix() { return &m_mat; }
0082:
0083: CD3DMesh* FindMesh( TCHAR* strMeshName );
0084: CD3DFrame* FindFrame( TCHAR* strFrameName );
0085: BOOL EnumMeshes( BOOL (*EnumMeshCB)(CD3DMesh*,VOID*),
0086: VOID* pContext );
0087:
0088: HRESULT Destroy();
0089: HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
0090: HRESULT InvalidateDeviceObjects();
0091: HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice,
0092: BOOL bDrawOpaqueSubsets = TRUE,
0093: BOOL bDrawAlphaSubsets = TRUE,
0094: D3DXMATRIX* pmatWorldMartix = NULL);
0095:
0096: CD3DFrame( TCHAR* strName = _T("CD3DFile_Frame") );
0097: virtual ~CD3DFrame();
0098: };
0099:
0100:
0101:
0102:
0103:
0104:
0105:
0106:
0107: class CD3DFile : public CD3DFrame
0108: {
0109: HRESULT LoadMesh( LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECTXFILEDATA pFileData,
0110: CD3DFrame* pParentFrame );
0111: HRESULT LoadFrame( LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECTXFILEDATA pFileData,
0112: CD3DFrame* pParentFrame );
0113: public:
0114: HRESULT Create( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strFilename );
0115: HRESULT CreateFromResource( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strResource, TCHAR* strType );
0116:
0117:
0118: HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice, D3DXMATRIX* pmatWorldMatrix = NULL );
0119:
0120: CD3DFile() : CD3DFrame( _T("CD3DFile_Root") ) {}
0121: };
0122:
0123:
0124:
0125: #endif
0126:
0127:
0128:
0129: