- Cal3D 0.11 API Reference -

coresubmorphtarget.h

00001 //****************************************************************************//
00002 // coresubmorphtarget.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_CORESUBMORPHTARGET_H
00012 #define CAL_CORESUBMORPHTARGET_H
00013 
00014 
00015 #include "cal3d/global.h"
00016 #include "cal3d/vector.h"
00017 #include "cal3d/refcounted.h"
00018 #include "cal3d/refptr.h"
00019 #include "cal3d/coresubmesh.h"
00020 
00021 class CAL3D_API CalCoreSubMorphTarget
00022 {
00023 public:
00024   struct BlendVertex
00025   {
00026     CalVector position;
00027     CalVector normal;
00028     std::vector<CalCoreSubmesh::TextureCoordinate> textureCoords;
00029     bool create() { return true; }
00030     bool destroy() { return true; }
00031   };
00032   
00033 public:
00034   CalCoreSubMorphTarget();
00035   virtual ~CalCoreSubMorphTarget() { }
00036   
00037   virtual void setCoreSubmesh( CalCoreSubmesh *inCoreSubmesh );
00038   const CalCoreSubmesh *getCoreSubmesh() const;
00039 
00040   int getBlendVertexCount() const;
00041   unsigned int size();
00042   typedef std::vector<BlendVertex *> VectorBlendVertex;
00043 
00044   std::vector<BlendVertex *>& getVectorBlendVertex();
00045   inline bool hasBlendVertex( int blendVertexId ) {
00046     return m_vectorBlendVertex[blendVertexId] != NULL;
00047   }
00048   inline BlendVertex const * getBlendVertex( int blendVertexId ) {
00049     return m_vectorBlendVertex[blendVertexId];
00050   }
00051 
00052   inline const BlendVertex* getBlendVertex( int blendVertexId ) const {
00053      return m_vectorBlendVertex[blendVertexId];
00054   }
00055 
00056   const std::vector<BlendVertex*>& getVectorBlendVertex() const;
00057   virtual bool reserve(int blendVertexCount);
00058   bool setBlendVertex(int vertexId, const BlendVertex& vertex);
00059 
00060   void  getBlendVertex( int vertexId, BlendVertex& outVertex ) const;
00061   CalMorphTargetType morphTargetType() const;
00062 
00063   void setName( std::string );
00064   std::string name() const;
00065 
00066 private:
00067   CalCoreSubMorphTarget( const CalCoreSubMorphTarget& inOther );    // unimp
00068 
00069   std::vector<BlendVertex*>  m_vectorBlendVertex;
00070   CalCoreSubmesh           *m_coreSubmesh;
00071   std::string               m_morphTargetName;
00072   CalMorphTargetType        m_morphTargetType;
00073 };
00074 
00075 // The difference map is reference counted because we can use the same difference
00076 // map on multiple actor heads.
00077 class CalSharedDifferenceMap : public cal3d::RefCounted
00078 {
00079 public:
00080             CalSharedDifferenceMap() : m_NextIndex(0),
00081                     m_vectorVertexIndexSize(0),
00082                     m_vectorVertexIndexPtr(0),
00083                     m_vectorBlendVertexPtr(0) { }
00084 
00085   bool reserve(int blendVertexCount);
00086   bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex& vertex);
00087   
00088   bool  getBlendVertex( int vertexId, CalCoreSubMorphTarget::BlendVertex& outVertex ) const;
00089 
00090 protected:
00091             ~CalSharedDifferenceMap() { }
00092 
00093 private:
00094   std::vector<CalCoreSubMorphTarget::BlendVertex>   m_vectorBlendVertex;
00095   std::vector<int>                                  m_vectorVertexIndex;
00096   mutable   int                                       m_NextIndex;
00097 
00098   // performance optimization: direct access to vector size and arrays
00099   mutable int                                       m_vectorVertexIndexSize;
00100   mutable const int                                *m_vectorVertexIndexPtr;
00101   mutable const CalCoreSubMorphTarget::BlendVertex *m_vectorBlendVertexPtr;
00102 };
00103 typedef cal3d::RefPtr<CalSharedDifferenceMap> CalSharedDifferenceMapPtr;
00104 
00105 
00106 class CalCoreSubMorphTargetDiffMap : public CalCoreSubMorphTarget
00107 {
00108 public:
00109             CalCoreSubMorphTargetDiffMap();
00110             CalCoreSubMorphTargetDiffMap( const CalCoreSubMorphTargetDiffMap& inOther );
00111             ~CalCoreSubMorphTargetDiffMap() { }
00112 
00113     virtual bool reserve(int blendVertexCount);
00114     virtual void    setCoreSubmesh( CalCoreSubmesh* inCoreSubmesh );
00115 
00116     bool appendBlendVertex(int vertexId, const CalCoreSubMorphTarget::BlendVertex& vertex);
00117 
00118 private:
00119     CalSharedDifferenceMapPtr   m_diffMap;
00120 };
00121 
00122 #endif
00123 //****************************************************************************//

Generated by The Cal3D Team with Doxygen 1.7.3