Changeset 4227 in orxonox.OLD for orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc
- Timestamp:
- May 19, 2005, 10:50:00 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc
r4226 r4227 532 532 { 533 533 FILE *pFile; //file stream 534 tMd2Header header;534 //tMd2Header header; 535 535 char* buffer; //buffer for frame data 536 536 sFrame* frame; //temp frame … … 544 544 return false; 545 545 } 546 fread( &header, 1, sizeof(tMd2Header), pFile);546 fread(header, 1, sizeof(tMd2Header), pFile); 547 547 /* check for the header version: make sure its a md2 file :) */ 548 548 if( unlikely(header.version != MD2_VERSION) && unlikely(header.ident != MD2_IDENT)) … … 553 553 554 554 /* got the data: map it to locals */ 555 this->numFrames = header.numFrames;556 this->numVertices = header.numVertices;557 this->numTriangles = header.numTriangles;558 this->numGLCommands = header.numGlCommands;555 this->numFrames = this->header->numFrames; 556 this->numVertices = this->header->numVertices; 557 this->numTriangles = this->header->numTriangles; 558 this->numGLCommands = this->header->numGlCommands; 559 559 /* allocate memory for the data storage */ 560 560 this->pVertices = new sVec3D[this->numVertices * this->numFrames]; 561 561 this->pGLCommands = new int[this->numGLCommands]; 562 562 this->pLightNormals = new int[this->numVertices * this->numFrames]; 563 buffer = new char[this->numFrames * header.frameSize];563 buffer = new char[this->numFrames * this->header->frameSize]; 564 564 565 565 /* read frame data from the file to a temp buffer */ 566 fseek(pFile, header.offsetFrames, SEEK_SET);567 fread(buffer, header.frameSize, this->numFrames, pFile);566 fseek(pFile, this->header->offsetFrames, SEEK_SET); 567 fread(buffer, this->header->frameSize, this->numFrames, pFile); 568 568 /* read opengl commands */ 569 fseek(pFile, header.offsetGlCommands, SEEK_SET);569 fseek(pFile, this->header->offsetGlCommands, SEEK_SET); 570 570 fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile); 571 571 … … 574 574 /* 575 575 faster but evt. buggy 576 frame = (sFrame*)(buffer + header.frameSize * i);576 frame = (sFrame*)(buffer + this->header->frameSize * i); 577 577 pVertex = this->pVertices + this->numVertices * i; 578 578 pNormals = this->pLightNormals + this->numVertices * i; 579 579 */ 580 frame = (sFrame *)&buffer[ header.frameSize * i];580 frame = (sFrame *)&buffer[this->header->frameSize * i]; 581 581 pVertex = &this->pVertices[this->numVertices * i]; 582 582 pNormals = &this->pLightNormals[this->numVertices * i]; … … 645 645 646 646 //printf(" pVertices %f, %f, %f\n", pVertices[i][0], pVertices[i][1], pVertices[i][2]); 647 //printf(" list: %f, %f, %f \n", verticesList[i][0], verticesList[i][1], verticesList[i][2]);647 printf(" list: %f, %f, %f \n", verticesList[i][0], verticesList[i][1], verticesList[i][2]); 648 648 } 649 649 } … … 792 792 } 793 793 794 795 void MD2Model2::debug() 796 { 797 PRINT(0)("==========================| MD2Model2::debug() |==="); 798 PRINT(0)("= Model Name: %s", this->); 799 PRINT(0)(" Position: %f/%f/%f\n", this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]); 800 PRINT(0)(" DiffuseColor: %f/%f/%f\n", this->diffuseColor[0], this->diffuseColor[1], this->diffuseColor[2]); 801 PRINT(0)(" SpecularColor: %f/%f/%f\n", this->specularColor[0], this->specularColor[1], this->specularColor[2]); 802 PRINT(0)(" Attenuation: constant=%f linear=%f quadratic=%f\n", this->constantAttenuation, this->linearAttenuation, this->quadraticAttenuation); 803 } 804 805 806 int ident; //!< This is used to identify the file 807 int version; //!< The version number of the file (Must be 8) 808 809 int skinWidth; //!< The skin width in pixels 810 int skinHeight; //!< The skin height in pixels 811 int frameSize; //!< The size in bytes the frames are 812 813 int numSkins; //!< The number of skins associated with the model 814 int numVertices; //!< The number of vertices (constant for each frame) 815 int numTexCoords; //!< The number of texture coordinates 816 int numTriangles; //!< The number of faces (polygons) 817 int numGlCommands; //!< The number of gl commands 818 int numFrames; //!< The number of animation frames 819 820 int offsetSkins; //!< The offset in the file for the skin data 821 int offsetTexCoords; //!< The offset in the file for the texture data 822 int offsetTriangles; //!< The offset in the file for the face data 823 int offsetFrames; //!< The offset in the file for the frames data 824 int offsetGlCommands; //!< The offset in the file for the gl commands data 825 int offsetEnd; //!< The end of the file offset
Note: See TracChangeset
for help on using the changeset viewer.