Changeset 3785 in orxonox.OLD for orxonox/branches
- Timestamp:
- Apr 13, 2005, 1:20:46 AM (20 years ago)
- Location:
- orxonox/branches/textEngine/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/animation.cc
r3784 r3785 27 27 // initialize a beginning KeyFrame, that will be deleted afterwards 28 28 this->bHasKeys = false; 29 AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame; 30 tmpKeyFrame->value = 0.0; 31 tmpKeyFrame->duration = 1.0; 32 keyFrameList->add(tmpKeyFrame); 29 33 30 31 this->animFunc = &Anim::random; 34 // setting default values 35 this->animFunc = &Anim::linear; 36 this->currentKeyFrame = tmpKeyFrame; 37 this->nextKeyFrame = tmpKeyFrame; 32 38 } 33 39 … … 52 58 void Anim::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc) 53 59 { 54 if (!bHasKeys) 60 // some small check 61 if (duration <= 0.0) 62 duration = 1.0; 63 64 65 AnimKeyFrame* tmpKeyFrame; 66 67 if (bHasKeys) 55 68 { 56 this->keyFrameList->remove(this->keyFrameList->firstElement()); 69 tmpKeyFrame = new AnimKeyFrame; 70 if (this->currentKeyFrame == this->nextKeyFrame) 71 this->nextKeyFrame = tmpKeyFrame; 72 } 73 else 74 { 75 tmpKeyFrame = this->keyFrameList->firstElement(); 57 76 bHasKeys = true; 58 77 } 59 AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame;60 78 tmpKeyFrame->value = value; 61 79 tmpKeyFrame->duration = duration; … … 94 112 95 113 // animation functions 96 float Anim::random(float time) 114 float Anim::random(float time) const 97 115 { 98 116 return (float)rand()/(float)RAND_MAX; 99 117 } 100 118 101 float Anim::constant(float time) 119 float Anim::constant(float time) const 120 { 121 return this->currentKeyFrame->value; 122 } 123 124 float Anim::linear(float time) const 125 { 126 return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value) 127 * (time*100.0 / this->currentKeyFrame->duration); 128 // PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame); 129 // return val; 130 } 131 132 float Anim::sine(float time) const 102 133 { 103 134 104 135 } 105 106 float Anim::linear(float time)107 {108 109 }110 111 float Anim::sine(float time)112 {113 114 } -
orxonox/branches/textEngine/src/animation.h
r3784 r3785 49 49 class Anim 50 50 { 51 public: 52 void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_LINEAR); 53 void setInfinity(ANIM_INFINITY preInfinity = ANIM_INF_CONSTANT, 54 ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT); 55 void setAnimFunc(ANIM_FUNCTION animFunc); 56 51 57 protected: 52 58 Anim(void); … … 57 63 virtual void tick(float time) = 0; 58 64 59 void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_LINEAR);60 void setInfinity(ANIM_INFINITY preInfinity = ANIM_INF_CONSTANT,61 ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);62 void setAnimFunc(ANIM_FUNCTION animFunc);63 65 64 66 65 67 // animation functions 66 float random(float time) ;67 float constant(float time) ;68 float linear(float time) ;69 float sine(float time) ;68 float random(float time) const; 69 float constant(float time) const; 70 float linear(float time) const; 71 float sine(float time) const; 70 72 71 73 72 74 // variables 73 75 // ANIM_FUNCTION animFunc; 74 float (Anim::*animFunc)(float) ;76 float (Anim::*animFunc)(float) const; 75 77 ANIM_INFINITY preInfinity; 76 78 ANIM_INFINITY postInfinity; 77 79 78 80 bool bHasKeys; 81 82 AnimKeyFrame* currentKeyFrame; 83 AnimKeyFrame* nextKeyFrame; 79 84 tList<AnimKeyFrame>* keyFrameList; 80 85 }; -
orxonox/branches/textEngine/src/story_entities/world.cc
r3784 r3785 361 361 362 362 tmpAnim = new Animation<Text>(testText, &Text::setBlending); 363 364 // tmpAnim->setFuncToAnim(testText, &Text::setBlending);363 tmpAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR); 364 tmpAnim->addKeyFrame(1.0, 1.0, ANIM_LINEAR); 365 365 break; 366 366 } … … 786 786 this->localCamera->tick(this->dt); 787 787 this->garbageCollector->tick(seconds); 788 tmpAnim->tick( this->dt);788 tmpAnim->tick(seconds); 789 789 } 790 790 this->lastFrame = currentFrame;
Note: See TracChangeset
for help on using the changeset viewer.