#include <dms/Material.h> Material(void); Material(const Vector4& ambientAndDiffuse); Material(const Vector4& ambientAndDiffuse, const Vector4& specular, GLfloat shininess); void apply(void); void disable(void); void setAmbient(const Vector4& color); void setDiffuse(const Vector4& color); void setAmbientAndDiffuse(const Vector4& color); void setSpecular(const Vector4& color); void setEmission(const Vector4& color); void setShininess(GLfloat shininess); Vector4& ambient(void); Vector4& diffuse(void); Vector4& specular(void); Vector4& emission(void); GLfloat shininess(void);
Material(void) Material(const Vector4& ambientAndDiffuse) Material(const Vector4& ambientAndDiffuse, const Vector4& specular, GLfloat shininess);
The default constructor creates a material with the following settings:
ambient | (0.2, 0.2, 0.2, 1) |
diffuse | (0.8, 0.8, 0.8, 1) |
specular | (0, 0, 0, 1) |
shininess | 0 |
emission | (0, 0, 0, 1) |
The other constructors allow you to create a material with the given
ambient/diffuse and specular color values and shininess.
If only the ambientAndDiffuse value is given, the specularity
again defaults to (0, 0, 0, 1).
Example:
dms::Vector4 purple(1.0, 0.0, 0.5, 1.0); dms::Material purpleMaterial(purple); dms::Material shinyMetallicPurpleArmor(purple, dms::Color::White, 60.0);
void apply(void)
Enables GL_LIGHTING, and makes all the necessary calls to glMaterial to
define the material.
Example:
dms::Material red(dms::Color::Red); red.apply();
void disable(void)
Disables GL_LIGHTING.
Example:
dms::Material red(dms::Color::Red); red.apply(); ... red.disable();
void setAmbient(const Vector4& color) Vector4& ambient(void)
Defines / returns the material's ambient color.
Example:
mat.setAmbient(dms::Color::cyan);
void setDiffuse(const Vector4& color) Vector4& diffuse(void)
Defines / returns the material's diffuse color.
Example:
dms::Vector4 brown(0.65, 0.15, 0.15, 1.0); mat.setDiffuse(brown);
void setAmbientAndDiffuse(const Vector4& color)
Defines the material's ambient and diffuse colors to both be the
given value.
Example:
dms::Vector4 brown(0.65, 0.15, 0.15, 1.0); mat.setAmbientAndDiffuse(brown);
void setSpecular(const Vector4& color) Vector4& specular(void)
Defines / returns the material's specular color.
Example:
dms::Vector4 white(1.0, 1.0, 1.0, 1.0); mat.setSpecular(white);
void setShininess(GLfloat exp) GLfloat shininess(void)
Defines / returns the material's specular exponent (shininess).
The value of exp should be in the range 0 to 128; larger
values produce a tighter specular highlight.
Example:
mat.setShininess(45.0);