Changeset 6199 in orxonox.OLD for branches/christmas_branche/src/lib/graphics
- Timestamp:
- Dec 20, 2005, 10:21:30 PM (19 years ago)
- Location:
- branches/christmas_branche/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/christmas_branche/src/lib/graphics/importer/md2Model.cc
r6198 r6199 50 50 sAnim MD2Model::animationList[21] = 51 51 { 52 // begin, end, fps 53 { 0, 39, 9 }, //!< STAND54 { 40, 45, 10 }, //!< RUN55 { 46, 53, 10 }, //!< ATTACK56 { 54, 57, 7 }, //!< PAIN_A57 { 58, 61, 7 }, //!< PAIN_B58 { 62, 65, 7 }, //!< PAIN_C59 { 66, 71, 7 }, //!< JUMP60 { 72, 83, 7 }, //!< FLIP61 { 84, 94, 7 }, //!< SALUTE62 { 95, 111, 10 }, //!< FALLBACK63 { 112, 122, 7 }, //!< WAVE64 { 123, 134, 6 }, //!< POINTT65 { 135, 153, 10 }, //!< CROUCH_STAND66 { 154, 159, 7 }, //!< CROUCH_WALK67 { 160, 168, 10 }, //!< CROUCH_ATTACK68 { 196, 172, 7 }, //!< CROUCH_PAIN69 { 173, 177, 5 }, //!< CROUCH_DEATH70 { 178, 183, 7 }, //!< DEATH_FALLBACK71 { 184, 189, 7 }, //!< DEATH_FALLFORWARD72 { 190, 197, 7 }, //!< DEATH_FALLBACKSLOW73 { 198, 198, 5 }, //!< BOOM52 // begin, end, fps, stoppable 53 { 0, 39, 9, 1 }, //!< STAND 54 { 40, 45, 10, 1 }, //!< RUN 55 { 46, 53, 10, 1 }, //!< ATTACK 56 { 54, 57, 7, 1 }, //!< PAIN_A 57 { 58, 61, 7, 1 }, //!< PAIN_B 58 { 62, 65, 7, 1 }, //!< PAIN_C 59 { 66, 71, 7, 0 }, //!< JUMP 60 { 72, 83, 7, 1 }, //!< FLIP 61 { 84, 94, 7, 1 }, //!< SALUTE 62 { 95, 111, 10, 1 }, //!< FALLBACK 63 { 112, 122, 7, 1 }, //!< WAVE 64 { 123, 134, 6, 1 }, //!< POINTT 65 { 135, 153, 10, 1 }, //!< CROUCH_STAND 66 { 154, 159, 7, 1 }, //!< CROUCH_WALK 67 { 160, 168, 10, 1 }, //!< CROUCH_ATTACK 68 { 196, 172, 7, 1 }, //!< CROUCH_PAIN 69 { 173, 177, 5, 0 }, //!< CROUCH_DEATH 70 { 178, 183, 7, 0 }, //!< DEATH_FALLBACK 71 { 184, 189, 7, 0 }, //!< DEATH_FALLFORWARD 72 { 190, 197, 7, 0 }, //!< DEATH_FALLBACKSLOW 73 { 198, 198, 5, 1 }, //!< BOOM 74 74 }; 75 75 … … 91 91 92 92 this->scaleFactor = this->data->scaleFactor; 93 94 /* set the animation stat mannualy */ 95 this->animationState.type = STAND; 93 96 this->setAnim(STAND); 94 97 … … 141 144 if( (type < 0) || (type > MAX_ANIMATIONS) ) 142 145 type = STAND; 146 147 if( MD2Model::animationList[this->animationState.type].bStoppable == 0) 148 { 149 if( this->animationState.numPlays == 0 ) 150 return; 151 } 143 152 144 153 this->animationState.startFrame = animationList[type].firstFrame; … … 147 156 this->animationState.fps = animationList[type].fps; 148 157 this->animationState.type = type; 158 this->animationState.numPlays = 0; 149 159 150 160 this->animationState.interpolationState = 0.0f; … … 161 171 void MD2Model::tick(float time) 162 172 { 163 this->animationState.localTime += time; 164 165 this->animate(); 173 this->animate(time); 166 174 this->processLighting(); 167 175 this->interpolate(/*verticesList*/); … … 223 231 glPopAttrib(); 224 232 } 225 226 227 228 233 229 234 … … 271 276 272 277 273 274 275 278 /** 276 279 \brief animates the current model … … 278 281 depending on the time passed (tick function), the player will select another model 279 282 */ 280 void MD2Model::animate() 281 { 283 void MD2Model::animate(float time) 284 { 285 this->animationState.localTime += time; 286 282 287 if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps)) 283 288 { … … 286 291 287 292 if( this->animationState.nextFrame > this->animationState.endFrame) 293 { 288 294 this->animationState.nextFrame = this->animationState.startFrame; 295 this->animationState.numPlays++; 296 } 289 297 this->animationState.lastTime = this->animationState.localTime; 290 298 } -
branches/christmas_branche/src/lib/graphics/importer/md2Model.h
r6198 r6199 116 116 int lastFrame; //!< last frame of the animation 117 117 int fps; //!< speed: number of frames per second 118 int bStoppable; //!< 1 if the animation is stoppable 0 else 118 119 } sAnim; 119 120 … … 134 135 int currentFrame; //!< the current frame 135 136 int nextFrame; //!< the next frame in the list 137 int numPlays; //!< the number of times, this has been played in series 136 138 } sAnimState; 137 139 … … 228 230 229 231 private: 230 void animate( );232 void animate(float time); 231 233 void processLighting(); 232 234 void interpolate(/*sVec3D* verticesList*/);
Note: See TracChangeset
for help on using the changeset viewer.