Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# irr::video::SMaterial Class Reference

Struct for holding parameters for a material renderer. More...

`#include <SMaterial.h>`

List of all members.

## Public Member Functions
bool | getFlag (E_MATERIAL_FLAG flag) const
| Gets the Material flag.
ITexture * | getTexture (u32 i) const
| Gets the i-th texture.
const core::matrix4 & | getTextureMatrix (u32 i) const
| Gets the immutable texture transformation matrix for level i.
core::matrix4 & | getTextureMatrix (u32 i)
| Gets the texture transformation matrix for level i.
bool | isTransparent () const
bool | operator!= (const SMaterial &b) const
| Inequality operator.
SMaterial & | operator= (const SMaterial &other)
| Assignment operator.
bool | operator== (const SMaterial &b) const
| Equality operator.
void | setFlag (E_MATERIAL_FLAG flag, bool value)
| Sets the Material flag to the given value.
void | setTexture (u32 i, ITexture *tex)
| Sets the i-th texture.
void | setTextureMatrix (u32 i, const core::matrix4 &mat)
| Sets the i-th texture transformation matrix.
| SMaterial (const SMaterial &other)
| Copy constructor.
| SMaterial ()
| Default constructor. Creates a solid, lit material with white colors.
## Public Attributes
SColor | AmbientColor
| How much ambient light (a global light) is reflected by this material.
u8 | AntiAliasing
| Sets the antialiasing mode.
bool | BackfaceCulling:1
| Is backface culling enabled? Default: true.
u8 | ColorMask:4
| Defines the enabled color planes.
u8 | ColorMaterial:3
| Defines the interpretation of vertex color in the lighting equation.
SColor | DiffuseColor
| How much diffuse light coming from a light source is reflected by this material.
SColor | EmissiveColor
| Light emitted by this material. Default is to emit no light.
bool | FogEnable:1
| Is fog enabled? Default: false.
bool | FrontfaceCulling:1
| Is frontface culling enabled? Default: false.
bool | GouraudShading:1
| Flat or Gouraud shading? Default: true.
bool | Lighting:1
| Will this material be lighted? Default: true.
E_MATERIAL_TYPE | MaterialType
| Type of the material. Specifies how everything is blended together.
f32 | MaterialTypeParam
| Free parameter, dependent on the material type.
f32 | MaterialTypeParam2
| Second free parameter, dependent on the material type.
bool | NormalizeNormals:1
| Should normals be normalized?
bool | PointCloud:1
| Draw as point cloud or filled triangles? Default: false.
f32 | Shininess
| Value affecting the size of specular highlights.
SColor | SpecularColor
| How much specular light (highlights from a light) is reflected.
SMaterialLayer | TextureLayer [MATERIAL_MAX_TEXTURES]
| Texture layer array.
f32 | Thickness
| Thickness of non-3dimensional elements such as lines and points.
bool | Wireframe:1
| Draw as wireframe or filled triangles? Default: false.
u8 | ZBuffer
| Is the ZBuffer enabled? Default: ECFN_LESSEQUAL.
bool | ZWriteEnable:1
| Is the zbuffer writeable or is it read-only. Default: true.

## Detailed Description

Struct for holding parameters for a material renderer.

Definition at line 189 of file SMaterial.h.

## Constructor & Destructor Documentation

irr::video::SMaterial::SMaterial | ( |  | ) | `[inline]`

Default constructor. Creates a solid, lit material with white colors.

Definition at line 193 of file SMaterial.h.

irr::video::SMaterial::SMaterial | ( | const SMaterial & | other | ) | `[inline]`

Copy constructor.

Parameters:

  | other | Material to copy from.

Definition at line 205 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, and TextureLayer.

## Member Function Documentation

bool irr::video::SMaterial::getFlag | ( | E_MATERIAL_FLAG | flag | ) | const`[inline]`

Gets the Material flag.

Parameters:

  | flag | The flag to query.

Returns:
  The current value of the flag.

Definition at line 500 of file SMaterial.h.

