- Timestamp:
- Jun 21, 2006, 2:44:45 AM (18 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer/md3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.cc
r8655 r8656 195 195 anim->first = atoi(tokens.back().c_str()); tokens.pop_back(); 196 196 197 //some adjustements: 198 if( anim->fps == 0) 199 anim->fps = 33; 200 197 201 PRINTF(0)("Animation: first frame: %i, num frames: %i, num loops: %i, fps: %i\n", anim->first, anim->numFrames, anim->numLoopFrames, anim->fps); 198 202 } -
branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
r8655 r8656 45 45 this->bDrawNormals = false; 46 46 47 this->time = 0.0f; 48 47 49 // set the animation 48 this->interpolate(this->md3Data, this->config->getAnimation("Dead 3"), MD3_ANIM_NEXT, true);50 this->interpolate(this->md3Data, this->config->getAnimation("Dead 3"), MD3_ANIM_NEXT, false); 49 51 } 50 52 … … 126 128 return; 127 129 128 this->visit(this->md3Data); 130 this->visit(this->md3Data, time); 131 129 132 this->tick(time, this->md3Data); 130 133 } … … 154 157 } 155 158 159 156 160 //draw all meshes of current frame of this model 157 161 for( int i = 0; i < data->header->meshNum; i++) … … 165 169 { 166 170 //interpolate mesh frame between the 2 current mesh frames 167 frame = this->interpolateMeshFrame( data, data->meshes[data->animationState.currentFrame]->meshFrames, 168 data->meshes[data->animationState.nextFrame]->meshFrames, 171 // frame = this->interpolateMeshFrame( data, 172 // data->meshes[data->animationState.currentFrame]->meshFrames, 173 // data->meshes[data->animationState.nextFrame]->meshFrames, 174 // data->animationState.interpolationFraction, mesh, i); 175 frame = this->interpolateMeshFrame( data, 176 &mesh->meshFrames[data->animationState.currentFrame], 177 &mesh->meshFrames[data->animationState.nextFrame], 169 178 data->animationState.interpolationFraction, mesh, i); 170 179 } … … 175 184 } 176 185 data->tmpMesh[i] = frame; 186 177 187 178 188 // draw vertex normals if needed … … 184 194 { 185 195 //interpolate vertex normals 186 this->interpolateVertexNormals(data, &mesh->normals[data->animationState.currentFrame], 196 this->interpolateVertexNormals(data, 197 &mesh->normals[data->animationState.currentFrame], 187 198 &mesh->normals[data->animationState.nextFrame], 188 199 data->animationState.interpolationFraction, mesh, i); 189 200 } 190 201 } 202 203 191 204 } 192 205 … … 546 559 * visit the model 547 560 */ 548 void MD3Model::visit(MD3Data* data )561 void MD3Model::visit(MD3Data* data, float time) 549 562 { 550 563 if ( (data->filename.find("lower") == std::string::npos && … … 556 569 data->animation->type == ALL // the animation is allways applicable 557 570 ) 558 this->doOp(data );571 this->doOp(data, time); 559 572 560 573 // visit children … … 624 637 * @param data: the data of the model 625 638 */ 626 void MD3Model::doOp(MD3Data* data )639 void MD3Model::doOp(MD3Data* data, float time) 627 640 { 628 641 // animation to be applied could have illegal data with respect to this model, … … 655 668 if( data->bInterpolate) 656 669 { 657 data->animationState.interpolationFraction += FRACTION; 670 data->animationState.interpolationFraction += time / data->animation->fps; 671 PRINTF(0)("anim state: +=%f, =%f\n", time / data->animation->fps, data->animationState.interpolationFraction); 658 672 if( data->animationState.interpolationFraction >= 1.0f) 659 673 { … … 664 678 } 665 679 else { 680 this->time += time * data->animation->fps; 681 PRINTF(0)("anim state: +=%f, =%f\n", time * data->animation->fps, this->time); 682 if(this->time > 1.0f) 683 { 666 684 data->animationState.currentFrame = data->animationState.nextFrame; 667 685 data->animationState.nextFrame = next(data, data->animationState.nextFrame); 686 this->time = 0.0f; 687 } 668 688 } 669 PRINTF(0)("interpolate fraction: %f, curr frame: %i \n", data->animationState.interpolationFraction, data->animationState.currentFrame);689 PRINTF(0)("interpolate fraction: %f, curr frame: %i, fps: %i, time: %f\n", data->animationState.interpolationFraction, data->animationState.currentFrame, data->animation->fps, time); 670 690 break; 671 691 … … 673 693 if( data->bInterpolate) 674 694 { 675 data->animationState.interpolationFraction -= FRACTION;695 data->animationState.interpolationFraction -= time / data->animation->fps; 676 696 if( data->animationState.interpolationFraction < 0.0f) 677 697 { -
branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
r8655 r8656 71 71 void interpolate(MD3Data* data, MD3Animation* anim, int op, bool bInterpolate); 72 72 73 void visit(MD3Data* data );73 void visit(MD3Data* data, float time); 74 74 int next(MD3Data* data, int nr); 75 75 int prev(MD3Data* data, int nr); 76 void doOp(MD3Data* data );76 void doOp(MD3Data* data, float time); 77 77 78 78 … … 85 85 MD3AnimationCfg* config; //!< the config file parsed 86 86 87 float time; 88 87 89 }; 88 90
Note: See TracChangeset
for help on using the changeset viewer.