mesh_morpher.h

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

Generated on Thu Jan 7 08:26:18 2010 for NeL by  doxygen 1.6.1