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 "SDL_image.h" |
---|
19 | |
---|
20 | #include "texture.h" |
---|
21 | |
---|
22 | // FORWARD DECLARATIONS // |
---|
23 | |
---|
24 | //! Class to handle Materials. |
---|
25 | class Material : public BaseObject |
---|
26 | { |
---|
27 | public: |
---|
28 | Material (const std::string& mtlName = ""); |
---|
29 | virtual ~Material (); |
---|
30 | |
---|
31 | Material& operator=(const Material& material); |
---|
32 | |
---|
33 | bool select () const; |
---|
34 | |
---|
35 | void setIllum (int illum); |
---|
36 | int getIllumModel() const { return this->illumModel; }; |
---|
37 | void setDiffuse (float r, float g, float b); |
---|
38 | void setAmbient (float r, float g, float b); |
---|
39 | void setSpecular (float r, float g, float b); |
---|
40 | void setShininess (float shini); |
---|
41 | void setTransparency (float trans); |
---|
42 | void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; |
---|
43 | |
---|
44 | |
---|
45 | // TODO Move them out of here |
---|
46 | void setIllum (char* illum); |
---|
47 | void setDiffuse (char* rgb); |
---|
48 | void setAmbient (char* rgb); |
---|
49 | void setSpecular (char* rgb); |
---|
50 | void setShininess (char* shini); |
---|
51 | void setTransparency (char* trans); |
---|
52 | |
---|
53 | |
---|
54 | // MAPPING // |
---|
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 | |
---|
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; }; |
---|
62 | |
---|
63 | static void addTexturePath(const std::string& pathName); |
---|
64 | |
---|
65 | public: |
---|
66 | static const GLenum glTextureArbs[]; //!< The Texture ARB's |
---|
67 | |
---|
68 | static int getMaxTextureUnits(); |
---|
69 | |
---|
70 | private: |
---|
71 | static const Material* selectedMaterial; //!< The currently selected material. |
---|
72 | |
---|
73 | int illumModel; //!< The IlluminationModel is either flat or smooth. |
---|
74 | float diffuse [4]; //!< The diffuse color of the Material. |
---|
75 | float ambient [4]; //!< The ambient color of the Material. |
---|
76 | float specular [4]; //!< The specular color of the Material. |
---|
77 | float shininess; //!< The shininess of the Material. |
---|
78 | float transparency; //!< The transperency of the Material. |
---|
79 | GLenum sFactor; |
---|
80 | GLenum tFactor; |
---|
81 | |
---|
82 | std::vector<Texture*> textures; //!< An Array of Textures. |
---|
83 | |
---|
84 | Texture* ambientTexture; //!< The ambient texture of the Material. |
---|
85 | Texture* specularTexture; //!< The specular texture of the Material. |
---|
86 | |
---|
87 | |
---|
88 | }; |
---|
89 | #endif |
---|