Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged gui back to the trunk
merged with command
merge -r8377:HEAD https://svn.orxonox.net/orxonox/branches/gui .

File size: 3.2 KB
RevLine 
[2842]1/*!
[7785]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 */
[2842]7
[2776]8#ifndef _MATERIAL_H
9#define _MATERIAL_H
[4584]10#include "base_object.h"
[2804]11
[7785]12
[4584]13#if HAVE_CONFIG_H
14#include <config.h>
[3140]15#endif /* HAVE_CONFIG_H */
16
[7785]17#include <vector>
[6769]18#include "texture.h"
[8376]19#include "color.h"
[6769]20
[5405]21// FORWARD DECLARATIONS //
[3140]22
[2842]23//! Class to handle Materials.
[4584]24class Material : public BaseObject
[2776]25{
[7785]26  public:
27    Material (const std::string& mtlName = "");
28    virtual ~Material ();
[2778]29
[7785]30    Material& operator=(const Material& material);
[6622]31
[7785]32    bool select () const;
[8037]33    bool activateTextureUnit(unsigned int textureNumber);
34    static void unselect();
[2778]35
[7785]36    void setIllum (int illum);
37    int getIllumModel() const { return this->illumModel; };
[8376]38
[7785]39    void setDiffuse (float r, float g, float b);
[8448]40    void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
[7785]41    void setAmbient (float r, float g, float b);
42    void setSpecular (float r, float g, float b);
43    void setShininess (float shini);
44    void setTransparency (float trans);
45    void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
[2776]46
[8376]47    const Color& getDiffuseColor() const { return diffuse; };
[7785]48
49    // MAPPING //
[7788]50    void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
[7785]51    void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
52    void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
[8037]53    void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
[7785]54
55    void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
56    void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
57    void setBump(const std::string& bump);
[7788]58    GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
[7785]59
60    static void addTexturePath(const std::string& pathName);
61
62  public:
63    static const GLenum glTextureArbs[];  //!< The Texture ARB's
64
[8316]65    static unsigned int getMaxTextureUnits();
[7785]66
[5866]67  private:
[7785]68    static const Material* selectedMaterial; //!< The currently selected material.
[6622]69
[7785]70    int              illumModel;       //!< The IlluminationModel is either flat or smooth.
[8376]71    Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
72    Color            ambient;          //!< The ambient color of the Material.
73    Color            specular;         //!< The specular color of the Material.
[7785]74    float            shininess;        //!< The shininess of the Material.
[8370]75    GLenum           sFactor;          //!< The Blending Factor for the Source.
76    GLenum           tFactor;          //!< The Blending Factor for the Destination.
[7785]77
[8370]78    std::vector<Texture> textures;     //!< An Array of Textures.
[7785]79
80    Texture*         ambientTexture;   //!< The ambient texture of the Material.
81    Texture*         specularTexture;  //!< The specular texture of the Material.
[8370]82};
[7785]83
[2776]84#endif
Note: See TracBrowser for help on using the repository browser.