Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.old/src/lib/graphics/importer/material.h @ 9395

Last change on this file since 9395 was 8697, checked in by patrick, 18 years ago

merged the terrain with the new trunk (MARK TERRAIN)

File size: 3.6 KB
Line 
1/*!
2 * @file material.h
3 * @brief Contains the Material Class that handles Material for 3D-Objects.
4 * @todo free SDL-surface when deleting Material.
5 * @todo delete imgNameWithPath after use creation.
6 */
7
8#ifndef _MATERIAL_H
9#define _MATERIAL_H
10#include "base_object.h"
11
12
13#if HAVE_CONFIG_H
14#include <config.h>
15#endif /* HAVE_CONFIG_H */
16
17#include <vector>
18#include "texture.h"
19#include "color.h"
20
21// FORWARD DECLARATIONS //
22
23//! Class to handle Materials.
24class Material : public BaseObject
25{
26public:
27  Material (const std::string& mtlName = "");
28  virtual ~Material ();
29
30  void loadParams(const TiXmlElement* root);
31
32  Material& operator=(const Material& material);
33
34  bool select () const;
35  bool activateTextureUnit(unsigned int textureNumber);
36  static void unselect();
37
38  void setIllum (int illum);
39  int getIllumModel() const { return this->illumModel; };
40
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);
49
50  Color& diffuseColor() { return diffuse; };
51  const Color& diffuseColor() const { return diffuse; };
52
53  // MAPPING //
54  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
55  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
56  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
57  void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
58
59  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
60  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
61  void setBump(const std::string& bump);
62  GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
63
64  const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
65
66  static void addTexturePath(const std::string& pathName);
67
68  const std::string& blendFuncToString(GLenum blendFunc);
69  GLenum stringToBlendFunc(const std::string& blendFuncString);
70
71
72public:
73  static const GLenum glTextureArbs[];  //!< The Texture ARB's
74
75  static const GLenum glBlendFuncParams[];
76  static const std::string blendFuncNames[];
77
78  static unsigned int getMaxTextureUnits();
79
80private:
81  static const Material* selectedMaterial; //!< The currently selected material.
82
83  int              illumModel;       //!< The IlluminationModel is either flat or smooth.
84  Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
85  Color            ambient;          //!< The ambient color of the Material.
86  Color            specular;         //!< The specular color of the Material.
87  float            shininess;        //!< The shininess of the Material.
88  GLenum           sFactor;          //!< The Blending Factor for the Source.
89  GLenum           tFactor;          //!< The Blending Factor for the Destination.
90
91  std::vector<Texture> textures;     //!< An Array of Textures.
92
93  Texture*         ambientTexture;   //!< The ambient texture of the Material.
94  Texture*         specularTexture;  //!< The specular texture of the Material.
95};
96
97#endif
Note: See TracBrowser for help on using the repository browser.