Changeset 8376 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jun 14, 2006, 12:13:16 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/material.cc
r8370 r8376 132 132 133 133 // setting diffuse color 134 glColor4f (diffuse [0], diffuse[1], diffuse[2], this->transparency);134 glColor4f (diffuse.r(), diffuse.g(), diffuse.b(), diffuse.a()); 135 135 // setting ambient color 136 glMaterialfv(GL_FRONT, GL_AMBIENT, this->ambient);136 glMaterialfv(GL_FRONT, GL_AMBIENT, &this->ambient[0]); 137 137 // setting up Sprecular 138 glMaterialfv(GL_FRONT, GL_SPECULAR, this->specular);138 glMaterialfv(GL_FRONT, GL_SPECULAR, &this->specular[0]); 139 139 // setting up Shininess 140 140 glMaterialf(GL_FRONT, GL_SHININESS, this->shininess); 141 141 142 142 // setting the transparency 143 if (this-> transparency< 1.0 || /* This allows alpha blending of 2D textures with the scene */143 if (this->diffuse.a() < 1.0 || /* This allows alpha blending of 2D textures with the scene */ 144 144 (likely(!this->textures.empty() && this->textures[0].hasAlpha()))) 145 145 { … … 206 206 { 207 207 PRINTF(4)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b); 208 this->diffuse[0] = r; 209 this->diffuse[1] = g; 210 this->diffuse[2] = b; 211 this->diffuse[3] = 1.0; 212 208 this->diffuse = Color(r, g, b, this->diffuse.a() ); 213 209 } 214 210 … … 223 219 { 224 220 PRINTF(4)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b); 225 this->ambient[0] = r; 226 this->ambient[1] = g; 227 this->ambient[2] = b; 228 this->ambient[3] = 1.0; 221 this->ambient = Color(r, g, b, 1.0); 229 222 } 230 223 … … 238 231 { 239 232 PRINTF(4)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->getName(), r, g, b); 240 this->specular[0] = r; 241 this->specular[1] = g; 242 this->specular[2] = b; 243 this->specular[3] = 1.0; 233 this->specular = Color (r, g, b, 1.0); 244 234 } 245 235 … … 260 250 { 261 251 PRINTF(4)("setting Transparency of Material %s to %f.\n", this->getName(), trans); 262 this-> transparency= trans;252 this->diffuse.a() = trans; 263 253 } 264 254 … … 310 300 Texture* tex = dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target)); 311 301 if (tex != NULL) 312 this->textures[textureNumber] = *tex;302 this->textures[textureNumber] = *tex; 313 303 else 314 304 this->textures[textureNumber] = Texture(); … … 373 363 * @brief Sets the Materials Ambient Map 374 364 * @todo implement this 375 */365 */ 376 366 void Material::setAmbientMap(const std::string& aMap, GLenum target) 377 367 { … … 383 373 * @brief Sets the Materials Specular Map 384 374 * @param sMap the Name of the Image to Use 385 386 */375 * @todo implement this 376 */ 387 377 void Material::setSpecularMap(const std::string& sMap, GLenum target) 388 378 { … … 395 385 * @param bump the Name of the Image to Use 396 386 * @todo implemet this 397 */387 */ 398 388 void Material::setBump(const std::string& bump) 399 389 { -
trunk/src/lib/graphics/importer/material.h
r8370 r8376 17 17 #include <vector> 18 18 #include "texture.h" 19 #include "color.h" 19 20 20 21 // FORWARD DECLARATIONS // … … 35 36 void setIllum (int illum); 36 37 int getIllumModel() const { return this->illumModel; }; 38 37 39 void setDiffuse (float r, float g, float b); 38 40 void setAmbient (float r, float g, float b); … … 42 44 void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; 43 45 44 void getDiffuseColor(float& r, float& g, float& b) const { r = diffuse[0], g = diffuse[1], b = diffuse[2]; }46 const Color& getDiffuseColor() const { return diffuse; }; 45 47 46 48 // MAPPING // … … 66 68 67 69 int illumModel; //!< The IlluminationModel is either flat or smooth. 68 float diffuse [4]; //!< The diffuse color of the Material.69 float ambient [4];//!< The ambient color of the Material.70 float specular [4];//!< The specular color of the Material.70 Color diffuse; //!< The diffuse color of the Material. (also transparency.) 71 Color ambient; //!< The ambient color of the Material. 72 Color specular; //!< The specular color of the Material. 71 73 float shininess; //!< The shininess of the Material. 72 float transparency; //!< The transperency of the Material.73 74 GLenum sFactor; //!< The Blending Factor for the Source. 74 75 GLenum tFactor; //!< The Blending Factor for the Destination. -
trunk/src/lib/graphics/importer/texture.cc
r8366 r8376 163 163 Texture::~Texture() 164 164 {} 165 166 /** 167 * @brief copies the Data from texture to this texture. 168 * @param texture the Texture to copy into this one. 169 * @returns the Texture. 170 */ 171 Texture& Texture::operator=(const Texture& texture) 172 { 173 this->data = texture.data; 174 175 return *this; 176 } 165 177 166 178 -
trunk/src/lib/graphics/importer/texture.h
r8363 r8376 26 26 Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D); 27 27 Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D); 28 29 Texture& operator=(const Texture& texture); 28 30 29 31 virtual ~Texture(); -
trunk/src/lib/util/color.cc
r7919 r8376 18 18 #include "color.h" 19 19 #include <stdio.h> 20 21 using namespace std;22 23 20 24 21 /** -
trunk/src/lib/util/color.h
r8145 r8376 16 16 { 17 17 public: 18 Color(float r , float g, float b, float a) :_r(r), _g(g), _b(b), _a(a) {};19 Color(const Color& c) { _r = c._r; _g = c._g; _b = c._b; _a = c._a; };18 Color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 0.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; }; 19 Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); } 20 20 21 float r() const { return _r; } 22 float& r() { return _r; } 23 float g() const { return _g; } 24 float& g() { return _g; } 25 float b() const { return _b; } 26 float& b() { return _b; } 27 float a() const { return _a; } 28 float& a() { return _a; } 21 float& operator[](unsigned int i) { return _rgba[i]; } 22 const float& operator[](unsigned int i) const { return _rgba[i]; } 29 23 24 float r() const { return _rgba[0]; } 25 float& r() { return _rgba[0]; } 26 float g() const { return _rgba[1]; } 27 float& g() { return _rgba[1]; } 28 float b() const { return _rgba[2]; } 29 float& b() { return _rgba[2]; } 30 float a() const { return _rgba[3]; } 31 float& a() { return _rgba[3]; } 32 33 34 /// STATIC TRANSFORMATIONS 30 35 public: 31 36 static Vector RGBtoHSV (const Vector& RGB); … … 38 43 static float maxrgb(float r, float g, float b); 39 44 40 float _r; //!< Red Value. 45 private: 46 float _rgba[4]; //!< Color Values 47 48 /* float _r; //!< Red Value. 41 49 float _g; //!< Green Value. 42 50 float _b; //!< Blue Value. 43 float _a; //!< Alpha Value. 44 51 float _a; //!< Alpha Value.*/ 45 52 }; 46 53
Note: See TracChangeset
for help on using the changeset viewer.