Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3909 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Apr 21, 2005, 12:27:19 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: importer: no more fstream c-style code only

Location:
orxonox/trunk/src/lib/graphics/importer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/framework.cc

    r3657 r3909  
    5858int main(int argc, char *argv[])
    5959{
    60   verbose = 3;
     60  verbose = 4;
    6161
    6262  Uint8* keys; // This variable will be used in the keyboard routine
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r3905 r3909  
    2727
    2828/**
    29    \brief Creates a 3D-Model.
    30 
    31    This only initializes a 3D-Model, but does not cleanup the Faces.
    32 */
    33 Model::Model(void)
    34 {
    35   this->initialize();
    36 }
    37 
    38 /**
    3929   \brief Creates a 3D-Model. and assigns it a Name.
    4030*/
    41 Model::Model(char* modelName)
    42 {
    43   this->initialize();
     31Model::Model(const char* modelName)
     32{
     33  PRINTF(4)("new 3D-Model is being created\n");
     34  this->name = NULL;
    4435  this->setName(modelName);
     36
     37
     38  this->finalized = false;
     39  // setting the start group;
     40  this->firstGroup = new Group;
     41  this->currentGroup = this->firstGroup;
     42  this->groupCount = 0;
     43 
     44  this->initGroup (this->currentGroup);
     45  this->scaleFactor = 1;
     46  this->material = new Material();
     47
     48  this->vertices = new Array();
     49  this->vTexture = new Array();
     50  this->normals = new Array();
     51
    4552}
    4653
     
    169176
    170177/**
    171     \brief initializes the Model.
    172 
    173     This Function initializes all the needed arrays, Lists and clientStates.
    174     It also defines default values.
    175 */
    176 bool Model::initialize (void)
    177 {
    178   PRINTF(4)("new 3D-Model is being created\n");
    179 
    180   this->name = NULL;
    181   this->finalized = false;
    182   // setting the start group;
    183   this->firstGroup = new Group;
    184   this->currentGroup = this->firstGroup;
    185   this->groupCount = 0;
    186  
    187   this->initGroup (this->currentGroup);
    188   this->scaleFactor = 1;
    189   this->material = new Material();
    190 
    191   this->vertices = new Array();
    192   this->vTexture = new Array();
    193   this->normals = new Array();
    194 
    195   return true;
    196 }
    197 
    198 /**
    199178   \brief sets a name to the Model
    200179   \param name The name to set to this Model
     
    204183  if (this->name)
    205184    delete this->name;
    206   this->name = new char[strlen(name)+1];
    207   strcpy(this->name, name);
     185  if (name)
     186    {
     187      this->name = new char[strlen(name)+1];
     188      strcpy(this->name, name);
     189    }
     190  else
     191    this->name = NULL;
    208192}
    209193/**
     
    348332   If a vertex line is found this function will inject it into the vertex-Array
    349333*/
    350 bool Model::addVertex (char* vertexString)
     334bool Model::addVertex (const char* vertexString)
    351335{
    352336  float subbuffer1;
     
    379363   If a face line is found this function will add it to the glList.
    380364*/
    381 bool Model::addFace (char* faceString)
     365bool Model::addFace (const char* faceString)
    382366{
    383367  if (this->currentGroup->faceCount >0)
     
    477461   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    478462*/
    479 bool Model::addVertexNormal (char* normalString)
     463bool Model::addVertexNormal (const char* normalString)
    480464{
    481465  float subbuffer1;
     
    509493   this function will inject it into the vertexTexture-Array
    510494*/
    511 bool Model::addVertexTexture (char* vTextureString)
     495bool Model::addVertexTexture (const char* vTextureString)
    512496{
    513497  float subbuffer1;
     
    540524bool Model::addUseMtl (const char* matString)
    541525{
    542   /*
    543   if (!this->mtlFileName)
    544     {
    545       PRINTF(4)("Not using new defined material, because no mtlFile found yet\n");
    546       return false;
    547     }
    548   */     
    549526  if (this->currentGroup->faceCount > 0)
    550527    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3895 r3909  
    2929{
    3030 public:
    31   Model(void);
    32   Model(char* modelName);
     31  Model(const char* modelName = NULL);
    3332  virtual ~Model(void);
    3433
     
    9291  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
    9392
    94   bool initialize(void);
    9593  bool initGroup(Group* group);
    9694  bool initFace (Face* face);
     
    102100 public:
    103101  bool addGroup(const char* groupString);
    104   bool addVertex(char* vertexString);
     102  bool addVertex(const char* vertexString);
    105103  bool addVertex(float x, float y, float z);
    106   bool addFace(char* faceString);
     104  bool addFace(const char* faceString);
    107105  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
    108   bool addVertexNormal(char* normalString);
     106  bool addVertexNormal(const char* normalString);
    109107  bool addVertexNormal(float x, float y, float z);
    110   bool addVertexTexture(char* vTextureString);
     108  bool addVertexTexture(const char* vTextureString);
    111109  bool addVertexTexture(float u, float v);
    112110  bool addUseMtl(const char* mtlString);
  • orxonox/trunk/src/lib/graphics/importer/objModel.cc

    r3908 r3909  
    2323
    2424#define PARSELINELENGTH 8192
    25 
    26 #include <fstream>
    2725
    2826#include "debug.h"
     
    6967  this->objFileName = NULL;
    7068  this->mtlFileName = NULL;
    71 
    72   this->initialize();
    7369}
    7470
     
    135131  char readLine[PARSELINELENGTH];
    136132  char buffer[PARSELINELENGTH];
    137   int i = 0;
    138133  while(fgets(readLine, PARSELINELENGTH, stream))
    139134    {
    140135      strcpy(buffer, readLine);
    141       i++;
    142136      // case vertice
    143137      if (!strncmp(buffer, "v ", 2))
     
    206200 
    207201
    208   PRINTF(4)("Opening mtlFile: %s\n", fileName);
    209 
    210   ifstream* MTL_FILE = new ifstream (fileName);
    211   if (MTL_FILE->fail())
    212     {
    213       PRINTF(2)("unable to open file: %s\n", fileName);
    214       MTL_FILE->close();
    215       delete []fileName;
    216       delete MTL_FILE;
     202  FILE* stream;
     203  if( (stream = fopen (fileName, "r")) == NULL)
     204    {
     205      printf("IniParser could not open %s\n", fileName);
    217206      return false;
    218207    }
    219   char buffer[500];
     208
     209  char readLine[PARSELINELENGTH];
     210  char buffer[PARSELINELENGTH];
    220211  Material* tmpMat = material;
    221   while(!MTL_FILE->eof())
    222     {
    223       MTL_FILE->getline(buffer, 500);
     212  while(fgets(readLine, PARSELINELENGTH, stream))
     213    {
    224214      PRINTF(5)("found line in mtlFile: %s\n", buffer);
    225      
    226215
    227216      // create new Material
     
    286275
    287276    }
    288   MTL_FILE->close();
     277  fclose(stream);
    289278  delete []fileName;
    290   delete MTL_FILE;
    291279  return true;
    292280}
  • orxonox/trunk/src/lib/graphics/importer/primitive_model.cc

    r3896 r3909  
    3333PrimitiveModel::PrimitiveModel(PRIMITIVE type, float size, unsigned int detail)
    3434{
    35   this->initialize();
    36 
    3735  switch (type)
    3836    {
Note: See TracChangeset for help on using the changeset viewer.