Magnum::Trade::PhongMaterialData class

Phong material data.

See Material types and convenience accessors for more information about how to use this class.

Base classes

class MaterialData new in Git master
Material data.

Public types

enum class Flag: UnsignedInt { DoubleSided = 1 << 0, AmbientTexture = 1 << 1, DiffuseTexture = 1 << 2, SpecularTexture = 1 << 3, NormalTexture = 1 << 4 new in 2020.06, TextureTransformation = 1 << 5 new in 2020.06, TextureCoordinates = 1 << 6 new in Git master, TextureCoordinateSets = TextureCoordinates deprecated in Git master } deprecated in Git master
Material flag.
using Flags = Containers::EnumSet<Flag> deprecated in Git master
Material flags.

Constructors, destructors, conversion operators

PhongMaterialData(Flags flags, const Color4& ambientColor, UnsignedInt ambientTexture, const Color4& diffuseColor, UnsignedInt diffuseTexture, const Color4& specularColor, UnsignedInt specularTexture, UnsignedInt normalTexture, const Matrix3& textureMatrix, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) deprecated in Git master explicit noexcept
Constructor.
PhongMaterialData(Flags flags, const Color4& ambientColor, UnsignedInt ambientTexture, UnsignedInt ambientTextureCoordinates, const Color4& diffuseColor, UnsignedInt diffuseTexture, UnsignedInt diffuseTextureCoordinates, const Color4& specularColor, UnsignedInt specularTexture, UnsignedInt specularTextureCoordinates, UnsignedInt normalTexture, UnsignedInt normalTextureCoordinates, const Matrix3& textureMatrix, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) deprecated in Git master explicit noexcept
Construct with non-zero texture coordinate sets.
PhongMaterialData(Flags flags, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) deprecated in 2020.06 explicit noexcept
Constructor.

Public functions

auto hasSpecularTexture() const -> bool new in Git master
Whether the material has a specular texture.
auto hasTextureTransformation() const -> bool new in Git master
Whether the material has texture transformation.
auto hasCommonTextureTransformation() const -> bool new in Git master
Whether the material has a common transformation for all textures.
auto hasTextureCoordinates() const -> bool new in Git master
Whether the material uses extra texture coordinate sets.
auto hasCommonTextureCoordinates() const -> bool new in Git master
Whether the material has a common coordinate set for all textures.
auto hasTextureLayer() const -> bool new in Git master
Whether the material uses array texture layers.
auto hasCommonTextureLayer() const -> bool new in Git master
Whether the material has a common array texture layer for all textures.
auto flags() const -> Flags deprecated in Git master
Material flags.
auto ambientColor() const -> Color4
Ambient color.
auto ambientTexture() const -> UnsignedInt
Ambient texture ID.
auto ambientTextureMatrix() const -> Matrix3 new in Git master
Ambient texture coordinate transformation matrix.
auto ambientTextureCoordinates() const -> UnsignedInt new in Git master
Ambient texture coordinate set.
auto ambientCoordinateSet() const -> UnsignedInt deprecated in Git master
Ambient texture coordinate set.
auto ambientTextureLayer() const -> UnsignedInt new in Git master
Ambient array texture layer.
auto diffuseColor() const -> Color4
Diffuse color.
auto diffuseTexture() const -> UnsignedInt
Diffuse texture ID.
auto diffuseTextureMatrix() const -> Matrix3 new in Git master
Diffuse texture coordinate transformation matrix.
auto diffuseTextureCoordinates() const -> UnsignedInt new in Git master
Diffuse texture coordinate set.
auto diffuseCoordinateSet() const -> UnsignedInt deprecated in Git master
Diffuse texture coordinate set.
auto diffuseTextureLayer() const -> UnsignedInt new in Git master
Diffuse array texture layer.
auto specularColor() const -> Color4
Specular color.
auto specularTexture() const -> UnsignedInt
Specular texture ID.
auto specularTextureSwizzle() const -> MaterialTextureSwizzle new in Git master
Specular texture swizzle.
auto specularTextureMatrix() const -> Matrix3 new in Git master
Specular texture coordinate transformation matrix.
auto specularTextureCoordinates() const -> UnsignedInt new in Git master
Specular texture coordinate set.
auto specularCoordinateSet() const -> UnsignedInt deprecated in Git master
Specular texture coordinate set.
auto specularTextureLayer() const -> UnsignedInt new in Git master
Specular array texture layer.
auto normalTexture() const -> UnsignedInt new in 2020.06
Normal texture ID.
auto normalTextureScale() const -> Float new in Git master
Normal texture scale.
auto normalTextureSwizzle() const -> MaterialTextureSwizzle new in Git master
Normal texture swizzle.
auto normalTextureMatrix() const -> Matrix3 new in Git master
Normal texture coordinate transformation matrix.
auto normalTextureCoordinates() const -> UnsignedInt new in Git master
Normal texture coordinate set.
auto normalCoordinateSet() const -> UnsignedInt deprecated in Git master
Normal texture coordinate set.
auto normalTextureLayer() const -> UnsignedInt new in Git master
Normal array texture layer.
auto commonTextureMatrix() const -> Matrix3 new in Git master
Common texture coordinate transformation matrix for all textures.
auto textureMatrix() const -> Matrix3 deprecated in Git master
Common texture coordinate transformation matrix for all textures.
auto commonTextureCoordinates() const -> UnsignedInt new in Git master
Common texture coordinate set for all textures.
auto commonTextureLayer() const -> UnsignedInt new in Git master
Common array texture layer for all textures.
auto shininess() const -> Float
Shininess.

