Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model/src/lib/graphics/importer/material.h @ 7513

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

material updated, so now select first deselects tho old Material

File size: 2.8 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#if HAVE_CONFIG_H
13#include <config.h>
14#endif /* HAVE_CONFIG_H */
15
16#include <vector>
17
18
19#include "texture.h"
20
21// FORWARD DECLARATIONS //
22
23//! Class to handle Materials.
24class Material : public BaseObject
25{
26  public:
27    Material (const std::string& mtlName = "");
28    virtual ~Material ();
29
30    Material& operator=(const Material& material);
31
32    bool select () const;
33
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; };
42
43
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
68  private:
69    static Material* selectedMaterial; //!< The currently selected material.
70
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;
79
80    std::vector<Texture*> textures;    //!< An Array of Textures.
81
82    Texture*         ambientTexture;   //!< The ambient texture of the Material.
83    Texture*         specularTexture;  //!< The specular texture of the Material.
84
85
86};
87#endif
Note: See TracBrowser for help on using the repository browser.