Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 21, 2005, 1:38:34 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: importer: functionality improvement

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

Legend:

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

    r3912 r3913  
    2727using namespace std;
    2828
     29//////////////////
     30// DE-CONSTRUCT //
     31//////////////////
    2932/**
    3033   \brief Creates a 3D-Model. and assigns it a Name.
     
    313316// MESH //
    314317//////////
     318/**
     319   \brief adds a new Material to the Material List
     320   \param material the Material to add
     321   \returns the added material
     322
     323   !! beware the Material will be deleted when the Model gets deleted
     324*/
     325Material* Model::addMaterial(Material* material)
     326{
     327  this->materialList->add(material);
     328  return material;
     329}
     330
     331/**
     332   \brief adds a new Material to the Material List
     333   \param material the name of the Material to add
     334   \returns the added material
     335*/
     336Material* Model::addMaterial(const char* materialName)
     337{
     338 
     339  Material* newMat = new Material();
     340  newMat->setName(materialName);
     341
     342  // adding material to the List of materials
     343  this->materialList->add(newMat); 
     344  return newMat;
     345}
     346
     347Material* Model::findMaterialByName(const char* materialName)
     348{
     349  tIterator<Material>* tmpIt = this->materialList->getIterator();
     350  Material* material = tmpIt->nextElement();
     351  while(material)
     352    {
     353      if (!strcmp(material->getName(), materialName))
     354        {
     355          delete tmpIt;
     356          return material;
     357        }
     358      material = tmpIt->nextElement();
     359    }
     360  delete tmpIt;
     361  return NULL;
     362}
     363
    315364/**
    316365   \brief parses a group String
     
    534583   \param matString the Material that will be set.
    535584*/
    536 bool Model::addUseMtl(const char* matString)
     585bool Model::setMaterial(const char* matString)
    537586{
    538587  if (this->currentGroup->faceCount > 0)
     
    550599   \param mtl the Material that will be set.
    551600*/
    552 bool Model::addUseMtl(Material* mtl)
     601bool Model::setMaterial(Material* mtl)
    553602{
    554603  if (this->currentGroup->faceCount > 0)
     
    572621*/
    573622bool Model::buildVertexNormals ()
    574 {
    575  
     623
    576624  PRINTF(4)("Normals are being calculated.\n");
    577625
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3911 r3913  
    101101  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
    102102
     103  Material* findMaterialByName(const char* materialName);
     104
    103105  void cubeModel(void);
    104106
     
    115117  int getGroupCount() const;
    116118
     119  Material* addMaterial(Material* material);
     120  Material* addMaterial(const char* materialName);
     121
    117122  bool addGroup(const char* groupString);
    118123  bool addVertex(const char* vertexString);
     
    124129  bool addVertexTexture(const char* vTextureString);
    125130  bool addVertexTexture(float u, float v);
    126   bool addUseMtl(const char* mtlString);
    127   bool addUseMtl(Material* mtl);
     131  bool setMaterial(const char* mtlString);
     132  bool setMaterial(Material* mtl);
    128133  void finalize(void);
    129134};
  • orxonox/trunk/src/lib/graphics/importer/objModel.cc

    r3911 r3913  
    153153      else if (!strncmp(buffer, "usemtl ", 7))
    154154        {
    155           this->addUseMtl (buffer+7);
     155          this->setMaterial (buffer+7);
    156156        }
    157157
     
    222222        {
    223223          tmpMat = tmpMat->addMaterial(buffer+7);
    224           //      PRINTF(2)("%s, %p\n", tmpMat->getName(), tmpMat);
    225224        }
    226225      // setting a illumMode
Note: See TracChangeset for help on using the changeset viewer.