Enum documentation

enum class Magnum::Trade::PhongMaterialData::Flag: UnsignedInt

Material flag.

A superset of MaterialData::Flag.

Enumerators
DoubleSided

The material is double-sided. Back faces should not be culled away but rendered as well, with normals flipped for correct lighting.

AmbientTexture

The material has an ambient texture

DiffuseTexture

The material has a diffuse texture

SpecularTexture

The material has a specular texture

NormalTexture new in 2020.06

The material has a normal texture

TextureTransformation new in 2020.06

The material has a texture coordinate transformation

TextureCoordinates new in Git master

The material uses non-default texture coordinate sets

TextureCoordinateSets

The material uses non-default texture coordinate sets

Typedef documentation

typedef Containers::EnumSet<Flag> Magnum::Trade::PhongMaterialData::Flags

Material flags.

A superset of MaterialData::Flags.

Function documentation

Magnum::Trade::PhongMaterialData::PhongMaterialData(Flags flags, const Color4& ambientColor, UnsignedInt ambientTexture, const Color4& diffuseColor, UnsignedInt diffuseTexture, const Color4& specularColor, UnsignedInt specularTexture, UnsignedInt normalTexture, const Matrix3& textureMatrix, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) explicit noexcept

Constructor.

Parameters
flags Material flags
ambientColor Ambient color. Use 0x000000ff_rgbaf for a default value for a non-textured material and 0xffffffff_rgbaf for a default value for a textured material.
ambientTexture Ambient texture ID. Ignored if flags doesn't have Flag::AmbientTexture.
diffuseColor Diffuse color. Use 0xffffffff_rgbaf for a default value for both a non-textured and a textured material.
diffuseTexture Diffuse texture ID. Ignored if flags doesn't have Flag::DiffuseTexture.
specularColor Specular color. Use 0xffffff00_rgbaf for a default value for both a non-textured and a textured material.
specularTexture Specular texture ID. Ignored if flags doesn't have Flag::SpecularTexture.
normalTexture Normal texture ID. Ignored if flags doesn't have Flag::NormalTexture.
textureMatrix Texture coordinate transformation
alphaMode Alpha mode. Use MaterialAlphaMode::Opaque for a default value.
alphaMask Alpha mask value. Use 0.5f for a default value.
shininess Shininess. Use 80.0f for a default value.
importerState Importer-specific state

All *TextureCoordinates() accessors are implicitly zero with this constructor. If textureMatrix is not default-constructed, expects Flag::TextureTransformation to be enabled as well.

Magnum::Trade::PhongMaterialData::PhongMaterialData(Flags flags, const Color4& ambientColor, UnsignedInt ambientTexture, UnsignedInt ambientTextureCoordinates, const Color4& diffuseColor, UnsignedInt diffuseTexture, UnsignedInt diffuseTextureCoordinates, const Color4& specularColor, UnsignedInt specularTexture, UnsignedInt specularTextureCoordinates, UnsignedInt normalTexture, UnsignedInt normalTextureCoordinates, const Matrix3& textureMatrix, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) explicit noexcept

