00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_LOD_CHARACTER_SHAPE_H
00027 #define NL_LOD_CHARACTER_SHAPE_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/common.h"
00031 #include "3d/mesh.h"
00032
00033
00034 namespace NL3D
00035 {
00036
00037
00038
00046 class CLodCharacterShapeBuild
00047 {
00048 public:
00049
00050 std::vector<CVector> Vertices;
00051
00052
00053 std::vector<CMesh::CSkinWeight> SkinWeights;
00054
00055
00056 std::vector<std::string> BonesNames;
00057
00058
00059 std::vector<uint32> TriangleIndices;
00060
00061
00062 void serial(NLMISC::IStream &f);
00063
00064 };
00065
00066
00067
00074 class CLodCharacterShape
00075 {
00076 public:
00077
00079 struct CAnimBuild
00080 {
00082 std::string Name;
00084 uint NumKeys;
00086 float AnimLength;
00087
00089 std::vector<CVector> Keys;
00090 };
00091
00093 struct CVector3s
00094 {
00095 sint16 x,y,z;
00096
00097 void serial(NLMISC::IStream &f)
00098 {
00099 f.serial(x,y,z);
00100 }
00101 };
00102
00103 public:
00104
00106 CLodCharacterShape();
00107
00111 void buildMesh(const std::string &name, const CLodCharacterShapeBuild &lodBuild);
00112
00116 bool addAnim(const CAnimBuild &animBuild);
00117
00119 void serial(NLMISC::IStream &f);
00120
00122 const std::string & getName() const {return _Name;}
00123
00125 sint getAnimIdByName(const std::string &name) const;
00126
00128 uint getNumVertices() const {return _NumVertices;}
00129
00131 uint getNumTriangles() const {return _NumTriangles;}
00132
00134 uint getNumBones() const {return _Bones.size();}
00135
00137 sint getBoneIdByName(const std::string &name) const;
00138
00140 const uint32 *getTriangleArray() const;
00141
00143
00144
00146 void startBoneColor(std::vector<NLMISC::CRGBAF> &tmpColors) const;
00147
00149 void addBoneColor(uint boneId, CRGBA color, std::vector<NLMISC::CRGBAF> &tmpColors) const;
00150
00156 void endBoneColor(const std::vector<NLMISC::CRGBAF> &tmpColors, std::vector<NLMISC::CRGBA> &dstColors) const;
00157
00158
00159
00165 const CVector3s *getAnimKey(uint animId, TGlobalAnimationTime time, bool wrapMode, CVector &unPackScaleFactor) const;
00166
00167
00168
00169 private:
00170
00172 struct CAnim
00173 {
00175 std::string Name;
00177 uint32 NumKeys;
00179 float AnimLength;
00180 float OOAnimLength;
00182 CVector UnPackScaleFactor;
00183
00185 std::vector<CVector3s> Keys;
00186
00187 void serial(NLMISC::IStream &f);
00188 };
00189
00190 struct CVertexInf
00191 {
00192
00193 uint32 VertexId;
00194
00195 float Influence;
00196
00197 void serial(NLMISC::IStream &f)
00198 {
00199 f.serial(VertexId);
00200 f.serial(Influence);
00201 }
00202 };
00203
00205 struct CBoneInfluence
00206 {
00207
00208 std::string Name;
00209
00210
00211 std::vector<CVertexInf> InfVertices;
00212
00213 void serial(NLMISC::IStream &f);
00214 };
00215
00217 typedef std::map<std::string, uint32> TStrIdMap;
00218 typedef TStrIdMap::iterator ItStrIdMap;
00219 typedef TStrIdMap::const_iterator CstItStrIdMap;
00220
00221 private:
00222 std::string _Name;
00223 uint32 _NumVertices;
00224 uint32 _NumTriangles;
00226 std::vector<CBoneInfluence> _Bones;
00227
00228
00229 TStrIdMap _BoneMap;
00230
00232 std::vector<uint32> _TriangleIndices;
00233
00235 std::vector<CAnim> _Anims;
00236
00237
00238 TStrIdMap _AnimMap;
00239
00240 };
00241
00242
00243 }
00244
00245
00246 #endif // NL_LOD_CHARACTER_SHAPE_H
00247
00248