Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
May 6, 2005, 12:23:14 PM (20 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: implemented importMD2 header function

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

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/importer/abstract_model.h

    r4078 r4079  
    2525#include "base_object.h"
    2626
     27template<class T> class tList;
    2728
    2829
     
    9293        int currentAnim;                                        // The current index into pAnimations list (NEW)
    9394        int currentFrame;                                       // The current frame of the current animation (NEW)
    94         //vector<tAnimationInfo> pAnimations; // The list of animations (NEW)
    95         //vector<tMaterialInfo> pMaterials;     // The list of material information (Textures and colors)
    96         //vector<t3DObject> pObject;                    // The object list for our model
     95        tList<tAnimationInfo>* animationList; // The list of animations (NEW)
     96        tList<tMaterialInfo>* materialList;     // The list of material information (Textures and colors)
     97        tList<t3DObject>* objectList;                   // The object list for our model
    9798};
    9899
     
    103104
    104105 public:
    105   AbstractModel();
    106   virtual ~AbstractModel();
    107 
    108 
    109  private:
    110 
     106  AbstractModel() {}
     107  virtual ~AbstractModel() {}
    111108};
    112109
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc

    r4078 r4079  
    1313*/
    1414
    15 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
     15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
    1616
    1717#include "md2Model.h"
     18
     19//#include <stdio.h>
     20//#include <stdlib.h>
     21//#include <string>
     22#include <fstream>
    1823
    1924
     
    7782        \param texture name to load
    7883*/
    79 bool MD2Loader::importMD2(t3DModel *pModel, char *strFileName, char *strTexture)
    80 {}
     84bool MD2Loader::importMD2(t3DModel *pModel, char *fileName, char *textureName)
     85{
     86        char strMessage[255] = {0};
     87
     88        this->pFile = fopen(fileName, "rb");
     89        if( unlikely(!pFile))
     90        {
     91                PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
     92                return false;
     93        }
     94        fread(&this->header, 1, sizeof(tMd2Header), pFile);
     95        /* check for the header version: make sure its a md2 file :) */
     96        if( likely(this->header.version != 8))
     97        {
     98                PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName);
     99                return false;
     100        }
     101       
     102        this->readMD2Data();
     103        this->convertDataStructures(pModel);
     104
     105        if( likely((int)textureName))
     106        {
     107                tMaterialInfo textureInfo;
     108                strcpy(textureInfo.strFile, textureName);
     109                /* since there is only one texture for a .Md2 file, the ID is always 0 */
     110                textureInfo.texureId = 0;
     111                textureInfo.uTile = 1;
     112                /* we only have 1 material for a model */
     113                pModel->numOfMaterials = 1;
     114                //pModel->materialList.add(texture);
     115        }
     116       
     117        this->cleanUp();
     118        return true;
     119}
    81120
    82121/**
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h

    r4078 r4079  
    135135  virtual ~MD2Loader();
    136136 
    137   bool importMD2(t3DModel *pModel, char *strFileName, char *strTexture);
     137  bool importMD2(t3DModel *pModel, char *fileName, char *texture);
    138138
    139139private:
Note: See TracChangeset for help on using the changeset viewer.