[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 | |
---|
[7510] | 16 | #include <vector> |
---|
[3894] | 17 | |
---|
[7510] | 18 | |
---|
[6769] | 19 | #include "texture.h" |
---|
| 20 | |
---|
[5405] | 21 | // FORWARD DECLARATIONS // |
---|
[3140] | 22 | |
---|
[2842] | 23 | //! Class to handle Materials. |
---|
[4584] | 24 | class Material : public BaseObject |
---|
[2776] | 25 | { |
---|
[7510] | 26 | public: |
---|
| 27 | Material (const std::string& mtlName = ""); |
---|
| 28 | virtual ~Material (); |
---|
[2778] | 29 | |
---|
[7510] | 30 | Material& operator=(const Material& material); |
---|
[6622] | 31 | |
---|
[7510] | 32 | bool select () const; |
---|
[2776] | 33 | |
---|
[7510] | 34 | void setIllum (int illum); |
---|
| 35 | int getIllumModel() const { return this->illumModel; }; |
---|
| 36 | void setDiffuse (float r, float g, float b); |
---|
| 37 | void setAmbient (float r, float g, float b); |
---|
| 38 | void setSpecular (float r, float g, float b); |
---|
| 39 | void setShininess (float shini); |
---|
| 40 | void setTransparency (float trans); |
---|
| 41 | void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; |
---|
[3070] | 42 | |
---|
[4466] | 43 | |
---|
[7510] | 44 | // TODO Move them out of here |
---|
| 45 | void setIllum (char* illum); |
---|
| 46 | void setDiffuse (char* rgb); |
---|
| 47 | void setAmbient (char* rgb); |
---|
| 48 | void setSpecular (char* rgb); |
---|
| 49 | void setShininess (char* shini); |
---|
| 50 | void setTransparency (char* trans); |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | // MAPPING // |
---|
| 54 | void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); |
---|
| 55 | |
---|
| 56 | void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D); |
---|
| 57 | void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D); |
---|
| 58 | void setBump(const std::string& bump); |
---|
| 59 | GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i]->getTexture() : 0; }; |
---|
| 60 | |
---|
| 61 | static void addTexturePath(const std::string& pathName); |
---|
| 62 | |
---|
| 63 | public: |
---|
| 64 | static const GLenum glTextureArbs[]; //!< The Texture ARB's |
---|
| 65 | |
---|
| 66 | static int getMaxTextureUnits(); |
---|
| 67 | |
---|
[5866] | 68 | private: |
---|
[7513] | 69 | static Material* selectedMaterial; //!< The currently selected material. |
---|
[6622] | 70 | |
---|
[7513] | 71 | int illumModel; //!< The IlluminationModel is either flat or smooth. |
---|
| 72 | float diffuse [4]; //!< The diffuse color of the Material. |
---|
| 73 | float ambient [4]; //!< The ambient color of the Material. |
---|
| 74 | float specular [4]; //!< The specular color of the Material. |
---|
| 75 | float shininess; //!< The shininess of the Material. |
---|
| 76 | float transparency; //!< The transperency of the Material. |
---|
| 77 | GLenum sFactor; |
---|
| 78 | GLenum tFactor; |
---|
[7510] | 79 | |
---|
[7513] | 80 | std::vector<Texture*> textures; //!< An Array of Textures. |
---|
[7510] | 81 | |
---|
[7513] | 82 | Texture* ambientTexture; //!< The ambient texture of the Material. |
---|
| 83 | Texture* specularTexture; //!< The specular texture of the Material. |
---|
[7510] | 84 | |
---|
[7513] | 85 | |
---|
[2776] | 86 | }; |
---|
| 87 | #endif |
---|