- Timestamp:
- Apr 7, 2005, 12:11:44 AM (20 years ago)
- Location:
- orxonox/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/ToDo
r1904 r3738 5 5 -------- 6 6 7 - perspective change: smooth glide back in zero mode (pb) 8 - efficency in garbage collection ShootLaser 9 - player speed, *speed setting smoother (now taking current fps rate): average 7 #define "objModel.h" has nothing todo in world_entity.h 8 9 Collision Detection: SetObjectCollisionBox( void ); 10 10 11 11 12 ./configure13 -----------14 - if dri is not supported glxinfo returns "Xlib: extension "XFree86-DRI" missing on display ":0.0"." -> this message should not be shown on the console!15 12 16 -
orxonox/trunk/src/simple_animation.cc
r3734 r3738 1 1 2 2 3 … … 45 46 this->setClassName ("SimpleAnimation"); 46 47 this->frames = new tList<KeyFrame>(); 48 this->animators = new tList<Animation>(); 47 49 this->localTime = 0; 48 50 this->bRunning = false; … … 254 256 void SimpleAnimation::tick(float time) 255 257 { 256 if( !this->bRunning)257 return;258 259 258 this->localTime += time; 260 /* first get the current frame via time-stamps */ 261 while( this->localTime > this->currentFrame->time) 262 { 263 printf("SimpleAnimation::tick(...) - changing Frame\n"); 264 this->localTime -= this->currentFrame->time; 265 266 //this->currentFrame->object->setRelCoor(*this->currentFrame->position); 267 *this->lastPosition = *this->currentFrame->position; 268 269 this->lastFrame = this->currentFrame; 270 this->currentFrame = this->frames->nextElement(this->currentFrame); 271 this->mode = this->currentFrame->mode; 272 if( this->mode == NEG_EXP) 259 tIterator<Animation>* iterator = this->animators->getIterator(); 260 Animation* anim = iterator->nextElement(); 261 while( anim != NULL) 262 { 263 if( anim->bRunning) 273 264 { 274 *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position; 275 deltaT = 1/this->currentFrame->time * logf(1.0 + 600.0/this->tmpVect->len()); 265 266 267 /* first get the current frame via time-stamps */ 268 while( this->localTime > anim->currentFrame->time) 269 { 270 printf("SimpleAnimation::tick(...) - changing Frame\n"); 271 272 //this->currentFrame->object->setRelCoor(*this->currentFrame->position); 273 *anim->lastPosition = *anim->currentFrame->position; 274 275 anim->lastFrame = anim->currentFrame; 276 anim->currentFrame = anim->frames->nextElement(anim->currentFrame); 277 anim->movMode = anim->currentFrame->mode; 278 if( anim->movMode == NEG_EXP) 279 { 280 *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position; 281 anim->deltaT = 1/anim->currentFrame->time * logf(1.0 + 600.0/anim->tmpVect->len()); 282 } 283 } 284 285 /* now animate it */ 286 switch( anim->movMode) 287 { 288 case LINEAR: 289 290 *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position; 291 *anim->tmpVect = *anim->tmpVect * this->localTime / anim->currentFrame->time; 292 anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect); 293 *anim->lastPosition = *anim->tmpVect; 294 break; 295 case EXP: 296 297 break; 298 case NEG_EXP: 299 *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position; 300 *anim->tmpVect = *anim->tmpVect * (1 - exp(- this->localTime * anim->deltaT)); 301 anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect); 302 *anim->lastPosition = *anim->tmpVect; 303 break; 304 case SIN: 305 *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position; 306 *anim->tmpVect = *anim->tmpVect * 0.5*(1 - cos(M_PI * this->localTime / anim->currentFrame->time)); 307 anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect); 308 *anim->lastPosition = *anim->tmpVect; 309 break; 310 case COS: 311 312 break; 313 case QUADRATIC: 314 *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position; 315 *anim->tmpVect = *anim->tmpVect * 1/3 * ldexpf(this->localTime, 3); 316 break; 317 default: 318 break; 319 } 276 320 } 277 } 278 279 /* now animate it */ 280 switch( this->mode) 281 { 282 case LINEAR: 283 284 *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position; 285 *this->tmpVect = *this->tmpVect * this->localTime / this->currentFrame->time; 286 this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect); 287 *this->lastPosition = *this->tmpVect; 288 break; 289 case EXP: 290 291 break; 292 case NEG_EXP: 293 *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position; 294 *this->tmpVect = *this->tmpVect * (1 - exp(- this->localTime * this->deltaT)); 295 this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect); 296 *this->lastPosition = *this->tmpVect; 297 break; 298 case SIN: 299 *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position; 300 *this->tmpVect = *this->tmpVect * 0.5*(1 - cos(M_PI * this->localTime / this->currentFrame->time)); 301 this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect); 302 *this->lastPosition = *this->tmpVect; 303 break; 304 case COS: 305 306 break; 307 case QUADRATIC: 308 *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position; 309 *this->tmpVect = *this->tmpVect * 1/3 * ldexpf(this->localTime, 3); 310 break; 311 default: 312 break; 313 } 314 } 321 anim = iterator->nextElement(); 322 } 323 delete anim; 324 } -
orxonox/trunk/src/simple_animation.h
r3733 r3738 21 21 22 22 typedef enum movementMode{LINEAR=0, EXP, NEG_EXP, SIN, COS, QUADRATIC}; 23 typedef enum animationMode{SINGLE=0, LOOP}; 23 24 #define DEFAULT_ANIMATION_MODE LINEAR 25 24 26 25 27 //! KeyFrame Struct … … 35 37 }; 36 38 39 //! Animation Struct 40 /** 41 This represents an animation for a object 42 */ 43 typedef struct Animation { 44 WorldEntity* object; 45 KeyFrame* currentFrame; 46 KeyFrame* lastFrame; 47 Vector* lastPosition; 48 Vector* tmpVect; 49 tList<KeyFrame>* frames; 50 animationMode animMode; 51 movementMode movMode; 52 bool bRunning; 53 float deltaT; 54 }; 37 55 38 56 //! Animation Class … … 70 88 bool bRunning; //<! is set, when the animation is running 71 89 tList<KeyFrame>* frames; //<! where keyframes are stored in 90 tList<Animation>* animators; //<! a list of animation's 72 91 KeyFrame* currentFrame; //<! the frame that is been played now 73 92 KeyFrame* lastFrame; … … 79 98 Vector* tmpVect; //<! this is the temporary vector save place - 80 99 WorldEntity* workingObject; //<! this is a pointer to the current working object that has been selected via selectObject() 100 Animator* workingAnimator; //<! the animator with which you are currently working 81 101 float deltaT; //<! this is a time constant for the movement 82 102
Note: See TracChangeset
for help on using the changeset viewer.