- Cal3D 0.11 API Reference -

coresubmorphtarget.h
1 //****************************************************************************//
2 // coresubmorphtarget.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_CORESUBMORPHTARGET_H
12 #define CAL_CORESUBMORPHTARGET_H
13 
14 
15 #include "cal3d/global.h"
16 #include "cal3d/vector.h"
17 #include "cal3d/refcounted.h"
18 #include "cal3d/refptr.h"
19 #include "cal3d/coresubmesh.h"
20 
21 class CAL3D_API CalCoreSubMorphTarget
22 {
23 public:
24  struct BlendVertex
25  {
26  CalVector position;
27  CalVector normal;
28  std::vector<CalCoreSubmesh::TextureCoordinate> textureCoords;
29  bool create() { return true; }
30  bool destroy() { return true; }
31  };
32 
33 public:
35  virtual ~CalCoreSubMorphTarget() { }
36 
37  virtual void setCoreSubmesh( CalCoreSubmesh *inCoreSubmesh );
38  const CalCoreSubmesh *getCoreSubmesh() const;
39 
40  int getBlendVertexCount() const;
41  unsigned int size();
42  typedef std::vector<BlendVertex *> VectorBlendVertex;
43 
44  std::vector<BlendVertex *>& getVectorBlendVertex();
45  inline bool hasBlendVertex( int blendVertexId ) {
46  return m_vectorBlendVertex[blendVertexId] != NULL;
47  }
48  inline BlendVertex const * getBlendVertex( int blendVertexId ) {
49  return m_vectorBlendVertex[blendVertexId];
50  }
51 
52  inline const BlendVertex* getBlendVertex( int blendVertexId ) const {
53  return m_vectorBlendVertex[blendVertexId];
54  }
55 
56  const std::vector<BlendVertex*>& getVectorBlendVertex() const;
57  virtual bool reserve(int blendVertexCount);
58  bool setBlendVertex(int vertexId, const BlendVertex& vertex);
59 
60  void getBlendVertex( int vertexId, BlendVertex& outVertex ) const;
61  CalMorphTargetType morphTargetType() const;
62 
63  void setName( std::string );
64  std::string name() const;
65 
66 private:
67  CalCoreSubMorphTarget( const CalCoreSubMorphTarget& inOther ); // unimp
68 
69  std::vector<BlendVertex*> m_vectorBlendVertex;
70  CalCoreSubmesh *m_coreSubmesh;
71  std::string m_morphTargetName;
72  CalMorphTargetType m_morphTargetType;
73 };
74 
75 // The difference map is reference counted because we can use the same difference
76 // map on multiple actor heads.
78 {
79 public:
80  CalSharedDifferenceMap() : m_NextIndex(0),
81  m_vectorVertexIndexSize(0),
82  m_vectorVertexIndexPtr(0),
83  m_vectorBlendVertexPtr(0) { }
84 
85  bool reserve(int blendVertexCount);
86  bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex& vertex);
87 
88  bool getBlendVertex( int vertexId, CalCoreSubMorphTarget::BlendVertex& outVertex ) const;
89 
90 protected:
92 
93 private:
94  std::vector<CalCoreSubMorphTarget::BlendVertex> m_vectorBlendVertex;
95  std::vector<int> m_vectorVertexIndex;
96  mutable int m_NextIndex;
97 
98  // performance optimization: direct access to vector size and arrays
99  mutable int m_vectorVertexIndexSize;
100  mutable const int *m_vectorVertexIndexPtr;
101  mutable const CalCoreSubMorphTarget::BlendVertex *m_vectorBlendVertexPtr;
102 };
104 
105 
107 {
108 public:
112 
113  virtual bool reserve(int blendVertexCount);
114  virtual void setCoreSubmesh( CalCoreSubmesh* inCoreSubmesh );
115 
116  bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex& vertex);
117 
118 private:
119  CalSharedDifferenceMapPtr m_diffMap;
120 };
121 
122 #endif
123 //****************************************************************************//
virtual void setCoreSubmesh(CalCoreSubmesh *inCoreSubmesh)
Record the core submesh that this morph applies to.
Definition: coresubmorphtarget.cpp:363
Definition: coresubmorphtarget.h:24
bool reserve(int blendVertexCount)
Reserves memory for the blend vertices.
Definition: coresubmorphtarget.cpp:219
bool getBlendVertex(int vertexId, CalCoreSubMorphTarget::BlendVertex &outVertex) const
Retrieve one blend vertex.
Definition: coresubmorphtarget.cpp:281
Definition: coresubmorphtarget.h:106
virtual bool reserve(int blendVertexCount)
Reserves memory for the blend vertices.
Definition: coresubmorphtarget.cpp:347
bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex &vertex)
Record one blend vertex.
Definition: coresubmorphtarget.cpp:402
bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex &vertex)
Record one blend vertex.
Definition: coresubmorphtarget.cpp:249
Definition: coresubmorphtarget.h:77
Definition: coresubmorphtarget.h:21
The vector class.
Definition: vector.h:36
Definition: coresubmesh.h:31
Derive from RefCounted to make your class have reference-counted lifetime semantics.
Definition: refcounted.h:28

Generated by The Cal3D Team with Doxygen 1.8.14