Construct with non-zero texture coordinate sets.

Parameters
flags Material flags
ambientColor Ambient color. Use 0x000000ff_rgbaf for a default value for a non-textured material and 0xffffffff_rgbaf for a default value for a textured material.
ambientTexture Ambient texture ID. Ignored if flags doesn't have Flag::AmbientTexture.
ambientTextureCoordinates Ambient texture coordinate set. Ignored if flags doesn't have Flag::AmbientTexture
diffuseColor Diffuse color. Use 0xffffffff_rgbaf for a default value for both a non-textured and a textured material.
diffuseTexture Diffuse texture ID. Ignored if flags doesn't have Flag::DiffuseTexture.
diffuseTextureCoordinates Diffuse texture coordinate set. Ignored if flags doesn't have Flag::DiffuseTexture
specularColor Specular color. Use 0xffffff00_rgbaf for a default value for both a non-textured and a textured material.
specularTexture Specular texture ID. Ignored if flags doesn't have Flag::SpecularTexture.
specularTextureCoordinates Specular texture coordinate set. Ignored if flags doesn't have Flag::SpecularTexture.
normalTexture Normal texture ID. Ignored if flags doesn't have Flag::NormalTexture.
normalTextureCoordinates Normal texture coordinate set. Ignored if flags doesn't have Flag::NormalTexture.
textureMatrix Texture coordinate transformation
alphaMode Alpha mode. Use MaterialAlphaMode::Opaque for a default value.
alphaMask Alpha mask value. Use 0.5f for a default value.
shininess Shininess. Use 80.0f for a default value.
importerState Importer-specific state

If textureMatrix is not default-constructed, expects Flag::TextureTransformation to be enabled as well. If any *Coordinates parameter is non-zero, expects Flag::TextureCoordinates to be enabled as well.

Magnum::Trade::PhongMaterialData::PhongMaterialData(Flags flags, MaterialAlphaMode alphaMode, Float alphaMask, Float shininess, const void* importerState = nullptr) explicit noexcept

Constructor.

bool Magnum::Trade::PhongMaterialData::hasSpecularTexture() const new in Git master

Whether the material has a specular texture.

Returns true if any of the MaterialAttribute::SpecularTexture or MaterialAttribute::SpecularGlossinessTexture attributes is present, false otherwise.

bool Magnum::Trade::PhongMaterialData::hasTextureTransformation() const new in Git master

Whether the material has texture transformation.

Returns true if any of the MaterialAttribute::AmbientTextureMatrix, MaterialAttribute::DiffuseTextureMatrix, MaterialAttribute::SpecularTextureMatrix, MaterialAttribute::NormalTextureMatrix or MaterialAttribute::TextureMatrix attributes is present, false otherwise.

bool Magnum::Trade::PhongMaterialData::hasCommonTextureTransformation() const new in Git master

Whether the material has a common transformation for all textures.

Returns true if, for each texture that is present, ambientTextureMatrix(), diffuseTextureMatrix(), specularTextureMatrix() and normalTextureMatrix() have the same value, false otherwise. In particular, returns true also if there's no texture transformation at all. Use hasTextureTransformation() to distinguish that case.

bool Magnum::Trade::PhongMaterialData::hasTextureCoordinates() const new in Git master

Whether the material uses extra texture coordinate sets.

Returns true if any of the MaterialAttribute::AmbientTextureCoordinates, MaterialAttribute::DiffuseTextureCoordinates, MaterialAttribute::SpecularTextureCoordinates, MaterialAttribute::NormalTextureCoordinates or MaterialAttribute::TextureCoordinates attributes is present and has a non-zero value, false otherwise.

bool Magnum::Trade::PhongMaterialData::hasCommonTextureCoordinates() const new in Git master

Whether the material has a common coordinate set for all textures.

Returns true if, for each texture that is present, ambientTextureCoordinates(), diffuseTextureCoordinates(), specularTextureCoordinates() and normalTextureCoordinates() have the same value, false otherwise. In particular, returns true also if there's no extra texture coordinate set used at all. Use hasTextureCoordinates() to distinguish that case.

