# 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  

animation_set.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_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                 // Look for an id with this name
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                 // Look for an id with this name
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                 // Look for an id with this name
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 } // NL3D
00234 
00235 
00236 #endif // NL_ANIMATION_SET_H
00237 
00238 /* End of animation_set.h */