Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/material.h @ 10664

Last change on this file since 10664 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.7 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{
26  ObjectListDeclaration(Material);
27public:
28  Material (const std::string& mtlName = "");
29  virtual ~Material ();
30
31  Material& operator=(const Material& material);
32
33  void loadParams(const TiXmlElement* root);
34
35  bool select () const;
36  bool activateTextureUnit(unsigned int textureNumber);
37  static void unselect();
38
39  void setIllum (int illum);
40  int getIllumModel() const { return this->illumModel; };
41
42  void setDiffuse (float r, float g, float b);
43  void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
44  void setAmbient (float r, float g, float b);
45  void setSpecular (float r, float g, float b);
46  void setShininess (float shini);
47  void setTransparency (float trans);
48  void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
49  void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
50
51  Color& diffuseColor() { return diffuse; };
52  const Color& diffuseColor() const { return diffuse; };
53
54  // MAPPING //
55  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
56  void setDiffuseMap(const TextureData::Pointer& texturePointer, unsigned int textureNumber = 0);
57  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
58  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
59  void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
60
61  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
62  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
63  void setBump(const std::string& bump);
64
65  GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
66
67  const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
68
69  static const std::string& blendFuncToString(GLenum blendFunc);
70  static GLenum stringToBlendFunc(const std::string& blendFuncString);
71
72  void debug() const;
73
74public:
75  static const GLenum glTextureArbs[];  //!< The Texture ARB's
76
77  static const GLenum glBlendFuncParams[];
78  static const std::string blendFuncNames[];
79
80  static unsigned int getMaxTextureUnits();
81
82private:
83  static const Material* selectedMaterial; //!< The currently selected material.
84
85  int              illumModel;       //!< The IlluminationModel is either flat or smooth.
86  Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
87  Color            ambient;          //!< The ambient color of the Material.
88  Color            specular;         //!< The specular color of the Material.
89  float            shininess;        //!< The shininess of the Material.
90  GLenum           sFactor;          //!< The Blending Factor for the Source.
91  GLenum           tFactor;          //!< The Blending Factor for the Destination.
92
93  std::vector<Texture> textures;     //!< An Array of Textures.
94
95  Texture*         ambientTexture;   //!< The ambient texture of the Material.
96  Texture*         specularTexture;  //!< The specular texture of the Material.
97};
98
99#endif
Note: See TracBrowser for help on using the repository browser.