Documentation


morphingEngine.h

Go to the documentation of this file.
00001 #ifndef MORPHING_ENGINE_H
00002 #define MORPHING_ENGINE_H
00003 
00004 #include <vector>
00005 
00006 #include "engine.h"
00007 #include <animal/vec3.h>
00008 
00009 namespace animal {
00010 
00027 template< class Morphings, class Real = float >
00028 class MorphingEngine : public Engine
00029 {
00030   protected:
00032     typedef typename Morphings::Key Key;
00033     typedef typename Morphings::Values Values;
00034   
00035   public:
00037     MorphingEngine();
00038 
00040     virtual ~MorphingEngine();
00041   
00042     //===============================================================
00045     
00047     virtual void reset();
00048   
00050     virtual void move(double dt);
00051     
00053     virtual void draw(){}
00054     
00056     //===============================================================
00057     //=========== Setters============================================
00059     void setCurrentKey(Key k);
00060     
00062     void setVelocity(Real v){ _velocity = v ; }
00063     
00065     void toggleCatmullRomMethod(bool b);
00067     void toggleLinearMethod(bool b);
00068     
00070     void setMorphings(Morphings * k){ _morphings = k; }
00071     
00073     void setInitialKey(Key k){ _initialKey = k; }
00074     //===============================================================
00075     //=========== Getters============================================
00077     int * getInterpolationID(){ return &_interpolationID; }
00078     
00080     Real * getVelocity(){ return &_velocity; }
00081     
00083     Morphings * getMorphings(){ return _morphings; }
00084     
00086     Key * getInitialKey(){ return &_initialKey; }
00087     //===============================================================
00088     
00089   protected:
00094     bool computeInterpolatedValues(Key key);
00095     
00101     bool searchRange(const Key key, Key & key0, Key & key1);
00102     
00103   private: 
00105     void printMorphings();
00106   
00110     bool begin(Key & key);
00111   
00119     bool searchKeys(const Key key, Key & key0, Key & key1, Key & key2, Key & key3);
00120 
00125     bool computeLinearInterpolation(const Key key);
00126   
00131     bool computeCatmullRomInterpolation(const Key key);
00132     
00133   
00134   protected: // Members
00135     
00137     Values * _positions;
00138   
00143     Morphings * _morphings;    
00144   
00150     int _interpolationID;
00151 
00153     Key _currentKey;
00154     
00156     Key _initialKey;
00157     
00159     Real _velocity;
00160    
00161     
00162 }; // class Morphing
00163 
00164 } // namespace animal
00165 
00166 #endif //MORPHING_ENGINE_H
00167 
00168 

Generated on Thu Dec 23 13:52:26 2004 by doxygen 1.3.6