Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/material.h @ 8433

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

orxonox/trunk: no more seg-fault when copying a Texture

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 "texture.h"
19#include "color.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    bool activateTextureUnit(unsigned int textureNumber);
34    static void unselect();
35
36    void setIllum (int illum);
37    int getIllumModel() const { return this->illumModel; };
38
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    const Color& getDiffuseColor() const { return diffuse; };
47
48    // MAPPING //
49    void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
50    void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
51    void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
52    void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
53
54    void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
55    void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
56    void setBump(const std::string& bump);
57    GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
58
59    static void addTexturePath(const std::string& pathName);
60
61  public:
62    static const GLenum glTextureArbs[];  //!< The Texture ARB's
63
64    static unsigned int getMaxTextureUnits();
65
66  private:
67    static const Material* selectedMaterial; //!< The currently selected material.
68
69    int              illumModel;       //!< The IlluminationModel is either flat or smooth.
70    Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
71    Color            ambient;          //!< The ambient color of the Material.
72    Color            specular;         //!< The specular color of the Material.
73    float            shininess;        //!< The shininess of the Material.
74    GLenum           sFactor;          //!< The Blending Factor for the Source.
75    GLenum           tFactor;          //!< The Blending Factor for the Destination.
76
77    std::vector<Texture> textures;     //!< An Array of Textures.
78
79    Texture*         ambientTexture;   //!< The ambient texture of the Material.
80    Texture*         specularTexture;  //!< The specular texture of the Material.
81};
82
83#endif
Note: See TracBrowser for help on using the repository browser.