Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 13, 2005, 6:54:35 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: some more functionality to material
now it is possible to add an external Material, and it handles pointers instead of char-arrays

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

Legend:

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

    r3750 r3801  
    236236  face->firstElem = NULL;
    237237 
    238   face->materialString = NULL;
     238  face->material = NULL;
    239239 
    240240  face->next = NULL;
     
    288288  PRINTF(5)("Cleaning up Face\n");
    289289
    290   if (face->materialString != NULL)
    291       delete []face->materialString;
    292290  if (face->firstElem != NULL)
    293291    {
     
    549547    }
    550548  */     
    551   if (this->currentGroup->faceCount >0)
     549  if (this->currentGroup->faceCount > 0)
    552550    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
    553551  this->initFace (this->currentGroup->currentFace);
    554552 
    555   this->currentGroup->currentFace->materialString = new char[strlen(matString)+1];
    556   strcpy (this->currentGroup->currentFace->materialString, matString);
    557  
     553  this->currentGroup->currentFace->material = material->search(matString);
     554
    558555  if (this->currentGroup->faceCount == 0)
    559556    this->currentGroup->faceCount ++;
    560 
     557}
     558
     559/**
     560   \brief Function that selects a material, if changed in the obj file.
     561   \param mtl the Material that will be set.
     562*/
     563bool Model::addUseMtl (Material* mtl)
     564{
     565  if (this->currentGroup->faceCount > 0)
     566    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
     567  this->initFace (this->currentGroup->currentFace);
     568 
     569  this->currentGroup->currentFace->material = mtl;
     570
     571  if (this->currentGroup->faceCount == 0)
     572    this->currentGroup->faceCount ++;
    561573}
    562574
     
    591603      while (tmpFace != NULL)
    592604        {
    593           if (tmpFace->vertexCount == 0 && tmpFace->materialString != NULL)
     605          if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
    594606            {
    595607              if (this->currentGroup->faceMode != -1)
     
    597609              this->currentGroup->faceMode = 0;
    598610              Material* tmpMat;
    599               if ((tmpMat = material->search(tmpFace->materialString)) != NULL)
     611              if (tmpFace->material != NULL)
    600612                {
    601                   tmpMat->select();
    602                   PRINTF(5)("using material %s for coming Faces.\n", tmpFace->materialString);
     613                  tmpFace->material->select();
     614                  PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName());
    603615                }
    604               else
    605                 PRINTF(2)("material %s not found.\n", tmpFace->materialString);
    606 
    607 
    608616            }
    609617
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3657 r3801  
    5454    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
    5555
    56     char* materialString;   //!< The Name of the Material to which to Change.
     56    Material* material;     //!< The Material to use.
    5757
    5858    Face* next;             //!< Pointer to the next Face.
     
    106106  bool addVertexTexture(const float u, const float v);
    107107  bool addUseMtl(char* mtlString);
     108  bool addUseMtl(Material* mtl);
    108109  void finalize(void);
    109110
Note: See TracChangeset for help on using the changeset viewer.