00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_ANIMATION_SET_H
00027 #define NL_ANIMATION_SET_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/animation.h"
00031 #include "3d/skeleton_weight.h"
00032 #include "nel/misc/smart_ptr.h"
00033 #include <map>
00034 #include <string>
00035 #include <vector>
00036
00037 namespace NLMISC
00038 {
00039 class IStream;
00040 struct EStream;
00041 }
00042
00043 namespace NL3D {
00044
00045
00054 class CAnimationSet : public NLMISC::CRefCount
00055 {
00056 public:
00057
00058 enum { NotFound=0xffffffff };
00059
00060 ~CAnimationSet ();
00061
00065 uint getNumChannelId () const;
00066
00070 uint getChannelIdByName (const std::string& name) const
00071 {
00072
00073 std::map <std::string, uint32>::const_iterator ite=_ChannelIdByName.find (name);
00074 if (ite!=_ChannelIdByName.end ())
00075 return ite->second;
00076 else
00077 return NotFound;
00078 }
00079
00083 uint getAnimationIdByName (const std::string& name) const
00084 {
00085
00086 std::map <std::string, uint32>::const_iterator ite=_AnimationIdByName.find (name);
00087 if (ite!=_AnimationIdByName.end ())
00088 return ite->second;
00089 else
00090 return NotFound;
00091 }
00092
00096 uint getNumAnimation () const
00097 {
00098 return _Animation.size();
00099 }
00100
00104 const std::string& getAnimationName (uint animationId) const
00105 {
00106 return _AnimationName[animationId];
00107 }
00108
00112 const CAnimation* getAnimation (uint animationId) const
00113 {
00114 return _Animation[animationId];
00115 }
00116
00120 CAnimation* getAnimation (uint animationId)
00121 {
00122 return _Animation[animationId];
00123 }
00124
00128 uint getNumSkeletonWeight () const
00129 {
00130 return _SkeletonWeight.size();
00131 }
00132
00136 uint getSkeletonWeightIdByName (const std::string& name) const
00137 {
00138
00139 std::map <std::string, uint32>::const_iterator ite=_SkeletonWeightIdByName.find (name);
00140 if (ite!=_SkeletonWeightIdByName.end ())
00141 return ite->second;
00142 else
00143 return NotFound;
00144 }
00145
00149 const std::string& getSkeletonWeightName (uint skeletonId) const
00150 {
00151 return _SkeletonWeightName[skeletonId];
00152 }
00153
00157 const CSkeletonWeight* getSkeletonWeight (uint skeletonId) const
00158 {
00159 return _SkeletonWeight[skeletonId];
00160 }
00161
00165 CSkeletonWeight* getSkeletonWeight (uint skeletonId)
00166 {
00167 return _SkeletonWeight[skeletonId];
00168 }
00169
00178 uint addAnimation (const char* name, CAnimation* animation);
00179
00186 uint addSkeletonWeight (const char* name, CSkeletonWeight* skeletonWeight);
00187
00191 void reset ();
00192
00200 void build ();
00201
00203 void serial (NLMISC::IStream& f);
00204
00214 bool loadFromFiles
00215 (
00216 const std::string &path,
00217 bool recurse = true,
00218 const char *ext = "anim",
00219 bool wantWarningMessage = true
00220 );
00221
00222 private:
00223 std::vector <CAnimation*> _Animation;
00224 std::vector <CSkeletonWeight*> _SkeletonWeight;
00225 std::vector <std::string> _AnimationName;
00226 std::vector <std::string> _SkeletonWeightName;
00227 std::map <std::string, uint32> _ChannelIdByName;
00228 std::map <std::string, uint32> _AnimationIdByName;
00229 std::map <std::string, uint32> _SkeletonWeightIdByName;
00230 };
00231
00232
00233 }
00234
00235
00236 #endif // NL_ANIMATION_SET_H
00237
00238