Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 5, 2006, 5:27:38 PM (19 years ago)
Author:
ponder
Message:

The md2Model loader now works as expected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/osx/src/lib/graphics/importer/md2Model.cc

    r8122 r8162  
    8080                _iptr[_l] = SDL_SwapLE32( _iptr[_l] );\
    8181} while( 0 )
     82#define BULK_CONV16( _ptr, _num ) do { \
     83        short  _cnt = _num;\
     84        short* _iptr = (short*)_ptr;\
     85        for( int _l = 0; _l<_cnt; ++_l )\
     86                _iptr[_l] = SDL_SwapLE16( _iptr[_l] );\
     87} while( 0 )
    8288#else
    8389#define BULK_CONV( _ptr, _num )
     90#define BULK_CONV16( _ptr, _num )
    8491#endif 
    8592
     
    111118  this->setAnim(STAND);
    112119
    113   this->debug();
     120  //this->debug();
    114121
    115122    //write the modelinfo information
     
    381388  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
    382389  PRINTF(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
    383   PRINTF(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
    384   PRINTF(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
     390  PRINTF(0)("=  Skin FileName:\t%s\n",
     391                this->data->skinFileName.c_str());
     392  PRINTF(0)("=  Size in Memory:\t%i Bytes\n",
     393                this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
    385394  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
    386395  PRINTF(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
     
    491500  fseek(pFile, this->header->offsetFrames, SEEK_SET);
    492501  fread(buffer, this->header->frameSize, this->numFrames, pFile);
    493         BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
     502        //BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
    494503  /* read opengl commands */
    495504  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
     
    500509  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    501510  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);       
    502         BULK_CONV( this->pTriangles, this->numTriangles*(sizeof(sTriangle)/4) );
     511        BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
    503512
    504513  /*  read in texture coordinates */
    505514  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
    506515  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
    507         BULK_CONV( this->pTexCoor, this->numTexCoor*(sizeof(sTexCoor)/4) );
     516        BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 );
    508517
    509518  for(int i = 0; i < this->numFrames; ++i)
    510519    {
    511520      frame = (sFrame*)(buffer + this->header->frameSize * i);
     521                        //Convert the translate and scale Vec3D if needed.
     522                        BULK_CONV( frame, 6 );
     523                        BULK_CONV( frame->pVertices, 3 );
    512524      pVertex = this->pVertices + this->numVertices  * i;
    513525      pNormals = this->pLightNormals + this->numVertices * i;
Note: See TracChangeset for help on using the changeset viewer.