Changeset 8660 in orxonox.OLD
- Timestamp:
- Jun 21, 2006, 4:00:49 AM (18 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer/md3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc
r8658 r8660 47 47 48 48 this->animation = NULL; 49 this->bInterpolate = false; 50 this->upperBound = 0; 49 51 50 52 this->loadModel(modelFileName); -
branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
r8659 r8660 48 48 49 49 // set the animation 50 this->interpolate(this->md3Data, this->config->getAnimation("Dead 1"), MD3_ANIM_NEXT, false);50 this->interpolate(this->md3Data, this->config->getAnimation("Dead 1"), MD3_ANIM_NEXT, true); 51 51 } 52 52 … … 125 125 void MD3Model::tick(float time) 126 126 { 127 PRINTF(0)("tick\n"); 127 128 if(this->md3Data == NULL) 128 129 return; … … 131 132 132 133 this->tick(time, this->md3Data); 134 PRINTF(0)("tick finished\n"); 133 135 } 134 136 … … 139 141 void MD3Model::tick(float time, MD3Data* data) 140 142 { 141 // draw the bones if needed 143 // draw the bones if needed# 142 144 if( this->bDrawBones) 143 145 { … … 163 165 MD3Mesh* mesh = data->meshes[i]; 164 166 165 // if( data->animationState.interpolationFraction != 0.0 && 166 // data->animationState.currentFrame != data->animationState.nextFrame) 167 // { 167 168 168 //interpolate mesh frame between the 2 current mesh frames 169 PRINTF(0)(" interpolate from %i, to %i\n", data->animationState.currentFrame, data->animationState.nextFrame); 169 170 if( data->header->boneFrameNum > 1) 170 171 this->interpolateMeshFrame( data, … … 177 178 mesh->meshFrames[data->animationState.currentFrame], 178 179 0.0f, mesh, i); 179 // } 180 // else 181 // { 182 // //no interpolation needed, just draw current frame 183 // frame = &mesh->meshFrames[data->animationState.currentFrame]; 184 // } 180 185 181 186 182 … … 219 215 { 220 216 //we need to interpolate 221 MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];222 this->interpolateTransformation(child, currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);217 // MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex]; 218 // this->interpolateTransformation(child, currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i); 223 219 } 224 220 else … … 260 256 void MD3Model::draw() const 261 257 { 258 PRINTF(0)("draw\n"); 262 259 //draw current bone frame 263 260 this->draw(this->md3Data); 261 PRINTF(0)("draw finished\n"); 264 262 } 265 263 … … 483 481 int vertexNum = mesh->header->vertexNum; 484 482 485 // calc interpolated vertices 486 for( int t = 0; t < vertexNum; t++) 487 { 488 data->tmpMesh[i][t][0] = (1.0f - frac) * currMeshFrame[t][0] + frac * nextMeshFrame[t][0]; 489 data->tmpMesh[i][t][1] = (1.0f - frac) * currMeshFrame[t][1] + frac * nextMeshFrame[t][1]; 490 data->tmpMesh[i][t][2] = (1.0f - frac) * currMeshFrame[t][2] + frac * nextMeshFrame[t][2]; 483 if( /*frac == 0.0f*/ true) 484 { 485 // just copy the vertices 486 for( int t = 0; t < vertexNum; t++) 487 { 488 data->tmpMesh[i][t][0] = currMeshFrame[t][0]; 489 data->tmpMesh[i][t][1] = currMeshFrame[t][1]; 490 data->tmpMesh[i][t][2] = currMeshFrame[t][2]; 491 } 492 } 493 else 494 { 495 // calc interpolated vertices 496 for( int t = 0; t < vertexNum; t++) 497 { 498 data->tmpMesh[i][t][0] = (1.0f - frac) * currMeshFrame[t][0] + frac * nextMeshFrame[t][0]; 499 data->tmpMesh[i][t][1] = (1.0f - frac) * currMeshFrame[t][1] + frac * nextMeshFrame[t][1]; 500 data->tmpMesh[i][t][2] = (1.0f - frac) * currMeshFrame[t][2] + frac * nextMeshFrame[t][2]; 501 } 491 502 } 492 503 … … 654 665 data->upperBound = data->header->boneFrameNum; 655 666 else 656 data->upperBound = (data->animation->first + 657 data->animation->numFrames); 658 } 659 660 661 // PRINTF(0)("anim op: %i\n", data->op); 667 data->upperBound = (data->animation->first + data->animation->numFrames); 668 } 669 670 671 PRINTF(0)("anim op: %i\n", data->op); 662 672 switch( data->op) { 663 673 … … 665 675 if( data->bInterpolate) 666 676 { 667 data->animationState.interpolationFraction += time / data->animation->fps; 668 PRINTF(0)("anim state: +=%f, =%f\n", time / data->animation->fps, data->animationState.interpolationFraction); 677 // keyframe interpolation animation 678 data->animationState.interpolationFraction += time * data->animation->fps; 679 669 680 if( data->animationState.interpolationFraction >= 1.0f) 670 681 { … … 674 685 } 675 686 } 676 else { 687 else 688 { 689 // only keyframe animation 677 690 this->time += time * data->animation->fps; 678 if( this->time > 1.0f)691 if( this->time > 1.0f) 679 692 { 680 data->animationState.currentFrame = data->animationState.nextFrame;681 data->animationState.nextFrame = next(data, data->animationState.nextFrame);682 this->time = 0.0f;693 data->animationState.currentFrame = data->animationState.nextFrame; 694 data->animationState.nextFrame = next(data, data->animationState.nextFrame); 695 this->time = 0.0f; 683 696 } 684 697 }
Note: See TracChangeset
for help on using the changeset viewer.