Changeset 8571 in orxonox.OLD
- Timestamp:
- Jun 18, 2006, 9:52:32 PM (18 years ago)
- Location:
- branches/gui/src/lib/graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/graphics/importer/material.cc
r8376 r8571 22 22 #include "debug.h" 23 23 #include "compiler.h" 24 25 #include "loading/load_param.h" 26 24 27 #include "util/loading/resource_manager.h" 25 28 … … 47 50 } 48 51 52 void Material::loadParams(const TiXmlElement* root) 53 { 54 LoadParam(root, "illum", this, Material, setIllum); 55 56 LoadParam(root, "diffuse-color", this, Material , setDiffuse); 57 LoadParam(root, "ambient-color", this, Material , setAmbient); 58 LoadParam(root, "specular-color", this, Material , setSpecular); 59 LoadParam(root, "transparency", this, Material , setTransparency); 60 61 LoadParam(root, "tex", this, Material, setDiffuseMap); 62 LoadParam(root, "blendfunc", this, Material, setBlendFuncS) 63 .defaultValues("ZERO", "ZERO"); 64 } 65 66 49 67 /** 50 68 * @brief deletes a Material … … 65 83 66 84 const Material* Material::selectedMaterial = NULL; 67 68 const GLenum Material::glTextureArbs[] =69 {70 GL_TEXTURE0,71 GL_TEXTURE1,72 GL_TEXTURE2,73 GL_TEXTURE3,74 GL_TEXTURE4,75 GL_TEXTURE5,76 GL_TEXTURE6,77 GL_TEXTURE778 };79 85 80 86 … … 104 110 * @brief sets the material with which the following Faces will be painted 105 111 */ 106 112 bool Material::select() const 107 113 { 108 114 if (unlikely(this == Material::selectedMaterial)) 109 110 111 /// !! HACK !!! FIX THIS IN MODEL ///115 return true; 116 117 /// !! HACK !!! FIX THIS IN MODEL /// 112 118 else if (likely(Material::selectedMaterial != NULL)) 113 119 { 114 Material::unselect();115 // for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)116 // {117 // glActiveTexture(Material::glTextureArbs[i]);118 // glBindTexture(GL_TEXTURE_2D, 0);119 // glDisable(GL_TEXTURE_2D);120 // }120 Material::unselect(); 121 // for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i) 122 // { 123 // glActiveTexture(Material::glTextureArbs[i]); 124 // glBindTexture(GL_TEXTURE_2D, 0); 125 // glDisable(GL_TEXTURE_2D); 126 // } 121 127 } 122 128 … … 125 131 for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i) 126 132 { 127 128 129 133 glActiveTexture(Material::glTextureArbs[i]); 134 //glBindTexture(GL_TEXTURE_2D, 0); 135 glDisable(GL_TEXTURE_2D); 130 136 } 131 137 } 132 138 133 139 // setting diffuse color 134 140 glColor4f (diffuse.r(), diffuse.g(), diffuse.b(), diffuse.a()); 135 141 // setting ambient color … … 161 167 for(unsigned int i = 0; i < this->textures.size(); ++i) 162 168 { 163 164 165 166 167 168 169 169 glActiveTexture(Material::glTextureArbs[i]); 170 glEnable(GL_TEXTURE_2D); 171 if(this->textures[i].hasAlpha()) 172 { 173 glEnable(GL_BLEND); 174 } 175 glBindTexture(GL_TEXTURE_2D, this->textures[i].getTexture()); 170 176 } 171 177 Material::selectedMaterial = this; … … 179 185 { 180 186 Material::selectedMaterial = NULL; 181 182 183 184 185 186 187 for(unsigned int i = 0; i < 8; ++i) 188 { 189 glActiveTexture(Material::glTextureArbs[i]); 190 glBindTexture(GL_TEXTURE_2D, 0); 191 glDisable(GL_TEXTURE_2D); 192 } 187 193 } 188 194 … … 252 258 this->diffuse.a() = trans; 253 259 } 260 261 /** 262 * @brief sets the Blend-Function Parameters 263 * @param sFactor the Source Parameter. 264 * @param tFactor the Desitnation Parameter. 265 */ 266 void Material::setBlendFuncS(const std::string& sFactor, const std::string& tFactor) 267 { 268 this->setBlendFunc(Material::stringToBlendFunc(sFactor), Material::stringToBlendFunc(tFactor)); 269 } 270 271 254 272 255 273 /** … … 354 372 // HACK 355 373 glActiveTexture(textureNumber); 356 357 374 glEnable(GL_TEXTURE_2D); 375 glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture()); 358 376 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); 359 377 … … 387 405 */ 388 406 void Material::setBump(const std::string& bump) 389 { 390 } 407 {} 391 408 392 409 … … 400 417 return maxTexUnits; 401 418 } 419 420 const GLenum Material::glTextureArbs[] = 421 { 422 GL_TEXTURE0, 423 GL_TEXTURE1, 424 GL_TEXTURE2, 425 GL_TEXTURE3, 426 GL_TEXTURE4, 427 GL_TEXTURE5, 428 GL_TEXTURE6, 429 GL_TEXTURE7 430 }; 431 432 433 const std::string& Material::blendFuncToString(GLenum blendFunc) 434 { 435 for (unsigned int i = 0; i < 9; ++i) 436 if (blendFunc == glBlendFuncParams[i]) 437 return blendFuncNames[i]; 438 return blendFuncNames[0]; 439 } 440 441 GLenum Material::stringToBlendFunc(const std::string& blendFuncString) 442 { 443 for (unsigned int i = 0; i < 9; ++i) 444 if (blendFuncString == blendFuncNames[i]) 445 return glBlendFuncParams[i]; 446 return glBlendFuncParams[0]; 447 } 448 449 450 451 const GLenum Material::glBlendFuncParams[] = 452 { 453 GL_ZERO, 454 GL_ONE, 455 GL_DST_COLOR, 456 GL_ONE_MINUS_DST_COLOR, 457 GL_SRC_ALPHA, 458 GL_ONE_MINUS_SRC_ALPHA, 459 GL_DST_ALPHA, 460 GL_ONE_MINUS_DST_ALPHA, 461 GL_SRC_ALPHA_SATURATE 462 }; 463 464 const std::string Material::blendFuncNames[] = 465 { 466 "ZERO", 467 "ONE", 468 "DST_COLOR", 469 "ONE_MINUS_DST_COLOR", 470 "SRC_ALPHA", 471 "ONE_MINUS_SRC_ALPHA", 472 "DST_ALPHA", 473 "ONE_MINUS_DST_ALPHA", 474 "SRC_ALPHA_SATURATE" 475 476 }; -
branches/gui/src/lib/graphics/importer/material.h
r8448 r8571 28 28 virtual ~Material (); 29 29 30 void loadParams(const TiXmlElement* root); 31 30 32 Material& operator=(const Material& material); 31 33 … … 44 46 void setTransparency (float trans); 45 47 void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; 48 void setBlendFuncS(const std::string& sFactor, const std::string& tFactor); 46 49 47 50 const Color& getDiffuseColor() const { return diffuse; }; … … 60 63 static void addTexturePath(const std::string& pathName); 61 64 65 const std::string& blendFuncToString(GLenum blendFunc); 66 GLenum stringToBlendFunc(const std::string& blendFuncString); 67 68 62 69 public: 63 70 static const GLenum glTextureArbs[]; //!< The Texture ARB's 71 72 static const GLenum glBlendFuncParams[]; 73 static const std::string blendFuncNames[]; 64 74 65 75 static unsigned int getMaxTextureUnits(); -
branches/gui/src/lib/graphics/text_engine/text.cc
r8539 r8571 21 21 #include "util/loading/resource_manager.h" 22 22 #include "debug.h" 23 24 using namespace std;25 23 26 24 /**
Note: See TracChangeset
for help on using the changeset viewer.