References irr::video::SMaterialLayer::AnisotropicFilter, AntiAliasing, BackfaceCulling, irr::video::SMaterialLayer::BilinearFilter, ColorMask, ColorMaterial, irr::video::ECFN_NEVER, irr::video::ECM_NONE, irr::video::ECP_NONE, irr::video::EMF_ANISOTROPIC_FILTER, irr::video::EMF_ANTI_ALIASING, irr::video::EMF_BACK_FACE_CULLING, irr::video::EMF_BILINEAR_FILTER, irr::video::EMF_COLOR_MASK, irr::video::EMF_COLOR_MATERIAL, irr::video::EMF_FOG_ENABLE, irr::video::EMF_FRONT_FACE_CULLING, irr::video::EMF_GOURAUD_SHADING, irr::video::EMF_LIGHTING, irr::video::EMF_NORMALIZE_NORMALS, irr::video::EMF_POINTCLOUD, irr::video::EMF_TEXTURE_WRAP, irr::video::EMF_TRILINEAR_FILTER, irr::video::EMF_WIREFRAME, irr::video::EMF_ZBUFFER, irr::video::EMF_ZWRITE_ENABLE, FogEnable, FrontfaceCulling, GouraudShading, Lighting, NormalizeNormals, PointCloud, TextureLayer, irr::video::SMaterialLayer::TextureWrap, irr::video::SMaterialLayer::TrilinearFilter, Wireframe, ZBuffer, and ZWriteEnable.

ITexture* irr::video::SMaterial::getTexture | ( | u32 | i | ) | const`[inline]`

Gets the i-th texture.

Parameters:

  | i | The desired level.

Returns:
  Texture for texture level i, if defined, else 0.

Definition at line 412 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, irr::video::SMaterialLayer::Texture, and TextureLayer.

const core::matrix4& irr::video::SMaterial::getTextureMatrix | ( | u32 | i | ) | const`[inline]`

Gets the immutable texture transformation matrix for level i.

Parameters:

  | i | The desired level.

Returns:
  Texture matrix for texture level i, or identity matrix for levels larger than MATERIAL_MAX_TEXTURES.

Definition at line 391 of file SMaterial.h.

References irr::video::SMaterialLayer::getTextureMatrix(), irr::core::IdentityMatrix, irr::video::MATERIAL_MAX_TEXTURES, and TextureLayer.

core::matrix4& irr::video::SMaterial::getTextureMatrix | ( | u32 | i | ) | `[inline]`

Gets the texture transformation matrix for level i.

Parameters:

  | i | The desired level. Must not be larger than MATERIAL_MAX_TEXTURES.

Returns:
  Texture matrix for texture level i.

Definition at line 383 of file SMaterial.h.

References irr::video::SMaterialLayer::getTextureMatrix(), and TextureLayer.

bool irr::video::SMaterial::isTransparent | ( |  | ) | const`[inline]`

Definition at line 587 of file SMaterial.h.

References irr::video::EMT_TRANSPARENT_ADD_COLOR, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, irr::video::EMT_TRANSPARENT_REFLECTION_2_LAYER, irr::video::EMT_TRANSPARENT_VERTEX_ALPHA, and MaterialType.

bool irr::video::SMaterial::operator!= | ( | const SMaterial & | b | ) | const`[inline]`

Inequality operator.

Parameters:

  | b | Material to compare to.

Returns:
  True if the materials differ, else false.

Definition at line 549 of file SMaterial.h.

References AmbientColor, AntiAliasing, BackfaceCulling, ColorMask, ColorMaterial, DiffuseColor, EmissiveColor, FogEnable, FrontfaceCulling, GouraudShading, Lighting, irr::video::MATERIAL_MAX_TEXTURES, MaterialType, MaterialTypeParam, MaterialTypeParam2, NormalizeNormals, PointCloud, Shininess, SpecularColor, TextureLayer, Thickness, Wireframe, ZBuffer, and ZWriteEnable.

SMaterial& irr::video::SMaterial::operator= | ( | const SMaterial & | other | ) | `[inline]`

Assignment operator.

Parameters:

  | other | Material to copy from.

Definition at line 215 of file SMaterial.h.

References AmbientColor, AntiAliasing, BackfaceCulling, ColorMask, ColorMaterial, DiffuseColor, EmissiveColor, FogEnable, FrontfaceCulling, GouraudShading, Lighting, irr::video::MATERIAL_MAX_TEXTURES, MaterialType, MaterialTypeParam, MaterialTypeParam2, NormalizeNormals, PointCloud, Shininess, SpecularColor, TextureLayer, Thickness, Wireframe, ZBuffer, and ZWriteEnable.

bool irr::video::SMaterial::operator== | ( | const SMaterial & | b | ) | const`[inline]`

Equality operator.

Parameters:

  | b | Material to compare to.

Returns:
  True if the materials are equal, else false.

Definition at line 584 of file SMaterial.h.

void irr::video::SMaterial::setFlag | ( | E_MATERIAL_FLAG | flag,
|  | bool | value |
| ) |  |  | `[inline]`

Sets the Material flag to the given value.

