Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 10, 2005, 3:50:11 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: TrackElement and Material are BaseObjects now

File:
1 edited

Legend:

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

    r4539 r4584  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3636Material::Material (const char* mtlName)
    3737{
    38    PRINTF(4)("initializing new Material.\n");
    39   this->name = NULL;
     38  PRINTF(4)("initializing new Material.\n");
    4039  this->setIllum(3);
    4140  this->setDiffuse(0,0,0);
     
    5251}
    5352
    54 /** 
     53/**
    5554    \brief deletes a Material
    5655*/
    5756Material::~Material()
    5857{
    59   PRINTF(4)("delete Material %s.\n", this->name);
    60   if (this->name)
    61     delete []this->name;
     58  PRINTF(4)("delete Material %s.\n", this->getName());
    6259  if (this->diffuseTexture)
    6360    ResourceManager::getInstance()->unload(this->diffuseTexture);
     
    8178  // setting up Shininess
    8279  glMaterialf(GL_FRONT, GL_SHININESS, this->shininess);
    83  
     80
    8481  // setting the transparency
    8582  if (this->transparency < 1.0)
     
    9693
    9794
    98   // setting illumination Model 
     95  // setting illumination Model
    9996  if (this->illumModel == 1) //! \todo make this work, if no vertex-normals are read.
    10097    glShadeModel(GL_FLAT);
     
    109106      /* This allows alpha blending of 2D textures with the scene */
    110107      if (this->diffuseTexture->hasAlpha())
    111         {
    112           glEnable(GL_BLEND);
    113           glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    114         }
     108        {
     109          glEnable(GL_BLEND);
     110          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     111        }
    115112    }
    116113  else
     
    122119
    123120/**
    124    \brief Set the Name of the Material. (Important for searching)
    125    \param mtlName the Name of the Material to be set.
    126 */
    127 void Material::setName (const char* mtlName)
    128 {
    129   if (this->name)
    130     delete this->name;
    131   if (mtlName)
    132     {
    133       this->name = new char [strlen(mtlName)+1];
    134       strcpy(this->name, mtlName);
    135     }
    136   else
    137     {
    138       this->name = new char[2];
    139       strcpy(this->name, "");
    140     }
    141 }
    142 
    143 /**
    144    \returns The Name of The Material
    145 */
    146 char* Material::getName (void)
    147 {
    148   return this->name;
    149 }
    150 
    151 /**
    152    \brief Sets the Material Illumination Model.
     121   \brief Sets the Material Illumination Model.
    153122   \brief illu illumination Model in int form
    154123*/
    155124void Material::setIllum (int illum)
    156125{
    157   PRINTF(4)("setting illumModel of Material %s to %i\n", this->name, illum);
     126  PRINTF(4)("setting illumModel of Material %s to %i\n", this->getName(), illum);
    158127  this->illumModel = illum;
    159128}
    160129/**
    161    \brief Sets the Material Illumination Model. 
     130   \brief Sets the Material Illumination Model.
    162131   \brief illu illumination Model in char* form
    163132*/void Material::setIllum (char* illum)
     
    174143void Material::setDiffuse (float r, float g, float b)
    175144{
    176   PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
     145  PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
    177146  this->diffuse[0] = r;
    178147  this->diffuse[1] = g;
    179   this->diffuse[2] = b; 
     148  this->diffuse[2] = b;
    180149  this->diffuse[3] = 1.0;
    181150
     
    193162
    194163/**
    195    \brief Sets the Material Ambient Color. 
     164   \brief Sets the Material Ambient Color.
    196165   \param r Red Color Channel.
    197166   \param g Green Color Channel.
     
    200169void Material::setAmbient (float r, float g, float b)
    201170{
    202   PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
     171  PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
    203172  this->ambient[0] = r;
    204173  this->ambient[1] = g;
     
    218187
    219188/**
    220    \brief Sets the Material Specular Color. 
     189   \brief Sets the Material Specular Color.
    221190   \param r Red Color Channel.
    222191   \param g Green Color Channel.
     
    225194void Material::setSpecular (float r, float g, float b)
    226195{
    227   PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
     196  PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b);
    228197  this->specular[0] = r;
    229198  this->specular[1] = g;
     
    265234void Material::setTransparency (float trans)
    266235{
    267   PRINTF(4)("setting Transparency of Material %s to %f.\n", this->name, trans);
     236  PRINTF(4)("setting Transparency of Material %s to %f.\n", this->getName(), trans);
    268237  this->transparency = trans;
    269238}
Note: See TracChangeset for help on using the changeset viewer.