- 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:friend class CalCoreSubmesh;
24  struct BlendVertex
25  {
26  CalVector position;
27  CalVector normal;
28  std::vector<CalCoreSubmesh::TextureCoordinate> textureCoords;
29  };
30 public:
32  virtual ~CalCoreSubMorphTarget() { }
33  virtual void setCoreSubmesh( CalCoreSubmesh *inCoreSubmesh );
34  const CalCoreSubmesh *getCoreSubmesh() const;
35 
36  int getBlendVertexCount() const;
37  unsigned int size();
38 
39  inline std::vector<BlendVertex>& getVectorBlendVertex(){ return m_vectorBlendVertex;}
40  inline const std::vector<BlendVertex>& getVectorBlendVertex() const{ return m_vectorBlendVertex;}
41 
42  inline BlendVertex const * getBlendVertex(int blendVertexId){ return &m_vectorBlendVertex[blendVertexId];}
43  inline const BlendVertex* getBlendVertex(int blendVertexId) const{ return &m_vectorBlendVertex[blendVertexId];}
44 
45  virtual bool reserve(int blendVertexCount);
46 
47  bool setBlendVertex(int vertexId, const BlendVertex& vertex);
48  void getBlendVertex( int vertexId, BlendVertex& outVertex ) const;
49 
51  inline CalMorphTargetType getMorphTargetType() const { return m_morphTargetType;}
52  inline void setMorphTargetType(CalMorphTargetType c) { m_morphTargetType=c;}
53 
55  inline const unsigned int& getMorphID() const{return m_morphTargetID;}
56 
58  void setName(const std::string &s){_name=s;}
59  const std::string& getName() const{return _name;}
60 protected:
61  inline void setMorphID(const unsigned int &i){m_morphTargetID=i;}
62 private:
63  std::string _name;
64  CalCoreSubMorphTarget( const CalCoreSubMorphTarget& inOther ); // unimp
65 
66  std::vector<BlendVertex> m_vectorBlendVertex;
67  CalCoreSubmesh *m_coreSubmesh;
68  unsigned int m_morphTargetID;
69  CalMorphTargetType m_morphTargetType;
70 };
71 
72 // The difference map is reference counted because we can use the same difference
73 // map on multiple actor heads.
75 {
76 public:
77  CalSharedDifferenceMap() : m_NextIndex(0),
78  m_vectorVertexIndexSize(0),
79  m_vectorVertexIndexPtr(0),
80  m_vectorBlendVertexPtr(0) { }
81 
82  bool reserve(int blendVertexCount);
83  bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex& vertex);
84 
85  bool getBlendVertex( int vertexId, CalCoreSubMorphTarget::BlendVertex& outVertex ) const;
86 
87 protected:
89 
90 private:
91  std::vector<CalCoreSubMorphTarget::BlendVertex> m_vectorBlendVertex;
92  std::vector<int> m_vectorVertexIndex;
93  mutable int m_NextIndex;
94 
95  // performance optimization: direct access to vector size and arrays
96  mutable int m_vectorVertexIndexSize;
97  mutable const int *m_vectorVertexIndexPtr;
98  mutable const CalCoreSubMorphTarget::BlendVertex *m_vectorBlendVertexPtr;
99 };
101 
102 
104 {
105 public:
109 
110  virtual bool reserve(int blendVertexCount);
111  virtual void setCoreSubmesh( CalCoreSubmesh* inCoreSubmesh );
112 
113  bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex& vertex);
114 
115 private:
116  CalSharedDifferenceMapPtr m_diffMap;
117 };
118 
119 #endif
120 //****************************************************************************//
virtual void setCoreSubmesh(CalCoreSubmesh *inCoreSubmesh)
Record the core submesh that this morph applies to.
Definition: coresubmorphtarget.cpp:328
Definition: coresubmorphtarget.h:24
void setName(const std::string &s)
Name property (just for convenience )
Definition: coresubmorphtarget.h:58
bool reserve(int blendVertexCount)
Reserves memory for the blend vertices.
Definition: coresubmorphtarget.cpp:184
bool getBlendVertex(int vertexId, CalCoreSubMorphTarget::BlendVertex &outVertex) const
Retrieve one blend vertex.
Definition: coresubmorphtarget.cpp:246
Definition: coresubmorphtarget.h:103
virtual bool reserve(int blendVertexCount)
Reserves memory for the blend vertices.
Definition: coresubmorphtarget.cpp:312
bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex &vertex)
Record one blend vertex.
Definition: coresubmorphtarget.cpp:367
bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex &vertex)
Record one blend vertex.
Definition: coresubmorphtarget.cpp:214
const unsigned int & getMorphID() const
Index of this morph for its target mesh.
Definition: coresubmorphtarget.h:55
Definition: coresubmorphtarget.h:74
Definition: coresubmorphtarget.h:21
The vector class.
Definition: vector.h:36
Definition: coresubmesh.h:31
CalMorphTargetType getMorphTargetType() const
Type of this morph.
Definition: coresubmorphtarget.h:51
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