Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/water/src/lib/graphics/importer/material.h @ 8025

Last change on this file since 8025 was 8025, checked in by stefalie, 18 years ago

water: activate texture unit…

File size: 3.1 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 "SDL_image.h"
19
20#include "texture.h"
21
22// FORWARD DECLARATIONS //
23
24//! Class to handle Materials.
25class 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    bool activateTextureUnit(unsigned int textureNumber);
35    static void unselect();
36
37    void setIllum (int illum);
38    int getIllumModel() const { return this->illumModel; };
39    void setDiffuse (float r, float g, float b);
40    void setAmbient (float r, float g, float b);
41    void setSpecular (float r, float g, float b);
42    void setShininess (float shini);
43    void setTransparency (float trans);
44    void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
45
46
47    // TODO Move them out of here
48    void setIllum (char* illum);
49    void setDiffuse (char* rgb);
50    void setAmbient (char* rgb);
51    void setSpecular (char* rgb);
52    void setShininess (char* shini);
53    void setTransparency (char* trans);
54
55
56    // MAPPING //
57    void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
58    void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
59    void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
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    GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
65
66    static void addTexturePath(const std::string& pathName);
67
68  public:
69    static const GLenum glTextureArbs[];  //!< The Texture ARB's
70
71    static int getMaxTextureUnits();
72
73  private:
74    static const Material* selectedMaterial; //!< The currently selected material.
75
76    int              illumModel;       //!< The IlluminationModel is either flat or smooth.
77    float            diffuse [4];      //!< The diffuse color of the Material.
78    float            ambient [4];      //!< The ambient color of the Material.
79    float            specular [4];     //!< The specular color of the Material.
80    float            shininess;        //!< The shininess of the Material.
81    float            transparency;     //!< The transperency of the Material.
82    GLenum           sFactor;
83    GLenum           tFactor;
84
85    std::vector<Texture> textures;    //!< An Array of Textures.
86
87    Texture*         ambientTexture;   //!< The ambient texture of the Material.
88    Texture*         specularTexture;  //!< The specular texture of the Material.
89
90
91};
92#endif
Note: See TracBrowser for help on using the repository browser.