Changeset 3973 in orxonox.OLD for orxonox/trunk/src/util/animation
- Timestamp:
- Apr 26, 2005, 1:55:47 AM (20 years ago)
- Location:
- orxonox/trunk/src/util/animation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/animation/animation3d.cc
r3971 r3973 42 42 this->nextKeyFrame = tmpKeyFrame; 43 43 44 this->animFunc = &Animation3D::linear; 44 this->animFuncMov = &Animation3D::mLinear; 45 this->animFuncRot = &Animation3D::rLinear; 45 46 } 46 47 … … 72 73 this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement()); 73 74 this->localTime = 0.0; 74 this->setAnimFunc(this->currentKeyFrame->animFunc); 75 this->setAnimFuncMov(this->currentKeyFrame->animFuncMov); 76 this->setAnimFuncRot(this->currentKeyFrame->animFuncRot); 75 77 } 76 78 … … 82 84 \param animFunc The function to animate between this keyFrame and the next one 83 85 */ 84 void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, ANIM_FUNCTION animFunc )86 void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration, ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot) 85 87 { 86 88 // some small check … … 94 96 { 95 97 tmpKeyFrame = this->keyFrameList->firstElement(); 96 this->setAnimFunc(animFunc); 98 this->setAnimFuncMov(animFuncMov); 99 this->setAnimFuncRot(animFuncRot); 97 100 } 98 101 else … … 108 111 tmpKeyFrame->direction = direction; 109 112 tmpKeyFrame->duration = duration; 110 tmpKeyFrame->animFunc = animFunc; 113 tmpKeyFrame->animFuncMov = animFuncMov; 114 tmpKeyFrame->animFuncRot = animFuncRot; 111 115 this->keyFrameCount++; 112 116 } 117 118 113 119 114 120 /** … … 130 136 this->handleInfinity(); 131 137 this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 132 this->setAnimFunc(this->currentKeyFrame->animFunc); 138 this->setAnimFuncMov(this->currentKeyFrame->animFuncMov); 139 this->setAnimFuncRot(this->currentKeyFrame->animFuncRot); 133 140 } 134 141 /* now animate it */ 135 (this->*animFunc)(this->localTime); 136 } 137 } 138 139 140 /** 141 \brief Sets The kind of Animation between this keyframe and the next one 142 (this->*animFuncMov)(this->localTime); 143 (this->*animFuncRot)(this->localTime); 144 } 145 } 146 147 148 /*==Movement Section==========================================================*/ 149 150 /** 151 \brief Sets The kind of movment Animation between this keyframe and the next one 142 152 \param animFunc The Type of Animation to set 143 153 */ 144 void Animation3D::setAnimFunc (ANIM_FUNCTION animFunc)145 { 146 switch (animFunc )154 void Animation3D::setAnimFuncMov(ANIM_FUNCTION animFuncMov) 155 { 156 switch (animFuncMov) 147 157 { 148 158 default: 149 159 case ANIM_CONSTANT: 150 this->animFunc = &Animation3D::constant;160 this->animFuncMov = &Animation3D::mConstant; 151 161 break; 152 162 case ANIM_LINEAR: 153 this->animFunc = &Animation3D::linear;163 this->animFuncMov = &Animation3D::mLinear; 154 164 break; 155 165 case ANIM_SINE: 156 this->animFunc = &Animation3D::sine;166 this->animFuncMov = &Animation3D::mSine; 157 167 break; 158 168 case ANIM_COSINE: 159 this->animFunc = &Animation3D::cosine;169 this->animFuncMov = &Animation3D::mCosine; 160 170 break; 161 171 case ANIM_EXP: 162 this->animFunc = &Animation3D::exp;172 this->animFuncMov = &Animation3D::mExp; 163 173 break; 164 174 case ANIM_NEG_EXP: 165 this->animFunc = &Animation3D::negExp;175 this->animFuncMov = &Animation3D::mNegExp; 166 176 this->expFactor = -1.0 / this->currentKeyFrame->duration * logf(DELTA_X_3D); 167 177 break; 168 178 case ANIM_QUADRATIC: 169 this->animFunc = &Animation3D::quadratic;179 this->animFuncMov = &Animation3D::mQuadratic; 170 180 break; 171 181 case ANIM_RANDOM: 172 this->animFunc = &Animation3D::random; 173 break; 174 } 175 } 182 this->animFuncMov = &Animation3D::mRandom; 183 break; 184 } 185 } 186 187 176 188 177 189 /** … … 179 191 \param timePassed The time passed since this Keyframe began 180 192 */ 181 void Animation3D:: constant(float timePassed) const193 void Animation3D::mConstant(float timePassed) const 182 194 { 183 195 this->object->setRelCoor(this->currentKeyFrame->position); … … 197 209 \todo implement also do this for direction 198 210 */ 199 void Animation3D:: linear(float timePassed) const211 void Animation3D::mLinear(float timePassed) const 200 212 { 201 213 this->object->setRelCoor(this->currentKeyFrame->position + … … 215 227 \todo implement 216 228 */ 217 void Animation3D:: sine(float timePassed) const229 void Animation3D::mSine(float timePassed) const 218 230 { 219 231 if( timePassed < this->currentKeyFrame->duration/2.0) … … 232 244 \todo implement 233 245 */ 234 void Animation3D:: cosine(float timePassed) const246 void Animation3D::mCosine(float timePassed) const 235 247 { 236 248 this->object->setRelCoor( this->nextKeyFrame->position - … … 250 262 \param timePassed The time passed since this Keyframe began 251 263 */ 252 void Animation3D:: exp(float timePassed) const264 void Animation3D::mExp(float timePassed) const 253 265 { 254 266 PRINTF(0)("no exp animation3d defined\n"); 255 this-> linear(timePassed);267 this->mLinear(timePassed); 256 268 } 257 269 … … 260 272 \param timePassed The time passed since this Keyframe began 261 273 */ 262 void Animation3D:: negExp(float timePassed) const274 void Animation3D::mNegExp(float timePassed) const 263 275 { 264 276 this->object->setRelCoor( this->currentKeyFrame->position + … … 274 286 \todo implement 275 287 */ 276 void Animation3D:: quadratic(float timePassed) const288 void Animation3D::mQuadratic(float timePassed) const 277 289 { 278 290 PRINTF(0)("no quadratic animation3d defined\n"); 279 this-> linear(timePassed);291 this->mLinear(timePassed); 280 292 } 281 293 … … 284 296 \param timePassed The time passed since this Keyframe began 285 297 */ 286 void Animation3D:: random(float timePassed) const298 void Animation3D::mRandom(float timePassed) const 287 299 { 288 300 this->object->setRelCoor(this->currentKeyFrame->position + … … 291 303 (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX); 292 304 } 305 306 307 /*==Rotation Section==========================================================*/ 308 309 310 /** 311 \brief Sets The kind of rotation Animation between this keyframe and the next one 312 \param animFunc The Type of Animation to set 313 */ 314 void Animation3D::setAnimFuncRot(ANIM_FUNCTION animFuncRot) 315 { 316 switch (animFuncRot) 317 { 318 default: 319 case ANIM_CONSTANT: 320 this->animFuncRot = &Animation3D::rConstant; 321 break; 322 case ANIM_LINEAR: 323 this->animFuncRot = &Animation3D::rLinear; 324 break; 325 case ANIM_SINE: 326 this->animFuncRot = &Animation3D::rSine; 327 break; 328 case ANIM_COSINE: 329 this->animFuncRot = &Animation3D::rCosine; 330 break; 331 case ANIM_EXP: 332 this->animFuncRot = &Animation3D::rExp; 333 break; 334 case ANIM_NEG_EXP: 335 this->animFuncRot = &Animation3D::rNegExp; 336 break; 337 case ANIM_QUADRATIC: 338 this->animFuncRot = &Animation3D::rQuadratic; 339 break; 340 case ANIM_RANDOM: 341 this->animFuncRot = &Animation3D::rRandom; 342 break; 343 } 344 } 345 346 347 /** 348 \brief stays at the value of the currentKeyFrame 349 \param timePassed The time passed since this Keyframe began 350 */ 351 void Animation3D::rConstant(float timePassed) const 352 { 353 } 354 355 /** 356 \brief linear interpolation between this keyframe and the next one 357 \param timePassed The time passed since this Keyframe began 358 359 \todo implement also do this for direction 360 */ 361 void Animation3D::rLinear(float timePassed) const 362 { 363 this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 364 this->currentKeyFrame->direction, 365 timePassed/this->currentKeyFrame->duration) ); 366 } 367 368 /** 369 \brief a Sinusodial Interpolation between this keyframe and the next one 370 \param timePassed The time passed since this Keyframe began 371 372 \todo implement 373 */ 374 void Animation3D::rSine(float timePassed) const 375 { 376 } 377 378 379 /** 380 \brief a cosine interpolation between this keyframe and the next one 381 \param timePassed The time passed since this Keyframe began 382 383 \todo implement 384 */ 385 void Animation3D::rCosine(float timePassed) const 386 { 387 } 388 389 390 /* 391 return ((this->nextKeyFrame->value + this->currentKeyFrame->value) + 392 (this->currentKeyFrame->value - this->nextKeyFrame->value) * 393 cos( M_PI * timePassed / this->currentKeyFrame->duration))/2; 394 */ 395 396 /** 397 \brief an exponential interpolation between this keyframe and the next one 398 \param timePassed The time passed since this Keyframe began 399 */ 400 void Animation3D::rExp(float timePassed) const 401 { 402 403 } 404 405 /** 406 \brief a negative exponential interpolation between this keyframe and the next one 407 \param timePassed The time passed since this Keyframe began 408 */ 409 void Animation3D::rNegExp(float timePassed) const 410 { 411 } 412 413 414 /** 415 \brief a quadratic interpolation between this keyframe and the next one 416 \param timePassed The time passed since this Keyframe began 417 418 \todo implement 419 */ 420 void Animation3D::rQuadratic(float timePassed) const 421 { 422 } 423 424 /** 425 \brief some random animation (fluctuating) 426 \param timePassed The time passed since this Keyframe began 427 */ 428 void Animation3D::rRandom(float timePassed) const 429 { 430 } -
orxonox/trunk/src/util/animation/animation3d.h
r3964 r3973 19 19 Vector position; //!< The position of this KeyFrame 20 20 Quaternion direction; //!< The direction of this KeyFrame 21 ANIM_FUNCTION animFunc; //!< with whitch function to iterate to the next KeyFrame3D 21 ANIM_FUNCTION animFuncMov; //!< with whitch function to iterate movement to the next KeyFrame3D 22 ANIM_FUNCTION animFuncRot; //!< with whitch function to iterate rotation to the next KeyFrame3D 22 23 }; 23 24 … … 34 35 virtual void rewind(void); 35 36 36 void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFunc = ANIM_LINEAR);37 void addKeyFrame(Vector position, Quaternion direction, float time, ANIM_FUNCTION animFuncMov = ANIM_LINEAR, ANIM_FUNCTION animFuncRot = ANIM_LINEAR); 37 38 // void addKeyFrame(KeyFrame3D* frame); 38 39 39 40 virtual void tick(float dt); 40 41 41 42 private: 42 43 // animation functions 43 void setAnimFunc(ANIM_FUNCTION animFunc); 44 void constant(float timePassed) const; 45 void linear(float timePassed) const; 46 void sine(float timePassed) const; 47 void cosine(float timePassed) const; 48 void exp(float timePassed) const; 49 void negExp(float timePassed) const; 50 void quadratic(float timePassed) const; 51 void random(float timePassed) const; 44 void setAnimFuncMov(ANIM_FUNCTION animFunc); 45 void setAnimFuncRot(ANIM_FUNCTION animFunc); 46 void mConstant(float timePassed) const; 47 void mLinear(float timePassed) const; 48 void mSine(float timePassed) const; 49 void mCosine(float timePassed) const; 50 void mExp(float timePassed) const; 51 void mNegExp(float timePassed) const; 52 void mQuadratic(float timePassed) const; 53 void mRandom(float timePassed) const; 54 void rConstant(float timePassed) const; 55 void rLinear(float timePassed) const; 56 void rSine(float timePassed) const; 57 void rCosine(float timePassed) const; 58 void rExp(float timePassed) const; 59 void rNegExp(float timePassed) const; 60 void rQuadratic(float timePassed) const; 61 void rRandom(float timePassed) const; 52 62 // ANIM_FUNCTION animFunc; 53 void (Animation3D::*animFunc)(float) const; //!< A Function for the AnimationType 63 void (Animation3D::*animFuncMov)(float) const; //!< A Function for the AnimationType 64 void (Animation3D::*animFuncRot)(float) const; //!< A Function for the AnimationType 54 65 55 66 KeyFrame3D* currentKeyFrame; //!< The current KeyFrame
Note: See TracChangeset
for help on using the changeset viewer.