Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/trunk: importer: having color again

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

Legend:

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

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

    r3909 r3910  
    522522   \param matString the Material that will be set.
    523523*/
    524 bool Model::addUseMtl (const char* matString)
     524bool Model::addUseMtl(const char* matString)
    525525{
    526526  if (this->currentGroup->faceCount > 0)
     
    538538   \param mtl the Material that will be set.
    539539*/
    540 bool Model::addUseMtl (Material* mtl)
     540bool Model::addUseMtl(Material* mtl)
    541541{
    542542  if (this->currentGroup->faceCount > 0)
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3909 r3910  
    1212class Array;
    1313class Vector;
     14template<class T> class tList;
     15
     16
    1417
    1518using namespace std;
     
    2831class Model
    2932{
    30  public:
    31   Model(const char* modelName = NULL);
    32   virtual ~Model(void);
    33 
    34   void setName(const char* name);
    35  
    36   void draw(void) const;
    37   void draw(int groupNumber) const;
    38   void draw(char* groupName) const;
    39   int getGroupCount() const;
    40 
    41  protected:
    42   char* name;            //!< This is the name of the Model.
    43   bool finalized;        //!< Sets the Object to be finalized.
    44  
     33 private:
     34  /////////////
     35  // structs //
     36  /////////////
    4537  //! This is the placeholder of one Vertex beloning to a Face.
    4638  struct FaceElement
     
    7769  };
    7870
     71  char* name;            //!< This is the name of the Model.
     72  bool finalized;        //!< Sets the Object to be finalized.
    7973
    8074  Array* vertices;      //!< The Array that handles the Vertices.
     
    8377  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
    8478
    85  
    8679  Group* firstGroup;    //!< The first of all groups.
    8780  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
    8881  int groupCount;       //!< The Count of Groups.
    8982
    90   Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
    91   float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
    92 
    9383  bool initGroup(Group* group);
    9484  bool initFace (Face* face);
    95   bool cleanup(void);
     85
    9686  bool cleanupGroup(Group* group);
    9787  bool cleanupFace(Face* face);
    9888  bool cleanupFaceElement(FaceElement* faceElem);
    9989
     90  bool addGLElement(FaceElement* elem);
     91
     92  bool buildVertexNormals(void);
     93
     94 protected:
     95  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
     96  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
     97
     98  bool importToGL(void);
     99  void cubeModel(void);
     100
     101  bool cleanup(void);
     102
    100103 public:
     104  Model(const char* modelName = NULL);
     105  virtual ~Model(void);
     106
     107  void setName(const char* name);
     108  inline const char* getName() {return this->name;}
     109 
     110  void draw(void) const;
     111  void draw(int groupNumber) const;
     112  void draw(char* groupName) const;
     113  int getGroupCount() const;
     114
    101115  bool addGroup(const char* groupString);
    102116  bool addVertex(const char* vertexString);
     
    111125  bool addUseMtl(Material* mtl);
    112126  void finalize(void);
    113 
    114  protected:
    115   bool importToGL(void);
    116   bool addGLElement(FaceElement* elem);
    117 
    118   bool buildVertexNormals(void);
    119 
    120   void cubeModel(void);
    121127};
    122128
  • orxonox/trunk/src/lib/graphics/importer/objModel.cc

    r3909 r3910  
    129129    }
    130130
    131   char readLine[PARSELINELENGTH];
    132131  char buffer[PARSELINELENGTH];
    133   while(fgets(readLine, PARSELINELENGTH, stream))
    134     {
    135       strcpy(buffer, readLine);
     132  while(fgets(buffer, PARSELINELENGTH, stream))
     133    {
     134      // line termiated with \0 not \n
     135      if (buffer[strlen(buffer)-1] == '\n')
     136        buffer[strlen(buffer)-1] = '\0';
     137
    136138      // case vertice
    137139      if (!strncmp(buffer, "v ", 2))
     
    207209    }
    208210
    209   char readLine[PARSELINELENGTH];
    210211  char buffer[PARSELINELENGTH];
    211212  Material* tmpMat = material;
    212   while(fgets(readLine, PARSELINELENGTH, stream))
     213  while(fgets(buffer, PARSELINELENGTH, stream))
    213214    {
    214215      PRINTF(5)("found line in mtlFile: %s\n", buffer);
     216
     217      // line termiated with \0 not \n
     218      if (buffer[strlen(buffer)-1] == '\n')
     219        buffer[strlen(buffer)-1] = '\0';
    215220
    216221      // create new Material
Note: See TracChangeset for help on using the changeset viewer.