Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8354 in orxonox.OLD


Ignore:
Timestamp:
Jun 14, 2006, 1:41:58 AM (18 years ago)
Author:
patrick
Message:

bsp: outputting the file informations and checking for valid header informations

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

Legend:

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

    r8353 r8354  
    4747  this->fileName = "";
    4848  this->skinFileName = "";
     49
     50
    4951  this->loadModel(modelFileName);
    50   this->loadSkin(skinFileName);
     52//   this->loadSkin(skinFileName);
    5153}
    5254
     
    7880  FILE *pFile;                            //file stream
    7981//  char* buffer;                           //buffer for frame data
     82  int fileOffset = 0;                     // file data offset
    8083
    8184
     
    8588    return false;
    8689
     90  PRINTF(0)("opening file: %s\n", fileName.c_str());
    8791  pFile = fopen(fileName.c_str(), "rb");
    8892  if( unlikely(!pFile))
     
    9397  this->header = new MD3Header;
    9498  fread(this->header, 1, sizeof(MD3Header), pFile);
     99  fileOffset += sizeof(MD3Header);
    95100  /* check for the header version: make sure its a md2 file :) */
    96   if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
     101  if( unlikely(this->header->version != MD3_VERSION) && unlikely(this->header->ident != MD3_IDENT))
    97102    {
    98103      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
     
    100105    }
    101106
    102 
     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);
     120
     121
     122    // check if the filesize is correct
     123    if( this->header->fileSize > this->header->tagStart &&
     124        this->header->fileSize >= this->header->meshStart)
     125    {
     126      bool bBoneFrames, bTags, bMeshes;
     127      bBoneFrames = ( this->header->boneFrameNum == 0);
     128      bTags = ( this->header->tagNum == 0);
     129      bMeshes = ( this->header->meshNum == 0);
     130
     131      // read different parts of the model in correct order
     132      while( !(bBoneFrames && bTags && bMeshes))
     133      {
     134        if( fileOffset == this->header->boneFrameStart && !bBoneFrames)
     135        {}
     136        else if( fileOffset == this->header->tagStart && !bTags)
     137        {}
     138        else if( fileOffset == this->header->meshStart && !bMeshes)
     139        {}
     140      }
     141
     142    }
    103143
    104144#if 0
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h

    r8353 r8354  
    2727
    2828//! These are the needed defines for the max values when loading .MD2 files
    29 #define MD2_IDENT                       (('2'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md2 identifier tag in the bin file
    30 #define MD2_VERSION                     8                                        //!< the md2 version in the header
     29#define MD3_IDENT                       (('4'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md2 identifier tag in the bin file
     30#define MD3_VERSION                     15                                       //!< the md2 version in the header
    3131#define MD2_MAX_TRIANGLES               4096                                     //!< maximal triangles count
    3232#define MD2_MAX_VERTICES                2048                                     //!< maximal vertices count
     
    5858   int meshNum;                         //!< number of mesh
    5959   int maxTexNum;                       //!< number of texture
     60
    6061   int boneFrameStart;                  //!< start of bone frames
    6162   int tagStart;                        //!< start of the tag
    6263   int meshStart;                       //!< mesh start
     64
    6365   int fileSize;                        //!< file size
    6466};
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc

    r8353 r8354  
    1717#include "md3_model.h"
    1818
     19#include "md3_data.h"
    1920
    2021
     
    2728  MD3Model::MD3Model(std::string filename, float scaling)
    2829  {
    29 
     30    this->md3Data = new MD3Data(filename, filename, scaling);
    3031  }
    3132
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8353 r8354  
    1313
    1414
    15 class MD3BoneFrame;
    16 class MD3Mesh;
    17 
    18 
    1915namespace md3
    2016{
     17
     18  class MD3BoneFrame;
     19  class MD3Mesh;
     20  class MD3Data;
    2121
    2222class MD3Model : public Model
     
    3030
    3131  private:
     32    MD3Data*            md3Data;           //!< reference to the md3 model data
     33
    3234    std::string         filename;          //!< the name of the file as recorded in the .md3 file
    3335    std::string         loadFilename;      //!< filename of the actual file from which data was loaded
Note: See TracChangeset for help on using the changeset viewer.