Parameters:

  | flag | The flag to be set.
  | value | The new value for the flag.

Definition at line 431 of file SMaterial.h.

References AntiAliasing, BackfaceCulling, ColorMask, ColorMaterial, irr::video::EAAM_OFF, irr::video::EAAM_SIMPLE, irr::video::ECM_DIFFUSE, irr::video::ECM_NONE, irr::video::ECP_ALL, irr::video::ECP_NONE, irr::video::EMF_ANISOTROPIC_FILTER, irr::video::EMF_ANTI_ALIASING, irr::video::EMF_BACK_FACE_CULLING, irr::video::EMF_BILINEAR_FILTER, irr::video::EMF_COLOR_MASK, irr::video::EMF_COLOR_MATERIAL, irr::video::EMF_FOG_ENABLE, irr::video::EMF_FRONT_FACE_CULLING, irr::video::EMF_GOURAUD_SHADING, irr::video::EMF_LIGHTING, irr::video::EMF_NORMALIZE_NORMALS, irr::video::EMF_POINTCLOUD, irr::video::EMF_TEXTURE_WRAP, irr::video::EMF_TRILINEAR_FILTER, irr::video::EMF_WIREFRAME, irr::video::EMF_ZBUFFER, irr::video::EMF_ZWRITE_ENABLE, FogEnable, FrontfaceCulling, GouraudShading, Lighting, irr::video::MATERIAL_MAX_TEXTURES, NormalizeNormals, PointCloud, TextureLayer, Wireframe, ZBuffer, and ZWriteEnable.

Referenced by irr::scene::ISceneNode::setMaterialFlag().

void irr::video::SMaterial::setTexture | ( | u32 | i,
|  | ITexture * | tex |
| ) |  |  | `[inline]`

Sets the i-th texture.

If i>=MATERIAL_MAX_TEXTURES this setting will be ignored.

Parameters:

  | i | The desired level.
  | tex | Texture for texture level i.

Definition at line 421 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, irr::video::SMaterialLayer::Texture, and TextureLayer.

Referenced by irr::scene::ISceneNode::setMaterialTexture().

void irr::video::SMaterial::setTextureMatrix | ( | u32 | i,
|  | const core::matrix4 & | mat |
| ) |  |  | `[inline]`

Sets the i-th texture transformation matrix.

Parameters:

  | i | The desired level.
  | mat | Texture matrix for texture level i.

Definition at line 402 of file SMaterial.h.

References irr::video::MATERIAL_MAX_TEXTURES, irr::video::SMaterialLayer::setTextureMatrix(), and TextureLayer.

## Member Data Documentation

SColor irr::video::SMaterial::AmbientColor

How much ambient light (a global light) is reflected by this material.

The default is full white, meaning objects are completely globally illuminated. Reduce this if you want to see diffuse or specular light effects.

Definition at line 263 of file SMaterial.h.

Referenced by operator!=(), and operator=().

u8 irr::video::SMaterial::AntiAliasing

Sets the antialiasing mode.

Values are chosen from E_ANTI_ALIASING_MODE. Default is EAAM_SIMPLE|EAAM_LINE_SMOOTH, i.e. simple multi-sample anti-aliasing and lime smoothing is enabled.

Definition at line 329 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

bool irr::video::SMaterial::BackfaceCulling

Is backface culling enabled? Default: true.

Definition at line 368 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

u8 irr::video::SMaterial::ColorMask

Defines the enabled color planes.

Values are defined as or'ed values of the E_COLOR_PLANE enum. Only enabled color planes will be rendered to the current render target. Typical use is to disable all colors when rendering only to depth or stencil buffer, or using Red and Green for Stereo rendering.

Definition at line 336 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

u8 irr::video::SMaterial::ColorMaterial

Defines the interpretation of vertex color in the lighting equation.

Values should be chosen from E_COLOR_MATERIAL. When lighting is enabled, vertex color can be used instead of the material values for light modulation. This allows to easily change e.g. the diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in a very similar rendering as with lighting turned off, just with light shading.

Definition at line 344 of file SMaterial.h.

Referenced by getFlag(), operator!=(), operator=(), and setFlag().

SColor irr::video::SMaterial::DiffuseColor

How much diffuse light coming from a light source is reflected by this material.

The default is full white.

Definition at line 267 of file SMaterial.h.

Referenced by operator!=(), and operator=().

SColor irr::video::SMaterial::EmissiveColor

Light emitted by this material. Default is to emit no light.

Definition at line 270 of file SMaterial.h.

Referenced by operator!=(), and operator=().

