D3DXFile.h
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:4k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1999 DXGuide. All Rights Reserved.
- // File: D3DXFile.h
- #ifndef _D3DXFILE__H
- #define _D3DXFILE__H
- #include "D3DMatrix.h" // for CD3DMatrix
- class CD3DDevice;
- class CD3DFileBaseObject;
- class CD3DFileFrame;
- class CPackFileManager;
- class CD3DXFile
- {
- friend class CD3DFileMesh;
- public:
- CD3DXFile(void);
- ~CD3DXFile();
- public:
- bool Load(CD3DDevice* pD3DDevice,
- LPCTSTR lpszFileName,
- CPackFileManager* pPackFileManager = NULL);
- public:
- bool Render(void);
- bool GetBoundingSphere(D3DVECTOR* pvCenterPt,
- D3DVALUE* pfRadius);
- bool GetFrameMatrix(LPCTSTR lpszName,
- CD3DMatrix** ppmat);
- bool GetMeshVertices(LPCTSTR lpszName,
- D3DVERTEX** ppVertices,
- DWORD* pdwNumVertices,
- WORD** ppwIndices,
- DWORD* pdwNumIndices);
- protected:
- CD3DFileFrame* m_pRootFrame;
- CPackFileManager* m_pPackFileManager;
- public:
- CD3DDevice* m_pD3DDevice;
- };
- // Internal class used by the CD3DXFile to hold data for a geometry file
- class CD3DFileBaseObject
- {
- protected:
- CD3DFileBaseObject(LPCTSTR lpszName,
- CD3DXFile* pD3DXFile);
- virtual ~CD3DFileBaseObject();
- public:
- virtual void Render(void) = 0;
- virtual void ComputeBoundingSphereCenter(CD3DMatrix* pmat, D3DVECTOR*, DWORD*);
- virtual void ComputeBoundingSphereRadius(CD3DMatrix* pmat, D3DVECTOR* pvCenter,
- D3DVALUE* pfRadius);
- virtual bool GetFrameMatrix(LPCTSTR lpszName,
- CD3DMatrix** ppMatrix);
- virtual bool GetMeshVertices(LPCTSTR lpszName,
- D3DVERTEX** ppvVertices,
- DWORD* pdwNumVertices,
- WORD** ppwIndices,
- DWORD* pdwNumIndices);
- public:
- void AddNext(CD3DFileBaseObject* pChild);
- void AddChild(CD3DFileBaseObject* pNext);
- protected:
- CD3DFileBaseObject* m_pNext;
- CD3DFileBaseObject* m_pChild;
- CString m_strName;
- CD3DXFile* m_pD3DXFile;
- };
- class CD3DFileFrame : public CD3DFileBaseObject
- {
- friend class CD3DXFile;
- friend class CDXFileData;
- protected:
- CD3DFileFrame(LPCTSTR lpszName, CD3DXFile* pD3DXFile);
- virtual ~CD3DFileFrame();
- public:
- virtual void Render(void);
- virtual void ComputeBoundingSphereCenter(CD3DMatrix* pmat,
- D3DVECTOR*, DWORD*);
- virtual void ComputeBoundingSphereRadius(CD3DMatrix* pmat,
- D3DVECTOR* pvCenter, D3DVALUE* pfRadius);
- virtual bool GetFrameMatrix(LPCTSTR lpszName,
- CD3DMatrix** ppMatrix);
- public:
- void SetMatrix(CD3DMatrix* pmat)
- {
- m_mat = *pmat;
- }
- protected:
- CD3DMatrix m_mat;
- };
- class CD3DTexture;
- class CD3DFileMesh : public CD3DFileBaseObject
- {
- friend class CDXFileData;
- protected:
- CD3DFileMesh(LPCTSTR lpszName,
- CD3DXFile* pD3DXFile,
- DWORD dwNumVertices, D3DVECTOR* pVertexData,
- DWORD dwNumFaces, void* pFaceData);
- virtual ~CD3DFileMesh();
- public:
- virtual void Render(void);
- virtual void ComputeBoundingSphereCenter(
- CD3DMatrix* pmat, D3DVECTOR*, DWORD*);
- virtual void ComputeBoundingSphereRadius(
- CD3DMatrix* pmat, D3DVECTOR* pvCenter,
- D3DVALUE* pfRadius);
- virtual bool GetMeshVertices(LPCTSTR lpszName,
- D3DVERTEX** ppvVertices,
- DWORD* pdwNumVertices,
- WORD** ppwIndices,
- DWORD* pdwNumIndices);
- public:
- bool SetTexture(LPCTSTR lpszName);
- void SetNormals(D3DVECTOR* pNormals);
- void SetTextureCoords(D3DVALUE* pTexCoords);
- void SetMaterial(D3DMATERIAL7* pMaterial);
- protected:
- bool ComputeNormals(void);
- protected:
- D3DMATERIAL7* m_pMaterial;
- CD3DTexture* m_pD3DTexture;
- DWORD m_dwNumVertices;
- D3DVERTEX* m_pVertices;
- DWORD m_dwNumIndices;
- WORD* m_pIndices;
- };
- #endif // _D3DXFILE__H