Changeset 3847 in orxonox.OLD for orxonox/trunk/src/animation.h
- Timestamp:
- Apr 17, 2005, 2:01:28 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/animation.h
r3846 r3847 55 55 }; 56 56 57 class Anim 57 class Animation 58 58 { 59 59 public: 60 virtual ~Anim (void);60 virtual ~Animation(void); 61 61 void doNotHandle(void); 62 62 … … 87 87 88 88 protected: 89 Anim (void);89 Animation(void); 90 90 91 91 // variables … … 102 102 103 103 //! A Class to handle some animation for single floated values. 104 template<class T> class tAnim : public Anim104 template<class T> class tAnimation : public Animation 105 105 { 106 106 public: 107 tAnim (T* object = NULL, void (T::*funcToAnim)(float) = NULL);108 virtual ~tAnim ();107 tAnimation(T* object = NULL, void (T::*funcToAnim)(float) = NULL); 108 virtual ~tAnimation(); 109 109 110 110 virtual void rewind(); … … 127 127 float random(float timePassed) const; 128 128 // ANIM_FUNCTION animFunc; 129 float (tAnim <T>::*animFunc)(float) const;129 float (tAnimation<T>::*animFunc)(float) const; 130 130 AnimKeyFrame* currentKeyFrame; 131 131 AnimKeyFrame* nextKeyFrame; … … 148 148 */ 149 149 template<class T> 150 tAnim <T>::tAnim(T* object, void (T::*funcToAnim)(float))150 tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 151 151 { 152 152 // create a new List … … 160 160 this->nextKeyFrame = tmpKeyFrame; 161 161 162 this->animFunc = &tAnim <T>::linear;162 this->animFunc = &tAnimation<T>::linear; 163 163 164 164 this->setFuncToAnim(object, funcToAnim); … … 171 171 */ 172 172 template<class T> 173 tAnim <T>::~tAnim()173 tAnimation<T>::~tAnimation () 174 174 { 175 175 // delete all the KeyFrames … … 187 187 188 188 template<class T> 189 void tAnim <T>::rewind(void)189 void tAnimation<T>::rewind(void) 190 190 { 191 191 this->currentKeyFrame = keyFrameList->firstElement(); … … 195 195 196 196 template<class T> 197 void tAnim <T>::setFuncToAnim(T* object, void (T::*funcToAnim)(float))197 void tAnimation<T>::setFuncToAnim(T* object, void (T::*funcToAnim)(float)) 198 198 { 199 199 this->baseObject = this->object = object; … … 202 202 203 203 template<class T> 204 void tAnim <T>::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc)204 void tAnimation<T>::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc) 205 205 { 206 206 // some small check … … 232 232 233 233 template<class T> 234 void tAnim <T>::tick(float time)234 void tAnimation<T>::tick(float time) 235 235 { 236 236 if (this->bRunning) … … 265 265 266 266 template<class T> 267 void tAnim <T>::setAnimFunc(ANIM_FUNCTION animFunc)267 void tAnimation<T>::setAnimFunc(ANIM_FUNCTION animFunc) 268 268 { 269 269 switch (animFunc) … … 271 271 default: 272 272 case ANIM_CONSTANT: 273 this->animFunc = &tAnim <T>::constant;273 this->animFunc = &tAnimation<T>::constant; 274 274 break; 275 275 case ANIM_LINEAR: 276 this->animFunc = &tAnim <T>::linear;276 this->animFunc = &tAnimation<T>::linear; 277 277 break; 278 278 case ANIM_SINE: 279 this->animFunc = &tAnim <T>::sine;279 this->animFunc = &tAnimation<T>::sine; 280 280 break; 281 281 case ANIM_COSINE: 282 this->animFunc = &tAnim <T>::cosine;282 this->animFunc = &tAnimation<T>::cosine; 283 283 break; 284 284 case ANIM_EXP: 285 this->animFunc = &tAnim <T>::exp;285 this->animFunc = &tAnimation<T>::exp; 286 286 break; 287 287 case ANIM_NEG_EXP: 288 288 { 289 this->animFunc = &tAnim <T>::negExp;289 this->animFunc = &tAnimation<T>::negExp; 290 290 float d = fabs(this->currentKeyFrame->value - this->nextKeyFrame->value); 291 291 expFactor = - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X); … … 293 293 } 294 294 case ANIM_QUADRATIC: 295 this->animFunc = &tAnim <T>::quadratic;295 this->animFunc = &tAnimation<T>::quadratic; 296 296 break; 297 297 case ANIM_RANDOM: 298 this->animFunc = &tAnim <T>::random;298 this->animFunc = &tAnimation<T>::random; 299 299 break; 300 300 } … … 304 304 // animation functions 305 305 template<class T> 306 float tAnim <T>::random(float timePassed) const306 float tAnimation<T>::random(float timePassed) const 307 307 { 308 308 return (float)rand()/(float)RAND_MAX; … … 310 310 311 311 template<class T> 312 float tAnim <T>::constant(float timePassed) const312 float tAnimation<T>::constant(float timePassed) const 313 313 { 314 314 return this->currentKeyFrame->value; … … 316 316 317 317 template<class T> 318 float tAnim <T>::linear(float timePassed) const318 float tAnimation<T>::linear(float timePassed) const 319 319 { 320 320 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) … … 325 325 326 326 template<class T> 327 float tAnim <T>::sine(float timePassed) const327 float tAnimation<T>::sine(float timePassed) const 328 328 { 329 329 float d = this->currentKeyFrame->value - this->nextKeyFrame->value; … … 337 337 338 338 template<class T> 339 float tAnim <T>::cosine(float timePassed) const339 float tAnimation<T>::cosine(float timePassed) const 340 340 { 341 341 float d = this->currentKeyFrame->value - this->nextKeyFrame->value; … … 350 350 351 351 template<class T> 352 float tAnim <T>::exp(float timePassed) const353 { 354 } 355 356 template<class T> 357 float tAnim <T>::negExp(float timePassed) const352 float tAnimation<T>::exp(float timePassed) const 353 { 354 } 355 356 template<class T> 357 float tAnimation<T>::negExp(float timePassed) const 358 358 { 359 359 float d = this->currentKeyFrame->value - this->nextKeyFrame->value; … … 363 363 364 364 template<class T> 365 float tAnim <T>::quadratic(float timePassed) const365 float tAnimation<T>::quadratic(float timePassed) const 366 366 { 367 367
Note: See TracChangeset
for help on using the changeset viewer.