- Cal3D 0.11 API Reference -

coresubmesh.h
1 //****************************************************************************//
2 // coresubmesh.h //
3 // Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger //
4 //****************************************************************************//
5 // This library is free software; you can redistribute it and/or modify it //
6 // under the terms of the GNU Lesser General Public License as published by //
7 // the Free Software Foundation; either version 2.1 of the License, or (at //
8 // your option) any later version. //
9 //****************************************************************************//
10 
11 #ifndef CAL_CORESUBMESH_H
12 #define CAL_CORESUBMESH_H
13 
14 
15 #include "cal3d/global.h"
16 #include "cal3d/vector.h"
17 
18 
20 
21 
22 enum CalMorphTargetType {
23  CalMorphTargetTypeNull = 0,
24  CalMorphTargetTypeAdditive,
25  CalMorphTargetTypeClamped,
26  CalMorphTargetTypeAverage,
27  CalMorphTargetTypeExclusive
28 };
29 
30 
31 class CAL3D_API CalCoreSubmesh
32 {
33 public:
35  {
36  float u, v;
37  };
38 
39  struct TangentSpace
40  {
41  CalVector tangent;
42  float crossFactor; // To get the binormal, use ((N x T) * crossFactor)
43  };
44 
45  struct Influence
46  {
47  int boneId;
48  float weight;
49  };
50 
52  {
53  float weight;
54  };
55 
56  struct Vertex
57  {
58  CalVector position;
59  CalVector normal;
60  std::vector<Influence> vectorInfluence;
61  int collapseId;
62  int faceCollapseCount;
63  CalVector vertexColor;
64  };
65 
66  struct Face
67  {
68  CalIndex vertexId[3];
69  };
70 
72  struct Spring
73  {
74  int vertexId[2];
75  float springCoefficient;
76  float idleLength;
77  };
78 
79 public:
81  ~CalCoreSubmesh();
82 
83  int getCoreMaterialThreadId() const;
84  int getFaceCount() const;
85  typedef std::vector<CalCoreSubMorphTarget *> CoreSubMorphTargetVector;
86  typedef std::vector<Face> VectorFace;
87  typedef std::vector<PhysicalProperty> VectorPhysicalProperty;
88  typedef std::vector<Spring> VectorSpring;
89  typedef std::vector<TangentSpace> VectorTangentSpace;
90  typedef std::vector<TextureCoordinate> VectorTextureCoordinate;
91  typedef std::vector<VectorTangentSpace > VectorVectorTangentSpace;
92  typedef std::vector<VectorTextureCoordinate > VectorVectorTextureCoordinate;
93  typedef std::vector<Vertex> VectorVertex;
94  typedef std::vector<Influence> VectorInfluence;
95  unsigned int size();
96  unsigned int sizeWithoutSubMorphTargets();
97  int getLodCount() const;
98  int getSpringCount() const;
99  bool hasNonWhiteVertexColors() { return m_hasNonWhiteVertexColors; }
100  std::vector<Face>& getVectorFace();
101  const std::vector<Face>& getVectorFace() const;
102  std::vector<PhysicalProperty>& getVectorPhysicalProperty();
103  const std::vector<PhysicalProperty>& getVectorPhysicalProperty() const;
104  std::vector<Spring>& getVectorSpring();
105  const std::vector<Spring>& getVectorSpring() const;
106  std::vector<std::vector<TangentSpace> >& getVectorVectorTangentSpace();
107  const std::vector<std::vector<TangentSpace> >& getVectorVectorTangentSpace() const;
108  std::vector<std::vector<TextureCoordinate> >& getVectorVectorTextureCoordinate();
109  const std::vector<std::vector<TextureCoordinate> >& getVectorVectorTextureCoordinate() const;
110  std::vector<Vertex>& getVectorVertex();
111  const std::vector<Vertex>& getVectorVertex() const;
112  int getVertexCount() const;
113  bool isTangentsEnabled(int mapId) const;
114  bool enableTangents(int mapId, bool enabled);
115  bool reserve(int vertexCount, int textureCoordinateCount, int faceCount, int springCount);
116  void setCoreMaterialThreadId(int coreMaterialThreadId);
117  bool setFace(int faceId, const Face& face);
118  void setLodCount(int lodCount);
119  bool setPhysicalProperty(int vertexId, const PhysicalProperty& physicalProperty);
120  bool setSpring(int springId, const Spring& spring);
121  bool setTangentSpace(int vertexId, int textureCoordinateId, const CalVector& tangent, float crossFactor);
122  bool setTextureCoordinate(int vertexId, int textureCoordinateId, const TextureCoordinate& textureCoordinate);
123  bool setVertex(int vertexId, const Vertex& vertex);
124  void setHasNonWhiteVertexColors( bool p ) { m_hasNonWhiteVertexColors = p; }
125  int addCoreSubMorphTarget(CalCoreSubMorphTarget *pCoreSubMorphTarget);
126  CalCoreSubMorphTarget *getCoreSubMorphTarget(int id);
127  const CalCoreSubMorphTarget *getCoreSubMorphTarget(int id) const;
128  int getCoreSubMorphTargetCount() const;
129  std::vector<CalCoreSubMorphTarget *>& getVectorCoreSubMorphTarget();
130  const std::vector<CalCoreSubMorphTarget *>& getVectorCoreSubMorphTarget() const;
131  void scale(float factor);
132  void setSubMorphTargetGroupIndexArray( unsigned int len, unsigned int const * indexArray );
133  inline unsigned int subMorphTargetGroupIndex( int subMorphTargetId ) {
134  if( size_t(subMorphTargetId) >= m_vectorSubMorphTargetGroupIndex.size() ) return 0xffffffff;
135  return m_vectorSubMorphTargetGroupIndex[ subMorphTargetId ]; }
136 
137 private:
138  void UpdateTangentVector(int v0, int v1, int v2, int channel);
139 
140  std::vector<Vertex> m_vectorVertex;
141  std::vector<bool> m_vectorTangentsEnabled;
142  std::vector<std::vector<TangentSpace> > m_vectorvectorTangentSpace;
143  std::vector<std::vector<TextureCoordinate> > m_vectorvectorTextureCoordinate;
144  std::vector<PhysicalProperty> m_vectorPhysicalProperty;
145  std::vector<Face> m_vectorFace;
146  std::vector<Spring> m_vectorSpring;
147  std::vector<CalCoreSubMorphTarget *> m_vectorCoreSubMorphTarget;
148  int m_coreMaterialThreadId;
149  int m_lodCount;
150  std::vector<unsigned int> m_vectorSubMorphTargetGroupIndex;
151  bool m_hasNonWhiteVertexColors;
152 };
153 
154 #endif
155 
156 //****************************************************************************//
The core submesh Spring.
Definition: coresubmesh.h:72
Definition: coresubmesh.h:34
Definition: coresubmesh.h:51
Definition: coresubmesh.h:66
Definition: coresubmesh.h:56
Definition: coresubmorphtarget.h:21
The vector class.
Definition: vector.h:36
Definition: coresubmesh.h:31
Definition: coresubmesh.h:45
Definition: coresubmesh.h:39

Generated by The Cal3D Team with Doxygen 1.8.14