# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

mesh_morpher.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_MESH_MORPHER_H
00027 #define NL_MESH_MORPHER_H
00028 
00029 #include "3d/animated_morph.h"
00030 #include "nel/misc/types_nl.h"
00031 #include "nel/misc/uv.h"
00032 #include <vector>
00033 
00034 namespace NL3D 
00035 {
00036 
00037 class CVertexBuffer;
00038 class IVertexBufferHard;
00039 
00040 // ***************************************************************************
00041 class CBlendShape
00042 {
00043 public:
00044         std::string                     Name;
00045 
00046         std::vector<NLMISC::CVector>    deltaPos;
00047         std::vector<NLMISC::CVector>    deltaNorm;
00048         std::vector<NLMISC::CVector>    deltaTgSpace;
00049         std::vector<NLMISC::CUV>                deltaUV;
00050         std::vector<NLMISC::CRGBAF>             deltaCol;
00051 
00052         std::vector<uint32>     VertRefs;       // Array of vertices reference
00053 
00054         void serial (NLMISC::IStream &f) throw(NLMISC::EStream);
00055 };
00056 
00057 // ***************************************************************************
00064 class CMeshMorpher
00065 {
00066         typedef enum
00067         {
00068                 OriginalAll=0,          // The vertex is the same as original into VBDst and VBHard
00069                 OriginalVBDst,          // The vertex is the same as original into VBDst
00070                 Modified,                       // Vertex modified
00071         } TState;
00072 
00073 public:
00074 
00075         std::vector<CBlendShape>                        BlendShapes;
00076 
00077         CMeshMorpher();
00078         // The allocation of the buffers must be managed by the caller
00079         void init (CVertexBuffer *vbOri, CVertexBuffer *vbDst, IVertexBufferHard *vbDstHrd, bool hasTgSpace);
00080         void initSkinned (CVertexBuffer *vbOri,
00081                                   CVertexBuffer *vbDst,
00082                                   IVertexBufferHard *vbDstHrd,
00083                                   bool hasTgSpace,
00084                                   std::vector<CVector> *vVertices,
00085                                   std::vector<CVector> *vNormals,
00086                                   std::vector<CVector> *vTgSpace, /* NULL if none */
00087                                   bool bSkinApplied);
00088 
00089         void update (std::vector<CAnimatedMorph> *pBSFactor);
00090         void updateSkinned (std::vector<CAnimatedMorph> *pBSFactor);
00091         
00092         void serial (NLMISC::IStream &f) throw(NLMISC::EStream);
00093 
00094 private:
00095 
00096         CVertexBuffer                   *_VBOri;
00097         CVertexBuffer                   *_VBDst;
00098         IVertexBufferHard               *_VBDstHrd;
00099 
00100         std::vector<CVector>    *_Vertices;
00101         std::vector<CVector>    *_Normals;
00102         std::vector<CVector>    *_TgSpace;
00103 
00104 
00105         bool                                    _SkinApplied : 1;
00106         bool                                    _UseTgSpace  : 1;
00107 
00108         std::vector<uint8>      _Flags; // 0 - OriginalAll  (vbDst & vbDstHrd original)
00109                                                                 // 1 - OriginalVBDst  (vbDst original)
00110                                                                 // 2 - Modified
00111 };
00112 
00113 } // NL3D
00114 
00115 
00116 #endif // NL_MESH_MORPHER_H
00117             
00118 /* End of mesh_morpher.h */