channel.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004-2007 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_channel_h
00022 #define neo_animation_channel_h
00023 
00029 #include "../core/platform.h"
00030 
00031 #if NEO_ENABLE_ANIMATION
00032 
00033 #include "../core/hashstring.h"
00034 #include "keyframe.h"
00035 
00036 namespace neo {
00037 namespace animation {
00038 
00040 
00042 class Channel
00043 {
00044     public:
00045 
00047 
00048                                                             Channel( const std::string& name );
00049     
00051     virtual                                                ~Channel();
00052 
00054 
00058     virtual unsigned int                                    getKeyframeIndex( float time, unsigned int last = 0 ) = 0;
00059 
00061 
00065     virtual void                                            interpolate( Keyframe* p_dst, float time, unsigned int lastKeyframe ) = 0;
00066 
00068 
00074     virtual void                                            blend( Keyframe* p_dst, float weight, float time, unsigned int lastKeyframe ) = 0;
00075 
00077 
00079     virtual Keyframe*                                       allocateKeyframe() const = 0;
00080 
00082 
00084     virtual void                                            setNumKeyframes( unsigned int num ) = 0;
00085     
00087 
00088     virtual unsigned int                                    getNumKeyframes() const = 0;
00089     
00091 
00092     inline const core::HashString&                          getName() const;
00093     
00094     protected:
00095     
00097     core::HashString                                        _name;
00098 };
00099 
00105 class TransformChannel : public Channel
00106 {
00107     public:
00108     
00110 
00111                                                             TransformChannel( const std::string& name );
00112 
00113     virtual                                                ~TransformChannel();
00114     virtual unsigned int                                    getKeyframeIndex( float time, unsigned int last );
00115     virtual void                                            interpolate( Keyframe* p_dst, float time, unsigned int lastKeyframe );
00116     virtual void                                            blend( Keyframe* p_dst, float weight, float time, unsigned int lastKeyframe );
00117     virtual Keyframe*                                       allocateKeyframe() const;
00118     virtual void                                            setNumKeyframes( unsigned int num );
00119     virtual unsigned int                                    getNumKeyframes() const;
00120 
00122 
00124     inline const core::Array< TransformKeyframe >&          getKeyframes() const;
00125 
00127 
00130     inline TransformKeyframe*                               getKeyframe( unsigned int keyframe );
00131     
00132     protected:
00133     
00135     core::Array< TransformKeyframe >                        _keyframes;
00136 };
00137 
00143 class VectorChannel : public Channel
00144 {
00145     public:
00146     
00148 
00150                                                             VectorChannel( const std::string& name, unsigned int num = 3 );
00151     
00152     virtual                                                ~VectorChannel();
00153     virtual unsigned int                                    getKeyframeIndex( float time, unsigned int last );
00154     virtual void                                            interpolate( Keyframe* p_dst, float time, unsigned int lastKeyframe );
00155     virtual void                                            blend( Keyframe* p_dst, float weight, float time, unsigned int lastKeyframe );
00156     virtual Keyframe*                                       allocateKeyframe() const;
00157     virtual void                                            setNumKeyframes( unsigned int num );
00158     virtual unsigned int                                    getNumKeyframes() const;
00159     
00161 
00162     void                                                    setNumValues( unsigned int num );
00163     
00165 
00166     inline unsigned int                                     getNumValues() const;
00167 
00169 
00171     inline const core::Array< VectorKeyframe >&             getKeyframes() const;
00172     
00174 
00177     inline VectorKeyframe*                                  getKeyframe( unsigned int keyframe );
00178     
00179     protected:
00180         
00182     unsigned int                                            _numValues;
00183         
00185     core::Array< VectorKeyframe >                           _keyframes;
00186 };
00187 
00188 #include "channel.inl"
00189 
00190 }
00191 }
00192 
00193 #endif
00194 
00195 #endif

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