Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 14, 2006, 6:35:58 PM (18 years ago)
Author:
patrick
Message:

bsp: reading the material/texture informations

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

    r8416 r8418  
    2020#include "md3_tag.h"
    2121#include "md3_mesh.h"
     22
     23#include "material.h"
    2224
    2325
     
    282284
    283285
     286/**
     287 * reading in the mesh triangles
     288 */
    284289int MD3Data::readMeshTriangles(FILE* pFile, int fileOffset, int mesh)
    285290{
    286291  // create the memomry to save the triangles
    287   MD3Triangle* tri = new MD3Triangle[this->meshes[mesh]->header->triangleNum];
    288   fread(tri, 1, sizeof(MD3Triangle), pFile);
     292  this->meshes[mesh]->triangles = new MD3Triangle[this->meshes[mesh]->header->triangleNum];
     293  fread(this->meshes[mesh]->triangles, 1, sizeof(MD3Triangle), pFile);
    289294
    290295  return this->meshes[mesh]->header->triangleNum * sizeof(MD3Triangle);
    291296}
    292297
     298
     299/**
     300 * reading in the mesh textures
     301 */
    293302int MD3Data::readMeshTextures(FILE* pFile, int fileOffset, int mesh)
    294303{
     304  // create the textures
     305  this->meshes[mesh]->material = new Material[this->meshes[mesh]->header->textureNum];
     306
     307  MD3Texture* tex = new MD3Texture[this->meshes[mesh]->header->textureNum];
     308  fread(this->meshes[mesh]->material, 1, sizeof(MD3Texture), pFile);
     309
     310  for( int i = 0; i < this->meshes[mesh]->header->textureNum; i++) {
     311    PRINTF(0)(" texture file: %s\n", tex[i].fileName);
     312    this->meshes[mesh]->material[i].setDiffuseMap(tex[i].fileName);
     313    this->meshes[mesh]->material[i].setAmbient(1, 1, 1);
     314  }
     315
     316  return this->meshes[mesh]->header->textureNum * sizeof(MD3Texture);
     317}
     318
     319
     320/**
     321 * reading in the mesh tex vecs
     322 */
     323int MD3Data::readMeshTexVecs(FILE* pFile, int fileOffset, int mesh)
     324{
    295325  return 0;
    296326}
    297327
    298 int MD3Data::readMeshTexVecs(FILE* pFile, int fileOffset, int mesh)
     328
     329/**
     330 * reading in the mesh vertices
     331 */
     332int MD3Data::readMeshVertices(FILE* pFile, int fileOffset, int mesh)
    299333{
    300334  return 0;
    301335}
    302336
    303 int MD3Data::readMeshVertices(FILE* pFile, int fileOffset, int mesh)
    304 {
    305   return 0;
    306 }
    307 
    308 }
    309 
    310 
    311 
    312 
    313 
    314 
    315 
     337}
     338
     339
     340
     341
     342
     343
     344
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h

    r8416 r8418  
    1616#include "vector.h"
    1717
     18class Material;
     19
    1820
    1921namespace md3
    2022{
    21 
    2223
    2324  typedef struct MD3MeshHeader {
     
    4142
    4243  typedef struct MD3Triangle  {
    43     int  vertexOffset[3];
     44    int  vertexOffset[3];                   //!< the vertex offsets of the triangles in the vertex array
     45  };
     46
     47  typedef struct MD3Texture {
     48    char fileName[68];                      //!< the filename of the texture. path relativly to the model file
    4449  };
    4550
     
    5560    MD3MeshHeader*     header;                  //!< the header of the mesh
    5661
    57     //MD3Texture*      textures;                //!< array of textures of size textureNum
     62    Material*          material;                //!< the material/textures of the models
    5863    MD3Triangle*       triangles;               //!< indices into mesh frames and texture coord arrays
     64
    5965    float*             textureCoords;           //!< U/V textures coordinates of vertices
    6066    Vector             meshFrames;              //!< mesh frames
Note: See TracChangeset for help on using the changeset viewer.