Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

GXModel.h

Go to the documentation of this file.
00001 #ifndef __GXMODEL_H
00002 #define __GXMODEL_H
00003 
00004 
00005 #include "GXStandardDefines.h"
00006 #include "GXSkeleton.h"
00007 #include "GXVertex.h"
00008 #include "GXHashableString.h"
00009 #include "GXBone.h"
00010 #include "GXSphere.h"
00011 
00012 
00013 struct SRenderCall
00014 {
00015         UINT    uAnimationIndex;
00016         float   fAnimationPos;
00017         float   fLOD;
00018 
00019         SGXAnimationKeyFrame RootPos;
00020 
00021         D3DXVECTOR4 vLightDir;
00022         D3DXVECTOR4 vEyePos;
00023 
00024 };
00025 
00026 
00027 
00028 #define TEXTURE_MAP_COUNT 1
00029 #define MODEL_DIFFUSE_TEXTURE_INDEX 0
00030 
00031 class CGXModel
00032 {
00033 public:
00034         CGXModel();
00035         virtual ~CGXModel();
00036 
00037         virtual bool    AddAnimation(CGXKeyframeTemplate<SGXAnimationKeyFrame>* pAnimations);//count = bone count
00038 
00039         virtual bool    LoadFromStream(CGXDeviceContainer* pDevice, 
00040                                                                 IStream* pStream);
00041 
00042         virtual bool    LoadFromData(CGXDeviceContainer* pDevice,
00043                                                                 GXVertex* pVerts,
00044                                                                 UINT* pIndices,
00045                                                                 DWORD dwVertCount,
00046                                                                 DWORD dwIndexCount,
00047                                                                 char** ppTextureNames,//array of sizeTEXTURE_MAP_COUNT
00048                                                                 UINT uBoneCount,
00049                                                                 CGXBone* pBones,
00050                                                                 float fDesiredSize);//each row is an animation, each column is a bone
00051 
00052         virtual bool    WriteToStream(IStream* pStream);
00053 
00054         virtual bool    LoadFromD3DXMesh(ID3DXMesh* pMesh,
00055                                                                         float fDesiredSize);
00056                                                                 
00057 
00058         virtual bool    DrawPrimitive(SRenderCall& RenderInfo, 
00059                                                                 UINT uVertexStream, 
00060                                                                 UINT uTextureStream,
00061                                                                 UINT uStartBoneConstant,
00062                                                                 D3DXMATRIX* pViewProj,
00063                                                                 UINT uViewProjIndex,
00064                                                                 D3DXMATRIX* pOptionalWorldMat=NULL);
00065 
00066         virtual UINT    GetVertexCount();
00067         virtual UINT    GetIndexCount();
00068         virtual UINT    GetFaceCount();
00069 
00070         
00071         virtual UINT    GetBoneCount();
00072         virtual UINT    GetAnimationCount();
00073 
00074         inline IDirect3DTexture8* GetTexture(UINT uIndex)
00075         {
00076                 if(uIndex>=TEXTURE_MAP_COUNT)
00077                 {
00078                         return NULL;
00079                 }
00080                 return m_rgpTextures[uIndex];
00081         }
00082 
00083         inline  bool    ReadyToRender()
00084         {
00085                 return (m_pMesh!=NULL);
00086         }
00087 
00088         inline float GetDiffuseFactor()
00089         {
00090                 return m_fDiffuseFactor;
00091         }
00092 
00093         inline float GetSpecularCooef()
00094         {
00095                 return m_fSpecularCooef;
00096         }
00097 
00098         inline void SetDiffuseFactor(float fFactor)
00099         {
00100                 m_fDiffuseFactor=fFactor;
00101         }
00102 
00103         inline void SetSpecularCooef(float fNewCooef)
00104         {
00105                 m_fSpecularCooef=fNewCooef;
00106         }
00107 
00108 
00109 
00110 protected:
00111         ID3DXPMesh*                     m_pMesh;
00112         CGXDeviceContainer*     m_pDevice;
00113         CGXSkeleton                     m_Skeleton;
00114         IDirect3DTexture8*      m_rgpTextures[TEXTURE_MAP_COUNT];
00115         float                           m_fBoundingSphereRadius;
00116 
00117         float                           m_fDiffuseFactor;//lerp amount between diffuse and spec
00118         float                           m_fSpecularCooef;//higher (like 50)==sharper specular
00119 
00120 
00121 
00122 protected:
00123         virtual void    Cleanup();
00124         virtual DWORD   GetOptions(CGXDeviceContainer* pDevice);
00125 };
00126 
00127 
00128 #endif

Generated on Thu May 23 17:51:00 2002 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001