- Cal3D 0.11 API Reference -

coresubmesh.h

00001 //****************************************************************************//
00002 // coresubmesh.h                                                              //
00003 // Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger                       //
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_CORESUBMESH_H
00012 #define CAL_CORESUBMESH_H
00013 
00014 
00015 #include "cal3d/global.h"
00016 #include "cal3d/vector.h"
00017 
00018 
00019 class CalCoreSubMorphTarget;
00020 
00021 
00022 enum CalMorphTargetType {
00023   CalMorphTargetTypeNull = 0,
00024   CalMorphTargetTypeAdditive,
00025   CalMorphTargetTypeClamped,
00026   CalMorphTargetTypeAverage,
00027   CalMorphTargetTypeExclusive
00028 };
00029 
00030 
00031 class CAL3D_API CalCoreSubmesh
00032 {
00033 public:
00034   struct TextureCoordinate
00035   {
00036     float u, v;
00037   };
00038 
00039   struct TangentSpace
00040   {
00041     CalVector tangent;
00042     float crossFactor;  // To get the binormal, use ((N x T) * crossFactor)
00043   };
00044 
00045   struct Influence
00046   {
00047     int boneId;
00048     float weight;
00049   };
00050 
00051   struct PhysicalProperty
00052   {
00053     float weight;
00054   };
00055 
00056   struct Vertex
00057   {
00058     CalVector position;
00059     CalVector normal;
00060     std::vector<Influence> vectorInfluence;
00061     int collapseId;
00062     int faceCollapseCount;
00063     CalVector vertexColor; 
00064   };
00065 
00066   struct Face
00067   {
00068     CalIndex vertexId[3];
00069   };
00070   
00072   struct Spring
00073   {
00074     int vertexId[2];
00075     float springCoefficient;
00076     float idleLength;
00077   };
00078 
00079 public:
00080   CalCoreSubmesh();
00081   ~CalCoreSubmesh();
00082 
00083   int getCoreMaterialThreadId() const;
00084   int getFaceCount() const;
00085   typedef std::vector<CalCoreSubMorphTarget *> CoreSubMorphTargetVector;
00086   typedef std::vector<Face> VectorFace;
00087   typedef std::vector<PhysicalProperty> VectorPhysicalProperty;
00088   typedef std::vector<Spring> VectorSpring;
00089   typedef std::vector<TangentSpace> VectorTangentSpace;
00090   typedef std::vector<TextureCoordinate> VectorTextureCoordinate;
00091   typedef std::vector<VectorTangentSpace > VectorVectorTangentSpace;
00092   typedef std::vector<VectorTextureCoordinate > VectorVectorTextureCoordinate;
00093   typedef std::vector<Vertex> VectorVertex;
00094   typedef std::vector<Influence> VectorInfluence;
00095   unsigned int size();
00096   unsigned int sizeWithoutSubMorphTargets();
00097   int getLodCount() const;
00098   int getSpringCount() const;
00099   bool hasNonWhiteVertexColors() { return m_hasNonWhiteVertexColors; }
00100   std::vector<Face>& getVectorFace();
00101   const std::vector<Face>& getVectorFace() const;
00102   std::vector<PhysicalProperty>& getVectorPhysicalProperty();
00103   const std::vector<PhysicalProperty>& getVectorPhysicalProperty() const;
00104   std::vector<Spring>& getVectorSpring();
00105   const std::vector<Spring>& getVectorSpring() const;
00106   std::vector<std::vector<TangentSpace> >& getVectorVectorTangentSpace();
00107   const std::vector<std::vector<TangentSpace> >& getVectorVectorTangentSpace() const;
00108   std::vector<std::vector<TextureCoordinate> >& getVectorVectorTextureCoordinate();
00109   const std::vector<std::vector<TextureCoordinate> >& getVectorVectorTextureCoordinate() const;
00110   std::vector<Vertex>& getVectorVertex();
00111   const std::vector<Vertex>& getVectorVertex() const;
00112   int getVertexCount() const;
00113   bool isTangentsEnabled(int mapId) const;
00114   bool enableTangents(int mapId, bool enabled);
00115   bool reserve(int vertexCount, int textureCoordinateCount, int faceCount, int springCount);
00116   void setCoreMaterialThreadId(int coreMaterialThreadId);
00117   bool setFace(int faceId, const Face& face);
00118   void setLodCount(int lodCount);
00119   bool setPhysicalProperty(int vertexId, const PhysicalProperty& physicalProperty);
00120   bool setSpring(int springId, const Spring& spring);
00121   bool setTangentSpace(int vertexId, int textureCoordinateId, const CalVector& tangent, float crossFactor);
00122   bool setTextureCoordinate(int vertexId, int textureCoordinateId, const TextureCoordinate& textureCoordinate);
00123   bool setVertex(int vertexId, const Vertex& vertex);
00124   void setHasNonWhiteVertexColors( bool p ) { m_hasNonWhiteVertexColors = p; }
00125   int addCoreSubMorphTarget(CalCoreSubMorphTarget *pCoreSubMorphTarget);
00126   CalCoreSubMorphTarget *getCoreSubMorphTarget(int id);
00127   const CalCoreSubMorphTarget *getCoreSubMorphTarget(int id) const;
00128   int getCoreSubMorphTargetCount() const;
00129   std::vector<CalCoreSubMorphTarget *>& getVectorCoreSubMorphTarget();
00130   const std::vector<CalCoreSubMorphTarget *>& getVectorCoreSubMorphTarget() const;
00131   void scale(float factor);
00132   void setSubMorphTargetGroupIndexArray( unsigned int len, unsigned int const * indexArray );
00133   inline unsigned int subMorphTargetGroupIndex( int subMorphTargetId ) { 
00134     if( size_t(subMorphTargetId) >= m_vectorSubMorphTargetGroupIndex.size() ) return 0xffffffff;
00135     return m_vectorSubMorphTargetGroupIndex[ subMorphTargetId ]; }
00136 
00137 private:
00138   void UpdateTangentVector(int v0, int v1, int v2, int channel);
00139 
00140   std::vector<Vertex>                          m_vectorVertex;
00141   std::vector<bool>                            m_vectorTangentsEnabled;
00142   std::vector<std::vector<TangentSpace> >      m_vectorvectorTangentSpace;
00143   std::vector<std::vector<TextureCoordinate> > m_vectorvectorTextureCoordinate;
00144   std::vector<PhysicalProperty>                m_vectorPhysicalProperty;
00145   std::vector<Face>                            m_vectorFace;
00146   std::vector<Spring>                          m_vectorSpring;
00147   std::vector<CalCoreSubMorphTarget *>         m_vectorCoreSubMorphTarget;
00148   int                                          m_coreMaterialThreadId;
00149   int                                          m_lodCount;
00150   std::vector<unsigned int>                    m_vectorSubMorphTargetGroupIndex;
00151   bool                                         m_hasNonWhiteVertexColors;
00152 };
00153 
00154 #endif
00155 
00156 //****************************************************************************//

Generated by The Cal3D Team with Doxygen 1.7.3