Changeset 4597 in orxonox.OLD for orxonox/trunk/src/util/animation/t_animation.h
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/animation/t_animation.h
r3982 r4597 14 14 */ 15 15 16 /*! 16 /*! 17 17 \file t_animation.h 18 18 */ … … 80 80 */ 81 81 template<class T> 82 tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 82 tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 83 83 { 84 84 // create a new List … … 100 100 /** 101 101 \brief standard deconstructor 102 102 103 103 deletes all the Keyframes 104 104 */ 105 105 template<class T> 106 tAnimation<T>::~tAnimation () 106 tAnimation<T>::~tAnimation () 107 107 { 108 108 // delete all the KeyFrames … … 158 158 159 159 KeyFrameF* tmpKeyFrame; 160 160 161 161 // when adding the first frame 162 162 if (this->keyFrameCount == 0) … … 170 170 // when adding the second frame 171 171 if (this->currentKeyFrame == this->nextKeyFrame) 172 172 this->nextKeyFrame = tmpKeyFrame; 173 173 this->keyFrameList->add(tmpKeyFrame); 174 174 } … … 191 191 this->localTime += dt; 192 192 if (localTime >= this->currentKeyFrame->duration) 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 this->setAnimFunc(this->currentKeyFrame->animFunc); 209 210 211 212 213 193 { 194 if (likely(this->keyFramesToPlay != 0)) 195 { 196 if (unlikely(this->keyFramesToPlay > 0)) 197 --this->keyFramesToPlay; 198 // switching to the next Key-Frame 199 this->localTime -= this->currentKeyFrame->duration; 200 201 this->currentKeyFrame = this->nextKeyFrame; 202 // checking, if we should still Play the animation 203 if (this->currentKeyFrame == this->keyFrameList->lastElement()) 204 this->handleInfinity(); 205 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 206 207 printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value); 208 this->setAnimFunc(this->currentKeyFrame->animFunc); 209 } 210 else 211 this->pause(); 212 } 213 214 214 (this->object->*(funcToAnim))((this->*animFunc)(this->localTime)); 215 215 } … … 243 243 case ANIM_NEG_EXP: 244 244 { 245 246 247 245 this->animFunc = &tAnimation<T>::negExp; 246 expFactor = - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X); 247 break; 248 248 } 249 249 case ANIM_QUADRATIC: … … 273 273 */ 274 274 template<class T> 275 float tAnimation<T>::linear(float timePassed) const 275 float tAnimation<T>::linear(float timePassed) const 276 276 { 277 277 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) … … 287 287 { 288 288 if (timePassed * 2.0 < this->currentKeyFrame->duration) 289 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 289 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 290 290 * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2; 291 else 291 else 292 292 return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value) 293 293 * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2; … … 350 350 float tAnimation<T>::random(float timePassed) const 351 351 { 352 return this->currentKeyFrame->value + 352 return this->currentKeyFrame->value + 353 353 (this->nextKeyFrame->value - this->currentKeyFrame->value) * 354 354 (float)rand()/(float)RAND_MAX;
Note: See TracChangeset
for help on using the changeset viewer.