bool Magnum::Trade::PhongMaterialData::hasTextureLayer() const new in Git master

Whether the material uses array texture layers.

Returns true if any of the MaterialAttribute::AmbientTextureLayer, MaterialAttribute::DiffuseTextureLayer, MaterialAttribute::SpecularTextureLayer, MaterialAttribute::NormalTextureLayer or MaterialAttribute::TextureLayer attributes is present and has a non-zero value, false otherwise.

bool Magnum::Trade::PhongMaterialData::hasCommonTextureLayer() const new in Git master

Whether the material has a common array texture layer for all textures.

Returns true if, for each texture that is present, ambientTextureLayer(), diffuseTextureLayer(), specularTextureLayer() and normalTextureLayer() have the same value, false otherwise. In particular, returns true also if there's no extra texture coordinate set used at all. Use hasTextureLayer() to distinguish that case.

Flags Magnum::Trade::PhongMaterialData::flags() const

Material flags.

A superset of MaterialData::flags().

Color4 Magnum::Trade::PhongMaterialData::ambientColor() const

Ambient color.

Convenience access to the MaterialAttribute::AmbientColor attribute. If not present, the default is either 0xffffffff_rgbaf if there's MaterialAttribute::AmbientTexture and 0x000000ff_rgbaf otherwise.

If the material has MaterialAttribute::AmbientTexture, the color and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PhongMaterialData::ambientTexture() const

Ambient texture ID.

Available only if MaterialAttribute::AmbientTexture is present. Meant to be multiplied with ambientColor().

Matrix3 Magnum::Trade::PhongMaterialData::ambientTextureMatrix() const new in Git master

Ambient texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::AmbientTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::AmbientTexture.

UnsignedInt Magnum::Trade::PhongMaterialData::ambientTextureCoordinates() const new in Git master

Ambient texture coordinate set.

Convenience access to the MaterialAttribute::AmbientTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::AmbientTexture.

UnsignedInt Magnum::Trade::PhongMaterialData::ambientCoordinateSet() const

Ambient texture coordinate set.

UnsignedInt Magnum::Trade::PhongMaterialData::ambientTextureLayer() const new in Git master

Ambient array texture layer.

Convenience access to the MaterialAttribute::AmbientTextureLayer / MaterialAttribute::TextureLayer attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::AmbientTexture.

Color4 Magnum::Trade::PhongMaterialData::diffuseColor() const

Diffuse color.

Convenience access to the MaterialAttribute::DiffuseColor attribute. If not present, the default is 0xffffffff_rgbaf.

If the material has MaterialAttribute::DiffuseTexture, the color and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PhongMaterialData::diffuseTexture() const

Diffuse texture ID.

Available only if MaterialAttribute::DiffuseTexture is present. Meant to be multiplied with diffuseColor().

Matrix3 Magnum::Trade::PhongMaterialData::diffuseTextureMatrix() const new in Git master

Diffuse texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::DiffuseTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::DiffuseTexture.

UnsignedInt Magnum::Trade::PhongMaterialData::diffuseTextureCoordinates() const new in Git master

Diffuse texture coordinate set.

Convenience access to the MaterialAttribute::DiffuseTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::DiffuseTexture.

UnsignedInt Magnum::Trade::PhongMaterialData::diffuseCoordinateSet() const

Diffuse texture coordinate set.

UnsignedInt Magnum::Trade::PhongMaterialData::diffuseTextureLayer() const new in Git master

Diffuse array texture layer.

Convenience access to the MaterialAttribute::DiffuseTextureLayer / MaterialAttribute::TextureLayer attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::DiffuseTexture.

Color4 Magnum::Trade::PhongMaterialData::specularColor() const

Specular color.

Convenience access to the MaterialAttribute::SpecularColor attribute. If not present, the default is 0xffffff00_rgbaf.

If the material has a specular texture, the color and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PhongMaterialData::specularTexture() const

Specular texture ID.

Available only if either MaterialAttribute::SpecularTexture or MaterialAttribute::SpecularGlossinessTexture is present. Meant to be multiplied with specularColor().

MaterialTextureSwizzle Magnum::Trade::PhongMaterialData::specularTextureSwizzle() const new in Git master

Specular texture swizzle.

