Changeset 3785 in orxonox.OLD for orxonox/branches/textEngine/src/animation.cc
- Timestamp:
- Apr 13, 2005, 1:20:46 AM (19 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.