- Cal3D 0.11 API Reference -

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 #include "cal3d/global.h"
00016 #include "cal3d/coresubmesh.h"
00017 
00018 
00019 class CalCoreModel;
00020 class CalSkeleton;
00021 class CalCoreMaterial;
00022 
00023 
00024 class CAL3D_API CalHardwareModel
00025 {
00026 public:
00027   struct CalHardwareMesh
00028   {
00029     std::vector<int> m_vectorBonesIndices;
00030     
00031     int baseVertexIndex;
00032     int vertexCount;
00033     int startIndex;
00034     int faceCount;
00035     CalCoreMaterial *pCoreMaterial;
00036 
00037     int meshId,submeshId;
00038   };
00039 
00040 public:
00041   CalHardwareModel(CalCoreModel* pCoreModel);
00042   ~CalHardwareModel() { }
00043   
00044   void setVertexBuffer( char * pVertexBuffer, int stride); 
00045   void setIndexBuffer( CalIndex * pIndexBuffer); 
00046   void setNormalBuffer( char * pNormalBuffer, int stride); 
00047   void setWeightBuffer( char * pWeightBuffer, int stride); 
00048   void setMatrixIndexBuffer( char * pMatrixIndexBuffer, int stride); 
00049   void setTextureCoordNum(int textureCoordNum);
00050   void setTextureCoordBuffer(int mapId, char * pTextureCoordBuffer, int stride);
00051   void setTangentSpaceBuffer(int mapId, char * pTangentSpaceBuffer, int stride);
00052   void setCoreMeshIds(const std::vector<int>& coreMeshIds);
00053 
00054   bool load(int baseVertexIndex, int startIndex,int maxBonesPerMesh);
00055       
00056   std::vector<CalHardwareMesh> & getVectorHardwareMesh();
00057   void getAmbientColor(unsigned char *pColorBuffer);
00058   void getDiffuseColor(unsigned char *pColorBuffer);
00059   void getSpecularColor(unsigned char *pColorBuffer);
00060   const CalQuaternion & getRotationBoneSpace(int boneId, CalSkeleton *pSkeleton);
00061   const CalVector & getTranslationBoneSpace(int boneId, CalSkeleton *pSkeleton);
00062 
00063   float getShininess();
00064   
00065   int getHardwareMeshCount();
00066   int getFaceCount();
00067   int getVertexCount();
00068   int getBoneCount();
00069 
00070   int getBaseVertexIndex();
00071   int getStartIndex();
00072 
00073   int getTotalFaceCount();
00074   int getTotalVertexCount();    
00075 
00076   Cal::UserData getMapUserData(int mapId);
00077   
00078   bool selectHardwareMesh(size_t meshId);
00079   
00080 private:
00081   bool canAddFace(CalHardwareMesh &hardwareMesh, CalCoreSubmesh::Face & face,std::vector<CalCoreSubmesh::Vertex>& vectorVertex, int maxBonesPerMesh);
00082   int  addVertex(CalHardwareMesh &hardwareMesh, int indice , CalCoreSubmesh *pCoreSubmesh, int maxBonesPerMesh);
00083   int  addBoneIndice(CalHardwareMesh &hardwareMesh, int Indice, int maxBonesPerMesh);  
00084     
00085 
00086 private:
00087   
00088   std::vector<CalHardwareMesh> m_vectorHardwareMesh;
00089   std::vector<CalIndex> m_vectorVertexIndiceUsed;
00090   int m_selectedHardwareMesh;
00091   std::vector<int> m_coreMeshIds;
00092   CalCoreModel *m_pCoreModel;
00093   
00094   
00095   char * m_pVertexBuffer;
00096   int m_vertexStride;
00097   char * m_pNormalBuffer;
00098   int m_normalStride;
00099   char * m_pWeightBuffer;
00100   int m_weightStride;
00101   char * m_pMatrixIndexBuffer;
00102   int m_matrixIndexStride;
00103   char * m_pTextureCoordBuffer[8];
00104   int m_textureCoordStride[8];
00105   int m_textureCoordNum;  
00106   char * m_pTangentSpaceBuffer[8];
00107   int m_tangentSpaceStride[8];
00108   
00109   CalIndex * m_pIndexBuffer;
00110 
00111   int m_totalVertexCount;
00112   int m_totalFaceCount;
00113 };
00114 
00115 #endif

Generated at Thu Jun 29 19:03:59 2006 by The Cal3D Team with Doxygen 1.4.6