Changeset 4224 in orxonox.OLD for orxonox/branches/md2_loader/src/lib
- Timestamp:
- May 19, 2005, 9:37:46 PM (19 years ago)
- Location:
- orxonox/branches/md2_loader/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc
r4215 r4224 41 41 sAnim MD2Model2::animationList[21] = 42 42 { 43 // begin, end, fps 43 44 { 0, 39, 9 }, // STAND 44 45 { 40, 45, 10 }, // RUN … … 511 512 512 513 this->textureID = 0; 513 this->scaleFactor = 1.0f;514 this->scaleFactor = 0.001f; 514 515 515 516 this->setAnim(STAND); … … 552 553 this->numFrames = header.numFrames; 553 554 this->numVertices = header.numVertices; 555 this->numTriangles = header.numTriangles; 554 556 this->numGLCommands = header.numGlCommands; 555 557 /* allocate memory for the data storage */ … … 583 585 pVertex[i][0] = (frame->pVertices[i].v[0] * frame->scale[0]) + frame->translate[0]; 584 586 pVertex[i][1] = (frame->pVertices[i].v[1] * frame->scale[1]) + frame->translate[1]; 585 pVertex[i][2] = (frame->pVertices[i].v[2] * frame->scale[2]) + frame->translate[2]; 587 pVertex[i][2] = (frame->pVertices[i].v[2] * frame->scale[2]) + frame->translate[2]; 586 588 587 589 pNormals[i] = frame->pVertices[i].lightNormalIndex; … … 617 619 nextVec = &this->pVertices[this->numVertices * this->animationState.nextFrame]; 618 620 619 //printf("currVec: %f, %f, %f\n", currVec[0][0], currVec[0][1], currVec[0][2]);620 //printf("nextVec: %f, %f, %f\n", nextVec[0], nextVec[1], nextVec[2]);621 printf("currVec: %f, %f, %f\n", currVec[0][0], currVec[0][1], currVec[0][2]); 622 printf("nextVec: %f, %f, %f\n", nextVec[0][0], nextVec[1][1], nextVec[2][2]); 621 623 622 for(int i = 0; i < this->numFrames; ++i) 623 { 624 /* 625 verticesList[i][0] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][0] * this->scaleFactor; 626 verticesList[i][1] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][1] * this->scaleFactor; 627 verticesList[i][2] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][2] * this->scaleFactor; 628 */ 629 630 verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor; 631 verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor; 632 verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor; 633 } 624 printf("numFrames: %i\n", this->numFrames); 625 printf("currentFrame: %i\n", this->animationState.currentFrame); 626 627 //for(int i = 0; i < this->numFrames; ++i) 628 for(int i = 0; i < this->numVertices; ++i) 629 { 630 /* 631 verticesList[i][0] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][0] * this->scaleFactor; 632 verticesList[i][1] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][1] * this->scaleFactor; 633 verticesList[i][2] = this->pVertices[i + (this->numFrames * this->animationState.currentFrame)][2] * this->scaleFactor; 634 */ 635 636 637 verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor; 638 verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor; 639 verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor; 640 641 642 //printf(" pVertices %f, %f, %f\n", pVertices[i][0], pVertices[i][1], pVertices[i][2]); 643 //printf(" list: %f, %f, %f \n", verticesList[i][0], verticesList[i][1], verticesList[i][2]); 644 } 634 645 } 635 646 … … 639 650 if( (type < 0) || (type > MAX_ANIMATIONS) ) 640 651 type = 0; 641 642 this->animationState.startFrame = animationList[type].firstFrame; 643 this->animationState.endFrame = animationList[type].lastFrame; 644 this->animationState.nextFrame = animationList[type].firstFrame + 1; 645 this->animationState.fps = animationList[type].fps; 646 this->animationState.type = type; 652 653 this->animationState.startFrame = animationList[type].firstFrame; 654 this->animationState.endFrame = animationList[type].lastFrame; 655 this->animationState.nextFrame = animationList[type].firstFrame + 1; 656 this->animationState.fps = animationList[type].fps; 657 this->animationState.type = type; 658 659 this->animationState.interpolationState = 0.0; 660 this->animationState.localTime = 0.0; 661 this->animationState.lastTime = 0.0; 662 this->animationState.currentFrame = animationList[type].firstFrame; 647 663 } 648 664 … … 670 686 671 687 672 /* hhmmm... id used a very different way to do lightning... */688 /* hhmmm... id used a very different way to do lightning... */ 673 689 void MD2Model2::processLighting() 674 690 { 675 691 shadeDots = anormsDots[((int)(md2Angle*(SHADEDOT_QUANT / 360.0)))&(SHADEDOT_QUANT - 1)]; 676 692 } 693 677 694 678 695 void MD2Model2::tick(float time) … … 696 713 697 714 glPopMatrix(); 715 } 716 717 718 void MD2Model2::draw2() 719 { 720 glBegin(GL_TRIANGLES); 721 for(int j = 0; j < this->numTriangles; j++) 722 { 723 for(int whichVertex = 0; whichVertex < 3; whichVertex++) 724 { 725 /* 726 int index = pObject->pFaces[j].vertIndex[whichVertex]; 727 int index2 = pObject->pFaces[j].coordIndex[whichVertex]; 728 glNormal3f(-pObject->pNormals[index].x, -pObject->pNormals[index].y, -pObject->pNormals[index].z); 729 730 if( likely(pObject->pTexVerts != NULL)) 731 { 732 glTexCoord2f(pObject->pTexVerts[index2].x, pObject->pTexVerts[index2].y); 733 } 734 glVertex3f(pObject->pVerts[index].x, pObject->pVerts[index].y, pObject->pVerts[index].z); 735 */ 736 } 737 } 738 glEnd(); 698 739 } 699 740 … … 716 757 /* draw the triangles */ 717 758 /* \todo: take int i out of while loop */ 718 while( int i = *(pCommands++)) /* strange looking while loop for maximum performance */ 719 { 759 while( false /*int i = *(pCommands++)*/) /* strange looking while loop for maximum performance */ 760 { 761 int i; 720 762 if( i < 0) 721 763 { … … 737 779 glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] ); 738 780 glVertex3fv(verticesList[pCommands[2]]); 781 782 //printf("draw vert: %f, %f, %f\n", verticesList[pCommands[2]][0], verticesList[pCommands[2]][1], verticesList[pCommands[2]][2] ); 739 783 } 740 784 glEnd(); -
orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h
r4213 r4224 2 2 \file md2Model.h 3 3 \brief Definition of an MD2 Model, a model format invented by ID Software. 4 5 6 7 8 9 10 11 12 13 14 15 4 5 We are deeply thankfull for all the wunderfull things id software made for us gamers! 6 7 The md2 file format is structured in a very simple way: it contains animations which are made out of 8 frames (so called keyframes). Each frame is a complete draweable model in a specific position. 9 A frame is a collection of vertex and its compagnions (normals, texture coordinates). 10 11 A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently 12 512 frames. The maximal vetices count is set to 2048 verteces, not enough? 13 You just have to change the MD2_MAX_* values if it doesn't fit your purposes... 14 15 Surface Culling is fully implemented in md2 models: quake2 uses front face culling. 16 16 */ 17 17 … … 187 187 void drawFrame(int frame); 188 188 void draw(); 189 void draw2(); 189 190 190 191 void setAnim(int type); … … 209 210 int numFrames; 210 211 int numVertices; 212 int numTriangles; 211 213 int numGLCommands; 212 214 … … 219 221 sAnimState animationState; 220 222 float scaleFactor; 223 //tMd2Header* header; 221 224 }; 222 225
Note: See TracChangeset
for help on using the changeset viewer.