00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef CAL_SUBMESH_H
00012 #define CAL_SUBMESH_H
00013
00014
00015 #include "cal3d/global.h"
00016 #include "cal3d/vector.h"
00017 #include "cal3d/coresubmesh.h"
00018
00019
00020 class CalCoreSubmesh;
00021
00022
00023
00024 struct MorphIdAndWeight {
00025 int morphId_;
00026 float weight_;
00027 };
00028 class CAL3D_API CalSubmesh
00029 {
00030 public:
00031 struct PhysicalProperty
00032 {
00033 CalVector position;
00034 CalVector positionOld;
00035 CalVector force;
00036 };
00037
00038 struct TangentSpace
00039 {
00040 CalVector tangent;
00041 float crossFactor;
00042 };
00043
00044 struct Face
00045 {
00046 CalIndex vertexId[3];
00047 };
00048
00049 public:
00050 CalSubmesh(CalCoreSubmesh *coreSubmesh);
00051 ~CalSubmesh() { }
00052
00053 CalCoreSubmesh *getCoreSubmesh();
00054 const CalCoreSubmesh *getCoreSubmesh() const;
00055 int getCoreMaterialId() const;
00056 int getFaceCount() const;
00057 int getFaces(CalIndex *pFaceBuffer) const;
00058 std::vector<CalVector>& getVectorNormal();
00059 const std::vector<CalVector>& getVectorNormal() const;
00060 std::vector<std::vector<TangentSpace> >& getVectorVectorTangentSpace();
00061 const std::vector<std::vector<TangentSpace> >& getVectorVectorTangentSpace() const;
00062 std::vector<PhysicalProperty>& getVectorPhysicalProperty();
00063 const std::vector<PhysicalProperty>& getVectorPhysicalProperty() const;
00064 std::vector<CalVector>& getVectorVertex();
00065 const std::vector<CalVector>& getVectorVertex() const;
00066 int getVertexCount() const;
00067 bool hasInternalData() const;
00068 void disableInternalData();
00069 void setCoreMaterialId(int coreMaterialId);
00070 void setLodLevel(float lodLevel);
00071 bool isTangentsEnabled(int mapId) const;
00072 bool enableTangents(int mapId, bool enabled);
00073 void setMorphTargetWeight(int blendId, float weight);
00074 float getMorphTargetWeight(int blendId) const;
00075 void setMorphTargetWeight(std::string const & morphName,float weight);
00076 int getMorphTargetWeightCount() const;
00077 bool getMorphTargetWeight(std::string const & morphName, float * weightOut);
00078 void getMorphIdAndWeightArray( MorphIdAndWeight * arrayResult,
00079 unsigned int * numMiawsResult,
00080 unsigned int maxMiaws );
00081 float getBaseWeight() const;
00082 std::vector<float>& getVectorMorphTargetWeight();
00083 const std::vector<float>& getVectorMorphTargetWeight() const;
00084 void clearMorphTargetScales();
00085 void clearMorphTargetState( std::string const & morphName );
00086 void blendMorphTargetScale( std::string const & morphName,
00087 float scale,
00088 float unrampedWeight,
00089 float rampValue,
00090 bool replace );
00091 void setSubMorphTargetGroupAttenuatorArray( unsigned int len, int const * morphTargetIdArray );
00092 void setSubMorphTargetGroupAttenuationArray( unsigned int len, float const * attenuationArray );
00093 private:
00094 CalCoreSubmesh *m_pCoreSubmesh;
00095 std::vector<float> m_vectorMorphTargetWeight;
00096 std::vector<float> m_vectorAccumulatedWeight;
00097 std::vector<float> m_vectorReplacementAttenuation;
00098 std::vector<CalVector> m_vectorVertex;
00099 std::vector<CalVector> m_vectorNormal;
00100 std::vector<std::vector<TangentSpace> > m_vectorvectorTangentSpace;
00101 std::vector<Face> m_vectorFace;
00102 std::vector<PhysicalProperty> m_vectorPhysicalProperty;
00103 std::vector<int> m_vectorSubMorphTargetGroupAttenuator;
00104 std::vector<float> m_vectorSubMorphTargetGroupAttenuation;
00105 int m_vertexCount;
00106 int m_faceCount;
00107 int m_coreMaterialId;
00108 bool m_bInternalData;
00109 };
00110
00111 #endif