Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4281 in orxonox.OLD


Ignore:
Timestamp:
May 24, 2005, 6:21:17 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: seperated the data from the model: now MD2Data represents the vertex/skin data of a model and can be shared between multiple MD2Models.

Location:
orxonox/trunk/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/md2Model.cc

    r4280 r4281  
    195195  sVec3D* nextVec;
    196196
    197   currVec = &this->pVertices[this->numVertices * this->animationState.currentFrame];
    198   nextVec = &this->pVertices[this->numVertices * this->animationState.nextFrame];
    199 
    200   for(int i = 0; i < this->numFrames; ++i)
    201     {
    202       verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor;
    203       verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor;
    204       verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor;
     197  currVec = &this->data->pVertices[this->data->numVertices * this->animationState.currentFrame];
     198  nextVec = &this->data->pVertices[this->data->numVertices * this->animationState.nextFrame];
     199
     200  for(int i = 0; i < this->data->numFrames; ++i)
     201    {
     202      verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->data->scaleFactor;
     203      verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->data->scaleFactor;
     204      verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->data->scaleFactor;
    205205    }
    206206}
     
    247247{
    248248  static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
    249   int* pCommands = this->pGLCommands;
     249  int* pCommands = this->data->pGLCommands;
    250250
    251251  /* some face culling stuff */
     
    257257  this->processLighting();
    258258  this->interpolate(verticesList);
    259   this->material->select();
     259  this->data->material->select();
    260260
    261261  /* draw the triangles */
     
    274274      for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
    275275        {
    276           glNormal3fv(anorms[this->pLightNormals[pCommands[2]]]);
     276          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
    277277          glTexCoord2f( ((float *)pCommands)[0], 1.0-((float *)pCommands)[1] );
    278278          glVertex3fv(verticesList[pCommands[2]]);
     
    297297    }
    298298
    299   if( this->animationState.currentFrame > (this->numFrames - 1) )
     299  if( this->animationState.currentFrame > (this->data->numFrames - 1) )
    300300    this->animationState.currentFrame = 0;
    301   if( this->animationState.nextFrame > (this->numFrames - 1) )
     301  if( this->animationState.nextFrame > (this->data->numFrames - 1) )
    302302    this->animationState.nextFrame = 0;
    303303
     
    317317{
    318318  PRINT(0)("==========================| MD2Model::debug() |===\n");
    319   PRINT(0)("=  Model FileName:\t%s\n", this->fileName);
    320   PRINT(0)("=  Skin FileName:\t%s\n", this->skinFileName);
    321   PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->header->frameSize * this->header->numFrames + 64); // 64bytes is the header size
    322   PRINT(0)("=  Number of Vertices:\t%i\n", this->header->numVertices);
    323   PRINT(0)("=  Number of Frames: \t%i\n", this->header->numFrames);
    324   PRINT(0)("=  Height, Width\t\t%i, %i\n", this->header->skinHeight, this->header->skinWidth);
     319  PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName);
     320  PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName);
     321  PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
     322  PRINT(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
     323  PRINT(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
     324  PRINT(0)("=  Height, Width\t\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
    325325  PRINT(0)("===================================================\n\n");
    326326}
     
    422422  this->skinFileName = new char[strlen(fileName)+1];
    423423  strcpy(this->skinFileName, fileName);
     424
    424425  this->material = new Material("md2ModelTest");
    425426  this->material->setDiffuseMap(fileName);
  • orxonox/trunk/src/lib/graphics/importer/md2Model.h

    r4279 r4281  
    164164 private:
    165165  MD2Data* data;
    166 
     166 
    167167  int numFrames;
    168168  int numVertices;
     
    177177  int* pLightNormals;
    178178  glCommandVertex* pGLCommands2;
     179 
    179180
    180181  Material* material;
Note: See TracChangeset for help on using the changeset viewer.