- Cal3D 0.9 API Reference -

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

hardwaremodel.h

00001 //****************************************************************************//
00002 // hardwaremodel.h                                                         //
00003 // Copyright (C) 2004 Desmecht Laurent                                        //
00004 //****************************************************************************//
00005 // This library is free software; you can redistribute it and/or modify it    //
00006 // under the terms of the GNU Lesser General Public License as published by   //
00007 // the Free Software Foundation; either version 2.1 of the License, or (at    //
00008 // your option) any later version.                                            //
00009 //****************************************************************************//
00010 
00011 #ifndef CAL_HARDWAREMODEL_H
00012 #define CAL_HARDWAREMODEL_H
00013 
00014 //****************************************************************************//
00015 // Includes                                                                   //
00016 //****************************************************************************//
00017 
00018 #include "cal3d/global.h"
00019 #include "cal3d/coresubmesh.h"
00020 
00021 //****************************************************************************//
00022 // Forward declarations                                                       //
00023 //****************************************************************************//
00024 
00025 class CalCoreModel;
00026 class CalSkeleton;
00027 class CalCoreMaterial;
00028 
00029 
00030 //****************************************************************************//
00031 // Class declaration                                                          //
00032 //****************************************************************************//
00033 
00034 /*****************************************************************************/
00038 class CAL3D_API CalHardwareModel
00039 {
00040 public:
00041     struct CalHardwareMesh
00042     {
00043         std::vector<int> m_vectorBonesIndices;
00044         
00045         int baseVertexIndex;
00046         int vertexCount;
00047         int startIndex;
00048         int faceCount;
00049         CalCoreMaterial *pCoreMaterial;
00050 
00051         int meshId,submeshId;
00052     };
00053     
00054 
00055     // member variables
00056 private:
00057     
00058     std::vector<CalHardwareMesh> m_vectorHardwareMesh;
00059     std::vector<CalIndex> m_vectorVertexIndiceUsed;
00060     int m_selectedHardwareMesh;
00061     std::vector<int> m_coreMeshIds;
00062     CalCoreModel *m_pCoreModel;
00063     
00064     
00065     char * m_pVertexBuffer;
00066     int m_vertexStride;
00067     char * m_pNormalBuffer;
00068     int m_normalStride;
00069     char * m_pWeightBuffer;
00070     int m_weightStride;
00071     char * m_pMatrixIndexBuffer;
00072     int m_matrixIndexStride;
00073     char * m_pTextureCoordBuffer[8];
00074     int m_textureCoordStride[8];
00075     int m_textureCoordNum;
00076     
00077     CalIndex * m_pIndexBuffer;
00078 
00079     int m_totalVertexCount;
00080     int m_totalFaceCount;
00081 
00082     
00083     
00084     // constructors/destructor
00085     public:
00086         CalHardwareModel();
00087         virtual ~CalHardwareModel();
00088         
00089         // member functions 
00090     public:
00091         bool create(CalCoreModel *pCoreModel);
00092         
00093         void setVertexBuffer( char * pVertexBuffer, int stride); 
00094         void setIndexBuffer( CalIndex * pIndexBuffer); 
00095         void setNormalBuffer( char * pNormalBuffer, int stride); 
00096         void setWeightBuffer( char * pWeightBuffer, int stride); 
00097         void setMatrixIndexBuffer( char * pMatrixIndexBuffer, int stride); 
00098         void setTextureCoordNum(int textureCoordNum);
00099         void setTextureCoordBuffer(int mapId, char * pTextureCoordBuffer, int stride); 
00100         void setCoreMeshIds(const std::vector<int>& coreMeshIds);
00101 
00102         bool load(int baseVertexIndex, int startIndex,int maxBonesPerMesh);
00103                 
00104         void destroy();
00105         
00106         std::vector<CalHardwareMesh> & getVectorHardwareMesh();
00107         void getAmbientColor(unsigned char *pColorBuffer);
00108         void getDiffuseColor(unsigned char *pColorBuffer);
00109         void getSpecularColor(unsigned char *pColorBuffer);
00110         const CalQuaternion & getRotationBoneSpace(int boneId, CalSkeleton *pSkeleton);
00111         const CalVector & getTranslationBoneSpace(int boneId, CalSkeleton *pSkeleton);
00112 
00113         float getShininess();
00114         
00115         int getHardwareMeshCount();
00116         int getFaceCount();
00117         int getVertexCount();
00118         int getBoneCount();
00119     
00120         int getBaseVertexIndex();
00121         int getStartIndex();
00122 
00123         int getTotalFaceCount();
00124         int getTotalVertexCount();      
00125     
00126         Cal::UserData getMapUserData(int mapId);
00127         
00128         bool selectHardwareMesh(int meshId);  
00129         
00130     private:
00131         bool canAddFace(CalHardwareMesh &hardwareMesh, CalCoreSubmesh::Face & face,std::vector<CalCoreSubmesh::Vertex>& vectorVertex, int maxBonesPerMesh);
00132         int  addVertex(CalHardwareMesh &hardwareMesh, int indice ,std::vector<CalCoreSubmesh::Vertex>& vectorVertex,  std::vector< std::vector<CalCoreSubmesh::TextureCoordinate> >& vectorTexCoord, int maxBonesPerMesh);
00133         int  addBoneIndice(CalHardwareMesh &hardwareMesh, int Indice, int maxBonesPerMesh);  
00134         
00135 };
00136 
00137 #endif
00138 
00139 //****************************************************************************//

Generated at Thu Dec 2 20:30:17 2004 by The Cal3D Team with doxygen 1.3.9.1 © 1997-2001 Dimitri van Heesch