bool irr::video::SMaterial::FogEnable

Is fog enabled? Default: false.

Definition at line 374 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

bool irr::video::SMaterial::FrontfaceCulling

Is frontface culling enabled? Default: false.

Definition at line 371 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

bool irr::video::SMaterial::GouraudShading

Flat or Gouraud shading? Default: true.

Definition at line 356 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

bool irr::video::SMaterial::Lighting

Will this material be lighted? Default: true.

Definition at line 359 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

E_MATERIAL_TYPE irr::video::SMaterial::MaterialType

Type of the material. Specifies how everything is blended together.

Definition at line 257 of file SMaterial.h.

Referenced by isTransparent(), operator!=(), operator=(), and irr::scene::ISceneNode::setMaterialType().

f32 irr::video::SMaterial::MaterialTypeParam

Free parameter, dependent on the material type.

Mostly ignored, used for example in EMT_PARALLAX_MAP_SOLID and EMT_TRANSPARENT_ALPHA_CHANNEL.

Definition at line 312 of file SMaterial.h.

Referenced by operator!=(), and operator=().

f32 irr::video::SMaterial::MaterialTypeParam2

Second free parameter, dependent on the material type.

Mostly ignored.

Definition at line 316 of file SMaterial.h.

Referenced by operator!=(), and operator=().

bool irr::video::SMaterial::NormalizeNormals

Should normals be normalized?

Always use this if the mesh lit and scaled. Default: false

Definition at line 378 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

bool irr::video::SMaterial::PointCloud

Draw as point cloud or filled triangles? Default: false.

Definition at line 353 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

f32 irr::video::SMaterial::Shininess

Value affecting the size of specular highlights.

A value of 20 is common. If set to 0, no specular highlights are being used. To activate, simply set the shininess of a material to a value in the range [0.5;128]:

                    sceneNode->getMaterial(0).Shininess = 20.0f;

You can change the color of the highlights using

                    sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);

The specular color of the dynamic lights (SLight::SpecularColor) will influence the the highlight color too, but they are set to a useful value by default when creating the light scene node. Here is a simple example on how to use specular highlights:

                    // load and display mesh
                    scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(
                    smgr->getMesh("data/faerie.md2"));
                    node->setMaterialTexture(0, driver->getTexture("data/Faerie2.pcx")); // set diffuse texture
                    node->setMaterialFlag(video::EMF_LIGHTING, true); // enable dynamic lighting
                    node->getMaterial(0).Shininess = 20.0f; // set size of specular highlights

                    // add white light
                    scene::ILightSceneNode* light = smgr->addLightSceneNode(0,
                            core::vector3df(5,5,5), video::SColorf(1.0f, 1.0f, 1.0f));

Definition at line 307 of file SMaterial.h.

Referenced by operator!=(), and operator=().

SColor irr::video::SMaterial::SpecularColor

How much specular light (highlights from a light) is reflected.

The default is to reflect white specular light. See SMaterial::Shininess on how to enable specular lights.

Definition at line 275 of file SMaterial.h.

Referenced by operator!=(), and operator=().

SMaterialLayer irr::video::SMaterial::TextureLayer[MATERIAL_MAX_TEXTURES]

Texture layer array.

Definition at line 254 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), getTexture(), getTextureMatrix(), operator!=(), operator=(), setFlag(), setTexture(), setTextureMatrix(), and SMaterial().

f32 irr::video::SMaterial::Thickness

Thickness of non-3dimensional elements such as lines and points.

Definition at line 319 of file SMaterial.h.

Referenced by operator!=(), and operator=().

bool irr::video::SMaterial::Wireframe

Draw as wireframe or filled triangles? Default: false.

The user can access a material flag using

     material.Wireframe=true

or

     material.setFlag(EMF_WIREFRAME, true);

Definition at line 350 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

u8 irr::video::SMaterial::ZBuffer

Is the ZBuffer enabled? Default: ECFN_LESSEQUAL.

Values are from E_COMPARISON_FUNC.

Definition at line 323 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

bool irr::video::SMaterial::ZWriteEnable

Is the zbuffer writeable or is it read-only. Default: true.

This flag is forced to false if the MaterialType is a transparent type and the scene parameter ALLOW_ZWRITE_ON_TRANSPARENT is not set.

Definition at line 365 of file SMaterial.h.

Referenced by irr::video::SOverrideMaterial::apply(), getFlag(), operator!=(), operator=(), and setFlag().

The documentation for this class was generated from the following file:

- SMaterial.h

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:20 2010 by Doxygen (1.5.6)