[2842] | 1 | /*! |
---|
| 2 | \file material.h |
---|
| 3 | \brief Contains the Material Class that handles Material for 3D-Objects. |
---|
[4836] | 4 | @todo free SDL-surface when deleting Material. |
---|
| 5 | @todo delete imgNameWithPath after use creation. |
---|
[2842] | 6 | */ |
---|
| 7 | |
---|
[2776] | 8 | #ifndef _MATERIAL_H |
---|
| 9 | #define _MATERIAL_H |
---|
[4584] | 10 | #include "base_object.h" |
---|
[2804] | 11 | |
---|
[4584] | 12 | #if HAVE_CONFIG_H |
---|
| 13 | #include <config.h> |
---|
[3140] | 14 | #endif /* HAVE_CONFIG_H */ |
---|
| 15 | |
---|
[3894] | 16 | #ifndef NULL |
---|
[4466] | 17 | #define NULL 0 //!< a pointer to NULL |
---|
[3894] | 18 | #endif |
---|
| 19 | |
---|
[6769] | 20 | #include "texture.h" |
---|
| 21 | |
---|
[5405] | 22 | // FORWARD DECLARATIONS // |
---|
[3140] | 23 | |
---|
[2842] | 24 | //! Class to handle Materials. |
---|
[4584] | 25 | class Material : public BaseObject |
---|
[2776] | 26 | { |
---|
| 27 | public: |
---|
[7221] | 28 | Material (const std::string& mtlName = ""); |
---|
[5308] | 29 | virtual ~Material (); |
---|
[2778] | 30 | |
---|
[6622] | 31 | Material& operator=(const Material& material); |
---|
| 32 | |
---|
[5308] | 33 | bool select () const; |
---|
[2778] | 34 | |
---|
[2776] | 35 | void setIllum (int illum); |
---|
| 36 | void setIllum (char* illum); |
---|
[6622] | 37 | int getIllumModel() const { return this->illumModel; }; |
---|
[2776] | 38 | void setDiffuse (float r, float g, float b); |
---|
| 39 | void setDiffuse (char* rgb); |
---|
| 40 | void setAmbient (float r, float g, float b); |
---|
| 41 | void setAmbient (char* rgb); |
---|
| 42 | void setSpecular (float r, float g, float b); |
---|
| 43 | void setSpecular (char* rgb); |
---|
[2836] | 44 | void setShininess (float shini); |
---|
| 45 | void setShininess (char* shini); |
---|
[2776] | 46 | void setTransparency (float trans); |
---|
| 47 | void setTransparency (char* trans); |
---|
[7057] | 48 | void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; |
---|
[2776] | 49 | |
---|
[3140] | 50 | // MAPPING // |
---|
[7221] | 51 | void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D); |
---|
| 52 | void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D); |
---|
| 53 | void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D); |
---|
| 54 | void setBump(const std::string& bump); |
---|
[6769] | 55 | GLuint getDiffuseTexture() const { return (this->diffuseTexture)? this->diffuseTexture->getTexture() : 0; }; |
---|
[3070] | 56 | |
---|
[7221] | 57 | static void addTexturePath(const std::string& pathName); |
---|
[4466] | 58 | |
---|
[5866] | 59 | private: |
---|
| 60 | int illumModel; //!< The IlluminationModel is either flat or smooth. |
---|
| 61 | float diffuse [4]; //!< The diffuse color of the Material. |
---|
| 62 | float ambient [4]; //!< The ambient color of the Material. |
---|
| 63 | float specular [4]; //!< The specular color of the Material. |
---|
| 64 | float shininess; //!< The shininess of the Material. |
---|
| 65 | float transparency; //!< The transperency of the Material. |
---|
[7057] | 66 | GLenum sFactor; |
---|
| 67 | GLenum tFactor; |
---|
[6622] | 68 | |
---|
[5866] | 69 | Texture* diffuseTexture; //!< The diffuse texture of the Material. |
---|
| 70 | Texture* ambientTexture; //!< The ambient texture of the Material. |
---|
| 71 | Texture* specularTexture; //!< The specular texture of the Material. |
---|
[2776] | 72 | }; |
---|
| 73 | #endif |
---|