Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/graphics/importer/material.h @ 9828

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

orxonox/new_class_id: now it should also be possible, to cache the resources, by suppling a LoadString.
This is vital to loading Resources, when you only know the TypeName and a LoadString, but not the c++-type and the LoadParameters as is the case when loading over the internet.

File size: 3.7 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{
[9715]26  ObjectListDeclaration(Material);
[8619]27public:
28  Material (const std::string& mtlName = "");
29  virtual ~Material ();
[2778]30
[9823]31  Material& operator=(const Material& material);
32
[8619]33  void loadParams(const TiXmlElement* root);
[6622]34
[8619]35  bool select () const;
36  bool activateTextureUnit(unsigned int textureNumber);
37  static void unselect();
[8376]38
[8619]39  void setIllum (int illum);
40  int getIllumModel() const { return this->illumModel; };
[2776]41
[8619]42  void setDiffuse (float r, float g, float b);
43  void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
44  void setAmbient (float r, float g, float b);
45  void setSpecular (float r, float g, float b);
46  void setShininess (float shini);
47  void setTransparency (float trans);
48  void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
49  void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
[7785]50
[8619]51  Color& diffuseColor() { return diffuse; };
52  const Color& diffuseColor() const { return diffuse; };
[7785]53
[8619]54  // MAPPING //
55  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
[9718]56  void setDiffuseMap(const TextureData::Pointer& texturePointer, unsigned int textureNumber = 0);
[8619]57  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
58  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
59  void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
[7785]60
[8619]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);
[7785]64
[8619]65  GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
[7785]66
[8619]67  const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
[7785]68
[8619]69  static void addTexturePath(const std::string& pathName);
[6622]70
[8761]71  static const std::string& blendFuncToString(GLenum blendFunc);
72  static GLenum stringToBlendFunc(const std::string& blendFuncString);
[7785]73
[8761]74  void debug() const;
[7785]75
[8619]76public:
77  static const GLenum glTextureArbs[];  //!< The Texture ARB's
78
79  static const GLenum glBlendFuncParams[];
80  static const std::string blendFuncNames[];
81
82  static unsigned int getMaxTextureUnits();
83
84private:
85  static const Material* selectedMaterial; //!< The currently selected material.
86
87  int              illumModel;       //!< The IlluminationModel is either flat or smooth.
88  Color            diffuse;          //!< The diffuse color of the Material. (also transparency.)
89  Color            ambient;          //!< The ambient color of the Material.
90  Color            specular;         //!< The specular color of the Material.
91  float            shininess;        //!< The shininess of the Material.
92  GLenum           sFactor;          //!< The Blending Factor for the Source.
93  GLenum           tFactor;          //!< The Blending Factor for the Destination.
94
95  std::vector<Texture> textures;     //!< An Array of Textures.
96
97  Texture*         ambientTexture;   //!< The ambient texture of the Material.
98  Texture*         specularTexture;  //!< The specular texture of the Material.
[8370]99};
[7785]100
[2776]101#endif
Note: See TracBrowser for help on using the repository browser.