Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8572 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 18, 2006, 10:02:52 PM (19 years ago)
Author:
bensch
Message:

gui: nicer looks of Material

Location:
branches/gui/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/graphics/importer/material.cc

    r8571 r8572  
    431431
    432432
     433/**
     434 * @param blendFunc the Enumerator to convert to a String.
     435 * @returns the matching String if found
     436 */
    433437const std::string& Material::blendFuncToString(GLenum blendFunc)
    434438{
    435439  for (unsigned int i = 0; i < 9; ++i)
    436     if (blendFunc == glBlendFuncParams[i])
    437       return blendFuncNames[i];
    438   return blendFuncNames[0];
    439 }
    440 
     440    if (blendFunc == Material::glBlendFuncParams[i])
     441      return Material::blendFuncNames[i];
     442  PRINTF(2)("Supplied an Invalid Enumerator to blendfunc %d\n", blendFunc);
     443  return Material::blendFuncNames[0];
     444}
     445
     446/**
     447 * @param blendFuncString the String to convert into a gl-enumeration
     448 * @returns the matching GL-enumeration if found.
     449 */
    441450GLenum Material::stringToBlendFunc(const std::string& blendFuncString)
    442451{
    443452  for (unsigned int i = 0; i < 9; ++i)
    444     if (blendFuncString == blendFuncNames[i])
    445       return glBlendFuncParams[i];
    446   return glBlendFuncParams[0];
    447 }
    448 
     453    if (blendFuncString == Material::blendFuncNames[i])
     454      return Material::glBlendFuncParams[i];
     455  PRINTF(2)("BlendFunction %s not recognized using %s\n", blendFuncString.c_str(), Material::blendFuncNames[0].c_str());
     456  return Material::glBlendFuncParams[0];
     457}
    449458
    450459
  • branches/gui/src/lib/graphics/importer/material.h

    r8571 r8572  
    2424class Material : public BaseObject
    2525{
    26   public:
    27     Material (const std::string& mtlName = "");
    28     virtual ~Material ();
     26public:
     27  Material (const std::string& mtlName = "");
     28  virtual ~Material ();
    2929
    30     void loadParams(const TiXmlElement* root);
     30  void loadParams(const TiXmlElement* root);
    3131
    32     Material& operator=(const Material& material);
     32  Material& operator=(const Material& material);
    3333
    34     bool select () const;
    35     bool activateTextureUnit(unsigned int textureNumber);
    36     static void unselect();
     34  bool select () const;
     35  bool activateTextureUnit(unsigned int textureNumber);
     36  static void unselect();
    3737
    38     void setIllum (int illum);
    39     int getIllumModel() const { return this->illumModel; };
     38  void setIllum (int illum);
     39  int getIllumModel() const { return this->illumModel; };
    4040
    41     void setDiffuse (float r, float g, float b);
    42     void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
    43     void setAmbient (float r, float g, float b);
    44     void setSpecular (float r, float g, float b);
    45     void setShininess (float shini);
    46     void setTransparency (float trans);
    47     void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
    48     void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
     41  void setDiffuse (float r, float g, float b);
     42  void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
     43  void setAmbient (float r, float g, float b);
     44  void setSpecular (float r, float g, float b);
     45  void setShininess (float shini);
     46  void setTransparency (float trans);
     47  void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
     48  void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
    4949
    50     const Color& getDiffuseColor() const { return diffuse; };
     50  const Color& diffuseColor() const { return diffuse; };
    5151
    52     // MAPPING //
    53     void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
    54     void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    55     void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    56     void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
     52  // MAPPING //
     53  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
     54  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     55  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     56  void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
    5757
    58     void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
    59     void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
    60     void setBump(const std::string& bump);
    61     GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
     58  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
     59  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
     60  void setBump(const std::string& bump);
     61  GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
    6262
    63     static void addTexturePath(const std::string& pathName);
     63  static void addTexturePath(const std::string& pathName);
    6464
    65     const std::string& blendFuncToString(GLenum blendFunc);
    66     GLenum stringToBlendFunc(const std::string& blendFuncString);
     65  const std::string& blendFuncToString(GLenum blendFunc);
     66  GLenum stringToBlendFunc(const std::string& blendFuncString);
    6767
    6868
    69   public:
    70     static const GLenum glTextureArbs[];  //!< The Texture ARB's
     69public:
     70  static const GLenum glTextureArbs[];  //!< The Texture ARB's
    7171
    72     static const GLenum glBlendFuncParams[];
    73     static const std::string blendFuncNames[];
     72  static const GLenum glBlendFuncParams[];
     73  static const std::string blendFuncNames[];
    7474
    75     static unsigned int getMaxTextureUnits();
     75  static unsigned int getMaxTextureUnits();
    7676
    77   private:
    78     static const Material* selectedMaterial; //!< The currently selected material.
     77private:
     78  static const Material* selectedMaterial; //!< The currently selected material.
    7979
    80     int              illumModel;       //!< The IlluminationModel is either flat or smooth.
    81     Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
    82     Color            ambient;          //!< The ambient color of the Material.
    83     Color            specular;         //!< The specular color of the Material.
    84     float            shininess;        //!< The shininess of the Material.
    85     GLenum           sFactor;          //!< The Blending Factor for the Source.
    86     GLenum           tFactor;          //!< The Blending Factor for the Destination.
     80  int              illumModel;       //!< The IlluminationModel is either flat or smooth.
     81  Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
     82  Color            ambient;          //!< The ambient color of the Material.
     83  Color            specular;         //!< The specular color of the Material.
     84  float            shininess;        //!< The shininess of the Material.
     85  GLenum           sFactor;          //!< The Blending Factor for the Source.
     86  GLenum           tFactor;          //!< The Blending Factor for the Destination.
    8787
    88     std::vector<Texture> textures;     //!< An Array of Textures.
     88  std::vector<Texture> textures;     //!< An Array of Textures.
    8989
    90     Texture*         ambientTexture;   //!< The ambient texture of the Material.
    91     Texture*         specularTexture;  //!< The specular texture of the Material.
     90  Texture*         ambientTexture;   //!< The ambient texture of the Material.
     91  Texture*         specularTexture;  //!< The specular texture of the Material.
    9292};
    9393
Note: See TracChangeset for help on using the changeset viewer.