Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4227 in orxonox.OLD for orxonox/branches/md2_loader/src/lib/graphics


Ignore:
Timestamp:
May 19, 2005, 10:50:00 PM (19 years ago)
Author:
patrick
Message:

orxonox/branches/md2_model: flushing work state

Location:
orxonox/branches/md2_loader/src/lib/graphics/importer
Files:
2 edited

Legend:

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

    r4226 r4227  
    532532{
    533533  FILE *pFile;                            //file stream
    534   tMd2Header header;
     534  //tMd2Header header;
    535535  char* buffer;                           //buffer for frame data
    536536  sFrame* frame;                          //temp frame
     
    544544      return false;
    545545    }
    546   fread(&header, 1, sizeof(tMd2Header), pFile);
     546  fread(header, 1, sizeof(tMd2Header), pFile);
    547547  /* check for the header version: make sure its a md2 file :) */
    548548  if( unlikely(header.version != MD2_VERSION) && unlikely(header.ident != MD2_IDENT))
     
    553553
    554554  /* got the data: map it to locals */
    555   this->numFrames = header.numFrames;
    556   this->numVertices = header.numVertices;
    557   this->numTriangles = header.numTriangles;
    558   this->numGLCommands = header.numGlCommands;
     555  this->numFrames = this->header->numFrames;
     556  this->numVertices = this->header->numVertices;
     557  this->numTriangles = this->header->numTriangles;
     558  this->numGLCommands = this->header->numGlCommands;
    559559  /* allocate memory for the data storage */
    560560  this->pVertices = new sVec3D[this->numVertices * this->numFrames];
    561561  this->pGLCommands = new int[this->numGLCommands];
    562562  this->pLightNormals = new int[this->numVertices * this->numFrames];
    563   buffer = new char[this->numFrames * header.frameSize];
     563  buffer = new char[this->numFrames * this->header->frameSize];
    564564
    565565  /* read frame data from the file to a temp buffer */
    566   fseek(pFile, header.offsetFrames, SEEK_SET);
    567   fread(buffer, header.frameSize, this->numFrames, pFile);
     566  fseek(pFile, this->header->offsetFrames, SEEK_SET);
     567  fread(buffer, this->header->frameSize, this->numFrames, pFile);
    568568  /* read opengl commands */
    569   fseek(pFile, header.offsetGlCommands, SEEK_SET);
     569  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
    570570  fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
    571571
     
    574574      /*
    575575      faster but evt. buggy
    576       frame = (sFrame*)(buffer + header.frameSize * i);
     576      frame = (sFrame*)(buffer + this->header->frameSize * i);
    577577      pVertex = this->pVertices + this->numVertices  * i;
    578578      pNormals = this->pLightNormals + this->numVertices * i;
    579579      */
    580       frame = (sFrame *)&buffer[header.frameSize * i];
     580      frame = (sFrame *)&buffer[this->header->frameSize * i];
    581581      pVertex = &this->pVertices[this->numVertices * i];
    582582      pNormals = &this->pLightNormals[this->numVertices * i];
     
    645645
    646646        //printf("  pVertices %f, %f, %f\n", pVertices[i][0], pVertices[i][1], pVertices[i][2]);
    647         //printf("  list:     %f, %f, %f \n", verticesList[i][0], verticesList[i][1], verticesList[i][2]);     
     647        printf("  list:     %f, %f, %f \n", verticesList[i][0], verticesList[i][1], verticesList[i][2]);     
    648648      }
    649649}
     
    792792}
    793793
     794
     795void MD2Model2::debug()
     796{
     797  PRINT(0)("==========================| MD2Model2::debug() |===");
     798  PRINT(0)("= Model Name: %s", this->);
     799  PRINT(0)(" Position:      %f/%f/%f\n", this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]);
     800  PRINT(0)(" DiffuseColor:  %f/%f/%f\n", this->diffuseColor[0], this->diffuseColor[1], this->diffuseColor[2]);
     801  PRINT(0)(" SpecularColor: %f/%f/%f\n", this->specularColor[0], this->specularColor[1], this->specularColor[2]);
     802  PRINT(0)(" Attenuation: constant=%f linear=%f quadratic=%f\n", this->constantAttenuation, this->linearAttenuation, this->quadraticAttenuation);
     803}
     804
     805
     806  int ident;                            //!< This is used to identify the file
     807   int version;                         //!< The version number of the file (Must be 8)
     808   
     809   int skinWidth;                       //!< The skin width in pixels
     810   int skinHeight;                      //!< The skin height in pixels
     811   int frameSize;                       //!< The size in bytes the frames are
     812   
     813   int numSkins;                        //!< The number of skins associated with the model
     814   int numVertices;                     //!< The number of vertices (constant for each frame)
     815   int numTexCoords;                    //!< The number of texture coordinates
     816   int numTriangles;                    //!< The number of faces (polygons)
     817   int numGlCommands;                   //!< The number of gl commands
     818   int numFrames;                       //!< The number of animation frames
     819   
     820   int offsetSkins;                     //!< The offset in the file for the skin data
     821   int offsetTexCoords;                 //!< The offset in the file for the texture data
     822   int offsetTriangles;                 //!< The offset in the file for the face data
     823   int offsetFrames;                    //!< The offset in the file for the frames data
     824   int offsetGlCommands;                //!< The offset in the file for the gl commands data
     825   int offsetEnd;                       //!< The end of the file offset
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h

    r4224 r4227  
    174174
    175175
    176 
    177 //! This is a MD2 Model class
    178 class MD2Model2 : public AbstractModel {
    179 
    180 public:
    181   MD2Model2();
    182   virtual ~MD2Model2();
    183  
    184   bool loadModel(const char* filename);
    185   bool loadSkin(const char* filename);
    186  
    187   void drawFrame(int frame);
    188   void draw();
    189   void draw2();
    190  
    191   void setAnim(int type);
    192   void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
    193 
    194   void tick(float dtS);
    195 
    196 
    197 private:
    198   void animate(); 
    199   void processLighting();
    200   void interpolate(sVec3D* verticesList);
    201   void renderFrame();
    202 
    203  public:
    204   /* these variables are static, because they are all the same for every model */
    205   static sVec3D anorms[NUM_VERTEX_NORMALS];
    206   static float anormsDots[SHADEDOT_QUANT][256];
    207   static sAnim animationList[21];
    208 
    209  private:
    210   int numFrames;
    211   int numVertices;
    212   int numTriangles;
    213   int numGLCommands;
    214 
    215   sVec3D* pVertices;
    216   int* pGLCommands;
    217   int* pLightNormals;
    218 
    219   unsigned int textureID;
    220   Material* material;
    221   sAnimState animationState;
    222   float scaleFactor;
    223   //tMd2Header* header;
    224 };
    225 
    226 
    227176//! A class that handles all of the loading code
    228177class MD2Loader : public BaseObject {
     
    250199
    251200
     201//! This is a MD2 Model class
     202class MD2Model2 : public AbstractModel {
     203
     204public:
     205  MD2Model2();
     206  virtual ~MD2Model2();
     207 
     208  bool loadModel(const char* filename);
     209  bool loadSkin(const char* filename);
     210 
     211  void drawFrame(int frame);
     212  void draw();
     213  void draw2();
     214 
     215  void setAnim(int type);
     216  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
     217
     218  void tick(float dtS);
     219  void debug();
     220
     221
     222private:
     223  void animate(); 
     224  void processLighting();
     225  void interpolate(sVec3D* verticesList);
     226  void renderFrame();
     227
     228 public:
     229  /* these variables are static, because they are all the same for every model */
     230  static sVec3D anorms[NUM_VERTEX_NORMALS];
     231  static float anormsDots[SHADEDOT_QUANT][256];
     232  static sAnim animationList[21];
     233
     234 private:
     235  int numFrames;
     236  int numVertices;
     237  int numTriangles;
     238  int numGLCommands;
     239
     240  sVec3D* pVertices;
     241  int* pGLCommands;
     242  int* pLightNormals;
     243
     244  unsigned int textureID;
     245  Material* material;
     246  sAnimState animationState;
     247  float scaleFactor;
     248  tMd2Header* header;
     249};
     250
     251
     252
     253
     254
    252255#endif /* _MD2MODEL_H */
Note: See TracChangeset for help on using the changeset viewer.