Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2006, 11:49:33 PM (18 years ago)
Author:
patrick
Message:

bsp: data reading algorithm completed. almost impossible, that it runs on first try…

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

    r8420 r8423  
    335335int MD3Data::readMeshVertices(FILE* pFile, int fileOffset, int mesh)
    336336{
    337   return 0;
    338 }
    339 
    340 }
    341 
    342 
    343 
    344 
    345 
    346 
    347 
     337  // reserver memory for the vertex informations
     338  this->meshes[mesh]->meshFrames = new sVec3D[this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum];
     339  this->meshes[mesh]->normals = new MD3Normal[this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum];
     340
     341  // read out the compressed data
     342  MD3VertexCompressed* vc = new MD3VertexCompressed[this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum];
     343  fread(vc, 1, sizeof(MD3VertexCompressed), pFile);
     344
     345  int index;
     346
     347  for( int i = 0; i < this->meshes[mesh]->header->meshFrameNum; i++)
     348  {
     349    for( int j = 0; j < this->meshes[mesh]->header->vertexNum; j++)
     350    {
     351      index = i * this->meshes[mesh]->header->meshFrameNum + j;
     352      this->meshes[mesh]->meshFrames[index][0] = (float)vc[index].vector[0] / 64.0f;
     353      this->meshes[mesh]->meshFrames[index][1] = (float)vc[index].vector[1] / 64.0f;
     354      this->meshes[mesh]->meshFrames[index][2] = (float)vc[index].vector[2] / 64.0f;
     355
     356      this->meshes[mesh]->normals[index].vertexNormal[0] = vc[index].vertexNormal[0];
     357      this->meshes[mesh]->normals[index].vertexNormal[1] = vc[index].vertexNormal[1];
     358    }
     359  }
     360
     361  // delete the temp memory again
     362  delete [] vc;
     363
     364  return this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum * sizeof(MD3VertexCompressed);
     365}
     366
     367}
     368
     369
     370
     371
     372
     373
     374
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h

    r8420 r8423  
    5353  };
    5454
     55  typedef struct MD3Normal {
     56    int     vertexNormal[2];                //!< vertex normals
     57  };
     58
     59  typedef struct MD3VertexCompressed {
     60    short   vector[3];                      //!< compressed vertex information
     61    unsigned char vertexNormal[2];          //!< vertex normals compressed
     62  };
     63
     64
    5565
    5666class MD3Mesh
     
    6777    MD3Triangle*       triangles;               //!< indices into mesh frames and texture coord arrays
    6878    MD3TexVecs*        texVecs;                 //!< tex vecs coordinates
     79    sVec3D*            meshFrames;              //!< mesh frames
     80    MD3Normal*         normals;                 //!< 3d array of normals with spherical coordinates giving the dir of the vertex normal
    6981
    70     float*             textureCoords;           //!< U/V textures coordinates of vertices
    71     Vector             meshFrames;              //!< mesh frames
    7282};
    7383
Note: See TracChangeset for help on using the changeset viewer.