Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3894 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Apr 19, 2005, 6:48:49 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: Material, and Model update, some const-issues

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

Legend:

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

    r3803 r3894  
    3434   \param mtlName Name of the Material to be added to the Material List
    3535*/
    36 Material::Material (char* mtlName)
     36Material::Material (const char* mtlName)
    3737{
    3838   PRINTF(4)("initializing new Material.\n");
    3939  this->nextMat = NULL;
    40   this->name ="";
     40  this->name = NULL;
    4141  this->setIllum(3);
    4242  this->setDiffuse(0,0,0);
     
    5555  this->specularTextureSet = false;
    5656
    57   if (mtlName)
    58     this->setName (mtlName);
    59   else
    60     this->setName("");
     57  this->setName(mtlName);
    6158}
    6259
     
    8077   \param mtlName The name of the Material to be added.
    8178*/
    82 Material* Material::addMaterial(char* mtlName)
     79Material* Material::addMaterial(const char* mtlName)
    8380{
    8481  PRINTF(4)("adding Material %s.\n", mtlName);
     
    9895   \returns Material named mtlName if it is found. NULL otherwise.
    9996*/
    100 Material* Material::search(char* mtlName)
     97Material* Material::search(const char* mtlName)
    10198{
    10299  PRINTF(5)("Searching for material %s", mtlName);
     
    168165   \param mtlName the Name of the Material to be set.
    169166*/
    170 void Material::setName (char* mtlName)
    171 {
    172   PRINTF(4)("setting Material Name to %s.\n", this->name);
    173   this->name = new char [strlen(mtlName)+1];
    174   strcpy(this->name, mtlName);
     167void Material::setName (const char* mtlName)
     168{
     169  if (this->name)
     170    delete this->name;
     171  if (mtlName)
     172    {
     173      this->name = new char [strlen(mtlName)+1];
     174      strcpy(this->name, mtlName);
     175    }
     176  else
     177    {
     178      this->name = new char[2];
     179      strcpy(this->name, "");
     180    }
    175181}
    176182
  • orxonox/trunk/src/lib/graphics/importer/material.h

    r3803 r3894  
    1414#endif /* HAVE_CONFIG_H */
    1515
     16#ifndef NULL
     17#define NULL 0
     18#endif
     19
    1620// FORWARD DEFINITIONS //
    1721class Texture;
     
    2226{
    2327 public:
    24   Material (char* mtlName = "");
    25   Material* addMaterial(char* mtlName);
     28  Material (const char* mtlName = NULL);
     29  Material* addMaterial(const char* mtlName);
    2630  ~Material ();
    2731
    28   Material* search(char* mtlName);
     32  Material* search(const char* mtlName);
    2933  bool select (void);
    3034
    31   void setName (char* mtlName);
     35  void setName (const char* mtlName);
    3236  char* getName (void);
    3337  void setIllum (int illum);
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r3801 r3894  
    323323   With it you should be able to import .obj-files with more than one Models inside.
    324324*/
    325 bool Model::addGroup (char* groupString)
     325bool Model::addGroup (const char* groupString)
    326326{
    327327  PRINTF(5)("Read Group: %s.\n", groupString);
     
    366366   
    367367*/
    368 bool Model::addVertex(const float x, const float y, const float z)
     368bool Model::addVertex(float x, float y, float z)
    369369{
    370370  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
     
    441441   \param type 0: vertex only, 1: vertex and normal, 2: vertex and Texture, 3 vertex, normal and texture
    442442*/
    443 bool Model::addFace(const float faceElemCount, int type, ...)
     443bool Model::addFace(int faceElemCount, int type, ...)
    444444{
    445445   if (this->currentGroup->faceCount > 0)
     
    496496   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    497497*/
    498 bool Model::addVertexNormal(const float x, const float y, const float z)
     498bool Model::addVertexNormal(float x, float y, float z)
    499499{
    500500  PRINTF(3)("found vertex-Normal %f, %f, %f\n", x, y, z);
     
    527527   If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
    528528*/
    529 bool Model::addVertexTexture(const float u, const float v)
    530 {
    531   PRINTF(3)("found vertex-Texture %f, %f\n", u, v);
     529bool Model::addVertexTexture(float u, float v)
     530{
     531  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
    532532  this->vTexture->addEntry(u);
    533533  this->vTexture->addEntry(v);
     
    538538   \param matString the Material that will be set.
    539539*/
    540 bool Model::addUseMtl (char* matString)
     540bool Model::addUseMtl (const char* matString)
    541541{
    542542  /*
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3801 r3894  
    1919#define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
    2020#define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
     21//! an enumerator for VERTEX_FORMAT
     22enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,
     23                    VERTEX_NORMAL = NORMAL,
     24                    VERTEX_TEXCOORD = TEXCOORD,
     25                    VERTEXT_TEXTURE_NORMAL = NORMAL | TEXCOORD};
    2126
    2227//! Class that handles 3D-Models. it can also read them in and display them.
     
    96101
    97102 public:
    98   bool addGroup(char* groupString);
     103  bool addGroup(const char* groupString);
    99104  bool addVertex(char* vertexString);
    100   bool addVertex(const float x, const float y, const float z);
     105  bool addVertex(float x, float y, float z);
    101106  bool addFace(char* faceString);
    102   bool addFace(const float faceElemCount, int type, ...);
     107  bool addFace(int faceElemCount, int type, ...);
    103108  bool addVertexNormal(char* normalString);
    104   bool addVertexNormal(const float x, const float y, const float z);
     109  bool addVertexNormal(float x, float y, float z);
    105110  bool addVertexTexture(char* vTextureString);
    106   bool addVertexTexture(const float u, const float v);
    107   bool addUseMtl(char* mtlString);
     111  bool addVertexTexture(float u, float v);
     112  bool addUseMtl(const char* mtlString);
    108113  bool addUseMtl(Material* mtl);
    109114  void finalize(void);
Note: See TracChangeset for help on using the changeset viewer.