Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8372 in orxonox.OLD for branches/bsp_model/src/lib/graphics/importer


Ignore:
Timestamp:
Jun 14, 2006, 11:28:29 AM (18 years ago)
Author:
patrick
Message:

bsp: started loading md3 mesh data, the last of the data structures

Location:
branches/bsp_model/src/lib/graphics/importer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc

    r8371 r8372  
    1919#include "md3_bone_frame.h"
    2020#include "md3_tag.h"
     21#include "md3_mesh.h"
    2122
    2223
     
    118119    }
    119120
    120 #if 0
    121   this->fileName =fileName;
    122   /* got the data: map it to locals */
    123   this->numFrames = this->header->numFrames;
    124   this->numVertices = this->header->numVertices;
    125   this->numTriangles = this->header->numTriangles;
    126   this->numGLCommands = this->header->numGlCommands;
    127   this->numTexCoor = this->header->numTexCoords;
    128   /* allocate memory for the data storage */
    129   this->pVertices = new sVec3D[this->numVertices * this->numFrames];
    130   this->pGLCommands = new int[this->numGLCommands];
    131   this->pLightNormals = new int[this->numVertices * this->numFrames];
    132   this->pTriangles = new sTriangle[this->numTriangles];
    133   this->pTexCoor = new sTexCoor[this->numTexCoor];
    134   buffer = new char[this->numFrames * this->header->frameSize];
    135 
    136 
    137   /* read frame data from the file to a temp buffer */
    138   fseek(pFile, this->header->offsetFrames, SEEK_SET);
    139   fread(buffer, this->header->frameSize, this->numFrames, pFile);
    140   /* read opengl commands */
    141   fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
    142   fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
    143   /* triangle list */
    144   fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    145   fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
    146   /*  read in texture coordinates */
    147   fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
    148   fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
    149 
    150 
    151   for(int i = 0; i < this->numFrames; ++i)
    152     {
    153       frame = (sFrame*)(buffer + this->header->frameSize * i);
    154       pVertex = this->pVertices + this->numVertices  * i;
    155       pNormals = this->pLightNormals + this->numVertices * i;
    156 
    157       for(int j = 0; j < this->numVertices; ++j)
    158         {
    159           /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
    160            pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
    161            pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
    162            pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
    163 
    164           //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
    165 
    166           pNormals[j] = frame->pVertices[j].lightNormalIndex;
    167         }
    168     }
    169     PRINTF(4)("Finished loading the md2 file\n");
    170 #endif
    171 
    172   //delete [] buffer;
    173121  fclose(pFile);
    174122
     
    240188    MD3BoneFrameData* md = new MD3BoneFrameData;
    241189    fread(md, 1, sizeof(MD3BoneFrameData), pFile);
     190    this->boneFrames[i]->data = md;
    242191  }
    243192
     
    262211      MD3TagData* md = new MD3TagData;
    263212      fread(md, 1, sizeof(MD3TagData), pFile);
     213      this->boneFrames[i]->tags[j]->data = md;
    264214    }
    265215  }
     
    274224int MD3Data::readMeshes(FILE* pFile, int fileOffset)
    275225{
     226  this->meshes = new MD3Mesh*[this->header->meshNum];
     227
     228  for( int i = 0; i < this->header->meshNum; i++)
     229  {
     230    this->meshes[i] = new MD3Mesh();
     231
     232  }
    276233  return 0;
    277234}
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h

    r8357 r8372  
    110110
    111111  MD3BoneFrame**      boneFrames;        //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame
    112   MD3Mesh*            meshes;            //!< array of meshes in the model. each containing the mesh for each of the animation
     112  MD3Mesh**           meshes;            //!< array of meshes in the model. each containing the mesh for each of the animation
    113113
    114114  int                 parentTagIndex;    //!< tag index
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.cc

    r8351 r8372  
    2424 *  md3 mesh constructor
    2525 */
    26 MD3Mesh::MD3Mesh(FILE *pFile, int dataOffset)
     26MD3Mesh::MD3Mesh()
    2727{
    2828}
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h

    r8351 r8372  
    2323{
    2424  public:
    25     MD3Mesh(FILE *pFile, int dataOffset);
     25    MD3Mesh();
    2626    virtual ~MD3Mesh();
    2727
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_tag.h

    r8359 r8372  
    3030
    3131
    32   private:
     32  public:
    3333    std::string               name;                   //!< name of tag as its usualy called in the md3 file
    3434    Vector                    position;               //!< the position of the tag reltive to the models containing that tag
  • branches/bsp_model/src/lib/graphics/importer/md_model_structure.h

    r8352 r8372  
    22 * @file md_model_structure.h
    33 */
     4
     5
     6
     7#ifndef _MD3_MODEL_STRUCTURE_H
     8#define _MD3_MODEL_STRUCTURE_H
    49
    510
     
    8186} sAnimState;
    8287
     88#endif /* _MD3_MODEL_STRUCTURE_H */
Note: See TracChangeset for help on using the changeset viewer.