# 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.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_H
00027 #define NL_ANIMATION_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 
00031 #include "nel/3d/animation_time.h"
00032 #include "nel/3d/u_animation.h"
00033 
00034 #include <memory>
00035 #include <map>
00036 #include <set>
00037 #include <vector>
00038 
00039 namespace NLMISC
00040 {
00041 class IStream;
00042 struct EStream;
00043 }
00044 
00045 #define NL3D_MEM_ANIMATION                                              NL_ALLOC_CONTEXT( 3dAnim )
00046 
00047 namespace NL3D 
00048 {
00049 
00050 class ITrack;
00051 
00060 class CAnimation : public UAnimation
00061 {
00062 public:
00064         CAnimation();
00066         virtual ~CAnimation ();
00067 
00069 
00070         enum { NotFound=0xffffffff };
00071 
00077         uint getIdTrackByName (const std::string& name) const
00078         {
00079                 NL3D_MEM_ANIMATION
00080                 // Find an entry in the name/id map
00081                 TMapStringUInt::const_iterator ite=_IdByName.find (name);
00082 
00083                 // Not found ?
00084                 if (ite==_IdByName.end ())
00085                         // yes, error
00086                         return NotFound;
00087                 else
00088                         // no, return track ID
00089                         return (uint)ite->second;
00090         }
00091 
00097         void getTrackNames (std::set<std::string>& setString) const;
00098 
00103         const ITrack* getTrack (uint trackId) const
00104         {
00105                 NL3D_MEM_ANIMATION
00106                 // Get the trackId-th track pointer
00107                 return _TrackVector[trackId];
00108         }
00109 
00114         ITrack* getTrack (uint trackId)
00115         {
00116                 NL3D_MEM_ANIMATION
00117                 // Get the trackId-th track pointer
00118                 return _TrackVector[trackId];
00119         }
00120 
00127         void addTrack (const std::string& name, ITrack* pChannel);
00128 
00130         void serial (NLMISC::IStream& f);
00131 
00133         void setMinEndTime (TAnimationTime minEndTime);
00134 
00136         // @{
00137 
00138         virtual UTrack*         getTrackByName (const char* name);
00139         virtual void            releaseTrack (UTrack* track);
00140         virtual TAnimationTime  getBeginTime () const;
00141         virtual TAnimationTime  getEndTime () const;
00142         virtual bool                    allTrackLoop() const;
00143 
00144         // @}
00145 
00146 
00147 private:
00149         typedef std::map<std::string, uint32> TMapStringUInt;
00150         typedef std::vector<ITrack* > TVectAPtrTrack;
00151 
00152         // Animation name
00153         std::string                     _Name;
00154 
00155         // Map to get a channel id with a name.
00156         TMapStringUInt          _IdByName;
00157 
00158         // Vector of channel pointer.
00159         TVectAPtrTrack          _TrackVector;
00160 
00161         // Force animation min end time
00162         TAnimationTime          _MinEndTime;
00163 
00165         // @{
00166                 mutable TAnimationTime          _BeginTime;     
00167                 mutable TAnimationTime          _EndTime;
00168                 mutable bool                            _AnimLoop;
00169                 mutable bool                            _BeginTimeTouched;
00170                 mutable bool                            _EndTimeTouched;
00171                 mutable bool                            _AnimLoopTouched;
00172         // @}
00173 };
00174 
00175 
00176 } // NL3D
00177 
00178 
00179 #endif // NL_ANIMATION_H
00180 
00181 /* End of animation.h */