Changeset 4584 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jun 10, 2005, 3:50:11 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/material.cc
r4539 r4584 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 36 36 Material::Material (const char* mtlName) 37 37 { 38 PRINTF(4)("initializing new Material.\n"); 39 this->name = NULL; 38 PRINTF(4)("initializing new Material.\n"); 40 39 this->setIllum(3); 41 40 this->setDiffuse(0,0,0); … … 52 51 } 53 52 54 /** 53 /** 55 54 \brief deletes a Material 56 55 */ 57 56 Material::~Material() 58 57 { 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()); 62 59 if (this->diffuseTexture) 63 60 ResourceManager::getInstance()->unload(this->diffuseTexture); … … 81 78 // setting up Shininess 82 79 glMaterialf(GL_FRONT, GL_SHININESS, this->shininess); 83 80 84 81 // setting the transparency 85 82 if (this->transparency < 1.0) … … 96 93 97 94 98 // setting illumination Model 95 // setting illumination Model 99 96 if (this->illumModel == 1) //! \todo make this work, if no vertex-normals are read. 100 97 glShadeModel(GL_FLAT); … … 109 106 /* This allows alpha blending of 2D textures with the scene */ 110 107 if (this->diffuseTexture->hasAlpha()) 111 112 113 114 108 { 109 glEnable(GL_BLEND); 110 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 111 } 115 112 } 116 113 else … … 122 119 123 120 /** 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. 153 122 \brief illu illumination Model in int form 154 123 */ 155 124 void Material::setIllum (int illum) 156 125 { 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); 158 127 this->illumModel = illum; 159 128 } 160 129 /** 161 \brief Sets the Material Illumination Model. 130 \brief Sets the Material Illumination Model. 162 131 \brief illu illumination Model in char* form 163 132 */void Material::setIllum (char* illum) … … 174 143 void Material::setDiffuse (float r, float g, float b) 175 144 { 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); 177 146 this->diffuse[0] = r; 178 147 this->diffuse[1] = g; 179 this->diffuse[2] = b; 148 this->diffuse[2] = b; 180 149 this->diffuse[3] = 1.0; 181 150 … … 193 162 194 163 /** 195 \brief Sets the Material Ambient Color. 164 \brief Sets the Material Ambient Color. 196 165 \param r Red Color Channel. 197 166 \param g Green Color Channel. … … 200 169 void Material::setAmbient (float r, float g, float b) 201 170 { 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); 203 172 this->ambient[0] = r; 204 173 this->ambient[1] = g; … … 218 187 219 188 /** 220 \brief Sets the Material Specular Color. 189 \brief Sets the Material Specular Color. 221 190 \param r Red Color Channel. 222 191 \param g Green Color Channel. … … 225 194 void Material::setSpecular (float r, float g, float b) 226 195 { 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); 228 197 this->specular[0] = r; 229 198 this->specular[1] = g; … … 265 234 void Material::setTransparency (float trans) 266 235 { 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); 268 237 this->transparency = trans; 269 238 } -
orxonox/trunk/src/lib/graphics/importer/material.h
r4466 r4584 8 8 #ifndef _MATERIAL_H 9 9 #define _MATERIAL_H 10 #include "base_object.h" 10 11 11 12 #if HAVE_CONFIG_H 13 #include <config.h> 12 #if HAVE_CONFIG_H 13 #include <config.h> 14 14 #endif /* HAVE_CONFIG_H */ 15 15 … … 22 22 23 23 //! Class to handle Materials. 24 class Material 24 class Material : public BaseObject 25 25 { 26 26 public: … … 30 30 bool select (void); 31 31 32 void setName (const char* mtlName);33 char* getName (void);34 32 void setIllum (int illum); 35 33 void setIllum (char* illum); … … 54 52 55 53 private: 56 char* name; //!< The Name of the Material.57 54 int illumModel; //!< The IlluminationModel is either flat or smooth. 58 55 float diffuse [4]; //!< The diffuse color of the Material.
Note: See TracChangeset
for help on using the changeset viewer.