If MaterialAttribute::SpecularGlossinessTexture is present, returns always MaterialTextureSwizzle::RGB. Otherwise returns the MaterialAttribute::SpecularTextureSwizzle attribute, or MaterialTextureSwizzle::RGB if it's not present. Available only if the material has a specular texture.

Matrix3 Magnum::Trade::PhongMaterialData::specularTextureMatrix() const new in Git master

Specular texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::SpecularTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has a specular texture.

UnsignedInt Magnum::Trade::PhongMaterialData::specularTextureCoordinates() const new in Git master

Specular texture coordinate set.

Convenience access to the MaterialAttribute::SpecularTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has a specular texture.

UnsignedInt Magnum::Trade::PhongMaterialData::specularCoordinateSet() const

Specular texture coordinate set.

UnsignedInt Magnum::Trade::PhongMaterialData::specularTextureLayer() const new in Git master

Specular array texture layer.

Convenience access to the MaterialAttribute::SpecularTextureLayer / MaterialAttribute::TextureLayer attributes. If neither is present, the default is 0. Available only if the material has a specular texture.

UnsignedInt Magnum::Trade::PhongMaterialData::normalTexture() const new in 2020.06

Normal texture ID.

Available only if MaterialAttribute::NormalTexture is present.

Float Magnum::Trade::PhongMaterialData::normalTextureScale() const new in Git master

Normal texture scale.

Convenience access to the MaterialAttribute::NormalTextureScale attribute. If not present, the default is 1.0f. Available only if MaterialAttribute::NormalTexture is present.

MaterialTextureSwizzle Magnum::Trade::PhongMaterialData::normalTextureSwizzle() const new in Git master

Normal texture swizzle.

Convenience access to the MaterialAttribute::NormalTextureSwizzle attribute. If not present, the default is MaterialTextureSwizzle::RGB. Available only if MaterialAttribute::NormalTexture is present.

Matrix3 Magnum::Trade::PhongMaterialData::normalTextureMatrix() const new in Git master

Normal texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::NormalTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::NormalTexture.

UnsignedInt Magnum::Trade::PhongMaterialData::normalTextureCoordinates() const new in Git master

Normal texture coordinate set.

Convenience access to the MaterialAttribute::NormalTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::NormalTexture.

UnsignedInt Magnum::Trade::PhongMaterialData::normalCoordinateSet() const

Normal texture coordinate set.

UnsignedInt Magnum::Trade::PhongMaterialData::normalTextureLayer() const new in Git master

Normal array texture layer.

Convenience access to the MaterialAttribute::NormalTextureLayer / MaterialAttribute::TextureLayer attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::NormalTexture.

Matrix3 Magnum::Trade::PhongMaterialData::commonTextureMatrix() const new in Git master

Common texture coordinate transformation matrix for all textures.

Expects that hasCommonTextureTransformation() is true; returns a matrix that's the same for all of ambientTextureMatrix(), diffuseTextureMatrix(), specularTextureMatrix() and normalTextureMatrix() where a texture is present. If no texture is present, returns an identity matrix.

Matrix3 Magnum::Trade::PhongMaterialData::textureMatrix() const

Common texture coordinate transformation matrix for all textures.

UnsignedInt Magnum::Trade::PhongMaterialData::commonTextureCoordinates() const new in Git master

Common texture coordinate set for all textures.

Expects that hasCommonTextureCoordinates() is true; returns a coordinate set that's the same for all of ambientTextureCoordinates(), diffuseTextureCoordinates(), specularTextureCoordinates() and normalTextureCoordinates() where a texture is present. If no texture is present, returns 0.

UnsignedInt Magnum::Trade::PhongMaterialData::commonTextureLayer() const new in Git master

Common array texture layer for all textures.

Expects that hasCommonTextureLayer() is true; returns a layer that's the same for all of ambientTextureLayer(), diffuseTextureLayer(), specularTextureLayer() and normalTextureLayer() where a texture is present. If no texture is present, returns 0.

Float Magnum::Trade::PhongMaterialData::shininess() const

Shininess.

Convenience access to the MaterialAttribute::Shininess attribute. If not present, the default is 80.0f.

Debug& operator<<(Debug& debug, PhongMaterialData::Flag value)

Debug output operator.

Debug& operator<<(Debug& debug, PhongMaterialData::Flags value)

Debug output operator.