animation/animation.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004-2005 by Reality Rift Studios                       *
00003  *   http://www.realityrift.com  -  mattias@realityrift.com                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef neo_animation_animation_h
00022 #define neo_animation_animation_h
00023 
00029 #include "../core/platform.h"
00030 
00031 #if NEO_ENABLE_ANIMATION
00032 
00033 #include "../core/pointer.h"
00034 #include "../core/array.h"
00035 #include "../core/hashstring.h"
00036 #include "../core/resource.h"
00037 #include "../math/core.h"
00038 
00039 namespace neo {
00040 namespace animation {
00041 
00042 class Channel;
00043 class Keyframe;
00044 
00046 
00048 class Animation : public core::RefCount, public core::Resource
00049 {
00050     public:
00051 
00053 
00054                                                             Animation( const std::string& name );
00055 
00057     virtual                                                ~Animation();
00058 
00060     float                                                   _length;
00061 
00063     core::HashTable< std::string, Channel* >                _channels;
00064 };
00065 
00066 NEO_DECLARE_SMARTPOINTER( Animation )
00067 
00068 
00069 
00071 class AnimationInstance
00072 {
00073     public:
00074 
00076 
00078                                                             AnimationInstance( const AnimationPtr& p_anim );
00079 
00081 
00082                                                             AnimationInstance( const AnimationInstance& instance );
00083     
00085     virtual                                                ~AnimationInstance();
00086 
00088 
00090     void                                                    update( float dt );
00091 
00093 
00095     void                                                    interpolate( core::HashTable< std::string, Keyframe* >& dest );
00096 
00098 
00101     void                                                    blend( core::HashTable< std::string, Keyframe* >& dest, float weight );
00102 
00104 
00106     void                                                    setAnimation( const AnimationPtr& p_anim );
00107 
00109 
00111     inline const AnimationPtr&                              getAnimation() const;
00112 
00114 
00116     inline void                                             reset( float time = 0.0f );
00117 
00119 
00121     inline void                                             play( bool play = true );
00122 
00124 
00126     inline void                                             loop( bool loop = true );
00127 
00129 
00131     inline float                                            getCurrentTime() const;
00132 
00134 
00135     inline bool                                             isLooping() const;
00136 
00138 
00139     inline bool                                             isPlaying() const;
00140     
00142 
00143     inline bool                                             isLooped() const;
00144     
00145     protected:
00146 
00148     AnimationPtr                                            _p_animation;
00149 
00151     core::Array< unsigned int >                             _keyframeIndex;
00152 
00154     float                                                   _time;
00155 
00157     float                                                   _timeNorm;
00158 
00160     bool                                                    _loop;
00161 
00163     bool                                                    _play;
00164     
00166     bool                                                    _looped;
00167 };
00168 
00169 #include "animation.inl"
00170 
00171 }
00172 }
00173 
00174 #endif
00175 
00176 #endif

Generated on Sat Feb 17 20:50:47 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1