Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8357 in orxonox.OLD


Ignore:
Timestamp:
Jun 14, 2006, 2:22:49 AM (18 years ago)
Author:
patrick
Message:

bsp: more data reading again

Location:
branches/bsp_model/src/lib/graphics/importer/md3
Files:
5 edited

Legend:

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

    r8348 r8357  
    1919
    2020
    21 using namespace std;
     21namespace md3
     22{
     23
     24
     25  /**
     26   * create a MD3BoneFrame object with the data coming from the specified input stream
     27   */
     28  MD3BoneFrame::MD3BoneFrame(int tagNum /*, DataInput din*/)
     29  { /* loadBoneFrame(this, din) */ }
     30
     31
     32  MD3BoneFrame::MD3BoneFrame(/*int tagNum*/)
     33  { /* this->tags = new MD3Tag[tagNum] */ }
     34
     35
     36  MD3BoneFrame::~MD3BoneFrame()
     37  {}
     38
     39
     40
     41};
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.h

    r8348 r8357  
    1313#include <string>
    1414
     15namespace md3
     16{
    1517
    1618class MD3Tag;
    17 
    1819
    1920class MD3BoneFrame
     
    2122  public:
    2223    /** create a MD3BoneFrame object with the data coming from the specified input stream */
    23     MD3BoneFrame(int tagNum /*, DataInput din*/) { /* loadBoneFrame(this, din) */ }
    24     MD3BoneFrame(/*int tagNum*/) { /* this->tags = new MD3Tag[tagNum] */ }
     24    MD3BoneFrame(int tagNum /*, DataInput din*/);
     25    MD3BoneFrame(/*int tagNum*/);
    2526    virtual ~MD3BoneFrame();
    2627
     
    3940};
    4041
     42}
    4143
    4244#endif /* _MD3_ANIMATION_H */
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc

    r8355 r8357  
    1717#include "md3_data.h"
    1818
     19#include "md3_bone_frame.h"
     20
    1921
    2022namespace md3
     
    3032MD3Data::MD3Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
    3133{
    32   scale *= 0.1f;
    33 
    34   this->pVertices = NULL;
    35   this->pGLCommands = NULL;
    36   this->pLightNormals = NULL;
    37   this->pTexCoor = NULL;
    38 
    39   this->numFrames = 0;
    40   this->numVertices = 0;
    41   this->numGLCommands = 0;
    42   this->numTexCoor = 0;
    43 
    44 //   this->scaleFactor = 1.0f;
    45   this->scaleFactor = scale;
    46 
    47   this->fileName = "";
    48   this->skinFileName = "";
     34
    4935
    5036
     
    6248{
    6349  delete this->header;
    64 
    65   delete [] this->pVertices;
    66   delete [] this->pGLCommands;
    67   delete [] this->pLightNormals;
    68   delete [] this->pTexCoor;
    6950}
    7051
     
    9576      return false;
    9677    }
    97   this->header = new MD3Header;
    98   fread(this->header, 1, sizeof(MD3Header), pFile);
    99   fileOffset += sizeof(MD3Header);
     78  fileOffset += this->readHeader(pFile, fileOffset);
    10079  /* check for the header version: make sure its a md2 file :) */
    10180  if( unlikely(this->header->version != MD3_VERSION) && unlikely(this->header->ident != MD3_IDENT))
     
    10483      return false;
    10584    }
    106 
    107     //header debug:
    108     PRINTF(0)("MD3 Header debug section======================================\n");
    109     printf("ident: %i\n", this->header->ident);
    110     printf("version: %i\n", this->header->version);
    111     printf("filename: %s\n", this->header->filename);
    112     printf("boneFrameNum: %i\n", this->header->boneFrameNum);
    113     printf("tag number: %i\n", this->header->tagNum);
    114     printf("mesh number: %i\n", this->header->meshNum);
    115     printf("max tex num: %i\n", this->header->maxTexNum);
    116     printf("bone frame start: %i\n", this->header->boneFrameStart);
    117     printf("tag start: %i\n", this->header->tagStart);
    118     printf("mesh start: %i\n", this->header->meshStart);
    119     printf("fileSize: %i\n", this->header->fileSize);
    12085
    12186
     
    13297      while( !(bBoneFrames && bTags && bMeshes))
    13398      {
     99        printf("while\n");
    134100        if( fileOffset == this->header->boneFrameStart && !bBoneFrames)
    135101        {
     
    217183bool MD3Data::loadSkin(const std::string& fileName)
    218184{
    219   if( fileName.empty())
    220     {
    221       this->skinFileName = "";
    222       return false;
    223     }
    224 
    225   this->skinFileName = fileName;
    226 
    227   this->material.setName("md2ModelMaterial");
    228   this->material.setDiffuseMap(fileName);
    229   this->material.setIllum(3);
    230   this->material.setAmbient(1.0, 1.0, 1.0);
     185//   if( fileName.empty())
     186//     {
     187//       this->skinFileName = "";
     188//       return false;
     189//     }
     190//
     191//   this->skinFileName = fileName;
     192//
     193//   this->material.setName("md2ModelMaterial");
     194//   this->material.setDiffuseMap(fileName);
     195//   this->material.setIllum(3);
     196//   this->material.setAmbient(1.0, 1.0, 1.0);
    231197
    232198  return true;
     
    239205int MD3Data::readHeader(FILE* pFile, int fileOffset)
    240206{
     207  this->header = new MD3Header;
     208  fread(this->header, 1, sizeof(MD3Header), pFile);
     209
     210    //header debug:
     211  PRINTF(0)("MD3 Header debug section======================================\n");
     212  printf("ident: %i\n", this->header->ident);
     213  printf("version: %i\n", this->header->version);
     214  printf("filename: %s\n", this->header->filename);
     215  printf("boneFrameNum: %i\n", this->header->boneFrameNum);
     216  printf("tag number: %i\n", this->header->tagNum);
     217  printf("mesh number: %i\n", this->header->meshNum);
     218  printf("max tex num: %i\n", this->header->maxTexNum);
     219  printf("bone frame start: %i\n", this->header->boneFrameStart);
     220  printf("tag start: %i\n", this->header->tagStart);
     221  printf("mesh start: %i\n", this->header->meshStart);
     222  printf("fileSize: %i\n", this->header->fileSize);
     223
     224
     225  return sizeof(MD3Header);
     226}
     227
     228
     229/**
     230 * read bone frames
     231 */
     232int MD3Data::readBoneFrames(FILE* pFile, int fileOffset)
     233{
     234  this->boneFrames = new MD3BoneFrame*[this->header->boneFrameNum];
     235
     236  for( int i = 0; i < this->header->boneFrameNum; i++)
     237    this->boneFrames[i] = new MD3BoneFrame(i);
     238
    241239  return 0;
    242240}
     
    244242
    245243/**
    246  * read bone frames
    247  */
    248 int MD3Data::readBoneFrames(FILE* pFile, int fileOffset)
     244 * read the tags
     245 */
     246int MD3Data::readTags(FILE* pFile, int fileOffset)
    249247{
    250248  return 0;
     
    253251
    254252/**
    255  * read the tags
    256  */
    257 int MD3Data::readTags(FILE* pFile, int fileOffset)
     253 * read meshes
     254 */
     255int MD3Data::readMeshes(FILE* pFile, int fileOffset)
    258256{
    259257  return 0;
    260258}
    261259
    262 
    263 /**
    264  * read meshes
    265  */
    266 int MD3Data::readMeshes(FILE* pFile, int fileOffset)
    267 {
    268   return 0;
    269 }
    270 
    271 }
    272 
     260}
     261
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h

    r8355 r8357  
    4646{
    4747
     48  class MD3BoneFrame;
     49  class MD3Mesh;
     50
    4851//! This holds the header information that is read in at the beginning of the file: id software definition
    4952struct MD3Header
     
    8790
    8891 public:
    89   int                numFrames;             //!< number of frames
    90   int                numVertices;           //!< number of vertices
    91   int                numTriangles;          //!< number of triangles
    92   int                numTexCoor;            //!< number of texture coordinates
    93   int                numGLCommands;         //!< number of gl commands in the glList (tells how to draw)
    94   std::string        fileName;              //!< file name of the model File
    95   std::string        skinFileName;          //!< file name of the skin file
    96   MD3Header*         header;                //!< the header file
    9792
    98   sVec3D*            pVertices;             //!< pointer to the vertices data block
    99   sTriangle*         pTriangles;            //!< pointer to the triangles data
    100   sTexCoor*          pTexCoor;              //!< pointer to the texture coordinate data
    101   int*               pGLCommands;           //!< pointer to the gllist data block
    102   int*               pLightNormals;         //!< pointer to the light normals
     93  MD3Header*          header;            //!< the header file
    10394
    104   Material           material;              //!< pointer to the material
    105   float              scaleFactor;           //!< the scale factor of the model, (global)
     95  std::string         filename;          //!< the name of the file as recorded in the .md3 file
     96  std::string         loadFilename;      //!< filename of the actual file from which data was loaded
     97
     98  int                 boneFrameNum;      //!< number of anumation key fames in the models
     99  int                 tagNum;            //!< number of tags
     100  int                 meshNum;           //!< number of meshes
     101
     102  int                 maxTextureNum;     //!< maximum number of unique used in an md3 file
     103  int                 boneFrameStart;    //!< starting position of bone frame data structures
     104  int                 tagStart;          //!< starting position of tag-structures
     105
     106  int                 meshStart;         //!< starting position of mesh structures
     107
     108  int                 fileSize;          //!< file size
     109
     110
     111  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
     113
     114  int                 parentTagIndex;    //!< tag index
     115
     116  //MD3Model*           parent;            //!< reference to the MD3Model
     117
     118
    106119};
    107120
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8354 r8357  
    1616{
    1717
    18   class MD3BoneFrame;
    19   class MD3Mesh;
    20   class MD3Data;
     18
     19class MD3Data;
    2120
    2221class MD3Model : public Model
     
    2827
    2928
    30 
    3129  private:
    3230    MD3Data*            md3Data;           //!< reference to the md3 model data
     31};
    3332
    34     std::string         filename;          //!< the name of the file as recorded in the .md3 file
    35     std::string         loadFilename;      //!< filename of the actual file from which data was loaded
    36 
    37     int                 boneFrameNum;      //!< number of anumation key fames in the models
    38     int                 tagNum;            //!< number of tags
    39     int                 meshNum;           //!< number of meshes
    40 
    41     int                 maxTextureNum;     //!< maximum number of unique used in an md3 file
    42     int                 boneFrameStart;    //!< starting position of bone frame data structures
    43     int                 tagStart;          //!< starting position of tag-structures
    44 
    45     int                 meshStart;         //!< starting position of mesh structures
    46 
    47     int                 fileSize;          //!< file size
    48 
    49 
    50     MD3BoneFrame*       boneFrames;        //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame
    51     MD3Mesh*            meshes;            //!< array of meshes in the model. each containing the mesh for each of the animation
    52 
    53     int                 parentTagIndex;    //!< tag index
    54     MD3Model*           parent;            //!< reference to the MD3Model
    55 };
    5633}
    5734
Note: See TracChangeset for help on using the changeset viewer.