Changeset 4597 in orxonox.OLD for orxonox/trunk/src/util/animation/animation3d.cc
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/animation/animation3d.cc
r4485 r4597 51 51 /** 52 52 \brief standard deconstructor 53 53 54 54 deletes all the Keyframes 55 55 */ … … 89 89 */ 90 90 void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, 91 91 ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot) 92 92 { 93 93 // some small check … … 101 101 102 102 KeyFrame3D* tmpKeyFrame; 103 103 104 104 // when adding the first frame 105 105 if (this->keyFrameCount == 0) … … 114 114 // when adding the second frame 115 115 if (this->currentKeyFrame == this->nextKeyFrame) 116 116 this->nextKeyFrame = tmpKeyFrame; 117 117 this->keyFrameList->add(tmpKeyFrame); 118 118 } … … 136 136 { 137 137 if (this->bRunning) 138 { 138 { 139 139 this->localTime += dt; 140 140 if (localTime >= this->currentKeyFrame->duration) 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 } 141 { 142 if (likely(this->keyFramesToPlay != 0)) 143 { 144 if (unlikely(this->keyFramesToPlay > 0)) 145 --this->keyFramesToPlay; 146 // switching to the next Key-Frame 147 this->localTime -= this->currentKeyFrame->duration; 148 this->currentKeyFrame = this->nextKeyFrame; 149 // checking, if we should still Play the animation 150 if (this->currentKeyFrame == this->keyFrameList->lastElement()) 151 this->handleInfinity(); 152 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 153 this->setAnimFuncMov(this->currentKeyFrame->animFuncMov); 154 this->setAnimFuncRot(this->currentKeyFrame->animFuncRot); 155 } 156 else 157 this->pause(); 158 } 159 159 /* now animate it */ 160 160 (this->*animFuncMov)(this->localTime); … … 257 257 else 258 258 v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (2.0 + sin( M_PI * (- timePassed /this->currentKeyFrame->duration)) )/ 2.0; 259 259 260 260 this->object->shiftCoor(v - this->currentKeyFrame->lastPosition); 261 261 this->currentKeyFrame->lastPosition = v; … … 279 279 /* 280 280 this->object->setRelCoor( this->nextKeyFrame->position - 281 282 281 (this->nextKeyFrame->position - this->currentKeyFrame->position) * 282 (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0); 283 283 */ 284 284 } … … 309 309 /* 310 310 this->object->setRelCoor( this->currentKeyFrame->position + 311 (this->nextKeyFrame->position - this->currentKeyFrame->position) * 312 311 (this->nextKeyFrame->position - this->currentKeyFrame->position) * 312 (1.0 - expf(- timePassed * expFactorMov)) ); 313 313 */ 314 314 } … … 334 334 { 335 335 /* 336 this->object->setRelCoor(this->currentKeyFrame->position + 337 336 this->object->setRelCoor(this->currentKeyFrame->position + 337 (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX); 338 338 this->object->setRelDir(this->currentKeyFrame->direction + 339 339 (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX); 340 340 */ 341 341 } … … 401 401 void Animation3D::rLinear(float timePassed) const 402 402 { 403 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 404 this->currentKeyFrame->direction, 405 403 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 404 this->currentKeyFrame->direction, 405 timePassed/this->currentKeyFrame->duration) ); 406 406 } 407 407 … … 420 420 scale = 1.0 - sin( M_PI * timePassed / this->currentKeyFrame->duration); 421 421 422 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 423 this->currentKeyFrame->direction, 424 422 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 423 this->currentKeyFrame->direction, 424 scale) ); 425 425 } 426 426 … … 435 435 { 436 436 float scale = cos(M_PI * timePassed / this->currentKeyFrame->duration); 437 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 438 this->currentKeyFrame->direction, 439 437 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 438 this->currentKeyFrame->direction, 439 scale) ); 440 440 } 441 441 … … 458 458 { 459 459 float scale = (1.0 - expf(- timePassed * expFactorRot)); 460 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 461 this->currentKeyFrame->direction, 462 460 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 461 this->currentKeyFrame->direction, 462 scale) ); 463 463 } 464 464
Note: See TracChangeset
for help on using the changeset viewer.