Magnum::Trade::MaterialData class new in Git master

Material data.

Key-value store for builtin as well as custom material attributes, with an ability to define additional layers further affecting the base material. Populated instances of this class are returned from AbstractImporter::material().

Usage

The simplest usage is through templated attribute() functions, which take a string attribute name or one of the pre-defined MaterialAttribute values. You're expected to check for attribute presence first with hasAttribute(), and the requested type has to match attributeType(). To make things easier, each of the attributes defined in MaterialAttribute has a strictly defined type, so you can safely assume the type when requesting those. In addition there's findAttribute() and attributeOr() that return a Containers::NullOpt or a default value in case given attribute is not found.

Trade::MaterialData data = ;

// Assumes the attribute exists
Float roughness = data.attribute<Float>(Trade::MaterialAttribute::Roughness);

// Optional access
Color4 color = data.attributeOr(Trade::MaterialAttribute::BaseColor,
                                0x3bd267ff_srgbaf);
if(Containers::Optional<UnsignedInt> texture =
   data.findAttribute<UnsignedInt>(Trade::MaterialAttribute::BaseColorTexture))
{
    // ...
}

It's also possible to iterate through all attributes using attributeName(), attributeType() and attribute() taking indices instead of names, with attributeCount() returning the total attribute count.

Material types and convenience accessors

A material usually consists of a set of attributes for a particular rendering workflow — PBR metallic/roughness, Phong or for example flat-shaded materials. To hint what the material contains, types() returns a set of MaterialType values. It's not just a single value as the data can define attributes for more than one material type (for example both metallic/roughness and specular/glossiness PBR workflow), allowing the application to pick the best type for a particular use case.

Because retrieving everything through the attribute() APIs can get verbose and complex, the Trade library provides a set of accessor APIs for common material types such as FlatMaterialData, PhongMaterialData, PbrMetallicRoughnessMaterialData or PbrSpecularGlossinessMaterialData. Using as() you can convert any MaterialData instance to a reference to one of those. These convenience APIs then take care of default values when an attribute isn't present or handle fallbacks when an attribute can be defined in multiple ways:

/* Prefer a specular/glossiness workflow, if present */
if(data.types() & Trade::MaterialType::PbrSpecularGlossiness) {
    const auto& pbr = data.as<Trade::PbrSpecularGlossinessMaterialData>();

    Color4 diffuse = pbr.diffuseColor();
    Color4 specular = pbr.specularColor();
    Float glossiness = pbr.glossiness();

    

/* Otherwise use metallic/roughness (or defaults if no attributes present) */
} else {
    const auto& pbr = data.as<Trade::PbrMetallicRoughnessMaterialData>();

    Color4 base = pbr.baseColor();
    Float metalness = pbr.metalness();
    Float roughness = pbr.roughness();

    
}

Each MaterialAttribute is exposed through one or more of those convenience APIs, see the documentation of of a particular enum value for more information.

Texture packing, coordinate transformation and coordinate sets

The material APIs allow for a lot of flexibility — texture maps may be arbitrarily packed together to efficiently use all four channels, each texture can use a different set of texture coordinates and there can be a different coordinate transformation for each texture.

In most cases, however, real-world textures fit into a few well-known packing schemes and usually have a common transformation and coordinate sets for all. Checking for all corner cases on the application side would be a headache, so there are queries like PbrSpecularGlossinessMaterialData::hasSpecularGlossinessTexture() or PbrSpecularGlossinessMaterialData::hasCommonTextureTransformation() to help narrowing the options down:

Trade::PbrSpecularGlossinessMaterialData data = ;

/* Simple case for diffuse + packed specular/glossiness texture, the default
   coordinate set and a common coordinate transformation for all textures */
if(data.hasAttribute(Trade::MaterialAttribute::DiffuseTexture) &&
   data.hasSpecularGlossinessTexture() &&
   data.hasCommonTextureTransformation() && !data.hasTextureCoordinates())
{
    UnsignedInt diffuse = data.diffuseTexture();
    UnsignedInt specularGlossiness = data.specularTexture();
    Matrix3 textureMatrix = data.commonTextureMatrix();

    

/* Extra work needed when using a non-default texture coordinate set */
} else if(data.hasTextureCoordinates() && data.hasCommonTextureCoordinates()) {
    

/* Etc... */
} else Fatal{} << "Material too complex, giving up";

Material layers

In addition to the base material, there can be material layers. While a material attribute can be specified only once for a particular layer, multiple layers can use the same attribute name for different purpose. Layers are commonly used in PBR workflows to describe lacquered wood, metallic paint or for example a thin film on leather surfaces. You can enumerate and query layers using layerCount(), layerName() and hasLayer(), layer-specific attributes are retrieved by passing layer ID or name as the first parameter to the attribute() family of APIs.

For each layer there can be predefined layerFactor(), layerFactorTexture() and other texture-related attributes which define how much the layer affects the underlying material, but the exact semantics of how the factor is applied is left to the layer implementation.

Here's an example showing retrieval of a clear coat layer parameters, if present:

if(data.hasLayer(Trade::MaterialLayer::ClearCoat)) {
    Float clearCoatFactor = data.attributeOr(Trade::MaterialLayer::ClearCoat,
        Trade::MaterialAttribute::LayerFactor, 1.0f);
    Float clearCoatRoughness = data.attributeOr(Trade::MaterialLayer::ClearCoat,
        Trade::MaterialAttribute::Roughness, 0.0f);

    
}

Like with base material attributes, builtin layers also have convenience accessor APIs. The above can be written in a more compact way using PbrClearCoatMaterialData:

if(data.types() & Trade::MaterialType::PbrClearCoat) {
    const auto& clearCoat = data.as<Trade::PbrClearCoatMaterialData>();

    Float clearCoatFactor = clearCoat.layerFactor();
    Float clearCoatRoughness = clearCoat.roughness();

    
}

Mutable data access

The interfaces implicitly return attribute values by copy or through const views on the contained data through the attributeData(), layerData() and attribute() accessors. This is done because in general case the data can also refer to a memory-mapped file or constant memory. In cases when it's desirable to modify the attribute values in-place, there's a set of mutableAttribute() functions. To use these, you need to check that the data are mutable using attributeDataFlags() first. The following snippet desaturates the base color of a PBR material:

Color4& color = data.mutableAttribute<Color4>(Trade::MaterialAttribute::BaseColor);
ColorHsv hsv = color.toHsv();
color.rgb() = Color3::fromHsv({hsv.hue, hsv.saturation*0.85f, hsv.value});

Because the class internally expects the attribute data to be sorted and partitioned into layers, it's not possible to modify attribute names, add/remove attributes or change layer offsets — only to edit values of existing attributes.

Populating an instance

A MaterialData instance by default takes over ownership of an Containers::Array containing MaterialAttributeData instances, together with MaterialTypes suggesting available material types (or an empty set, in case of a fully custom material). Attribute values can be in one of the types from MaterialAttributeType, and the type is in most cases inferred implicitly. The class internally uses strings for attribute names, but you're encouraged to use the predefined names from MaterialAttribute — with those, the attribute gets checked additionally that it's in an expected type. Attribute order doesn't matter, the array gets internally sorted by name to allow a $ \mathcal{O}(\log n) $ lookup.

Trade::MaterialData data{Trade::MaterialType::PbrMetallicRoughness, {
    {Trade::MaterialAttribute::DoubleSided, true},
    {Trade::MaterialAttribute::BaseColor, 0x3bd267ff_srgbaf},
    {Trade::MaterialAttribute::BaseColorTexture, 17u},
    {Trade::MaterialAttribute::TextureMatrix, Matrix3::scaling({0.5f, 1.0f})}
}};

In addition to passing ownership of an array it's also possible to have the MaterialData instance refer to external data (for example in a memory-mapped file, constant memory etc.). Instead of moving in an Containers::Array you pass DataFlags describing if the data is mutable or not together with an Containers::ArrayView. Note that in this case, since the attribute data is treated as immutable, you have to ensure the list is already sorted by name.

using namespace Containers::Literals;

constexpr Trade::MaterialAttributeData attributes[]{
    {"BaseColor"_s, Color4{0.043735f, 0.64448f, 0.135633f, 1.0f}},
    {"BaseColorTexture"_s, 5u},
    {"DoubleSided"_s, true},
    {"TextureMatrix"_s, Matrix3{{0.5f, 0.0f, 0.0f},
                                {0.0f, 1.0f, 0.0f},
                                {0.0f, 0.0f, 1.0f}}}
};

Trade::MaterialData data{Trade::MaterialType::Phong, {}, attributes};

Custom material attributes

While attribute names beginning with uppercase letters and whitespace are reserved for builtin Magnum attributes, anything beginning with a lowercase letter or a printable non-letter character can be a custom attribute. For greater flexibility, custom attributes can be also strings, untyped buffers or pointers, allowing you to store arbitrary properties such as image filenames or direct texture pointers instead of IDs:

char sha1[20]{};

Trade::MaterialData data{Trade::MaterialType::PbrMetallicRoughness, {
    {Trade::MaterialAttribute::BaseColor, 0x3bd267ff_srgbaf},
    {Trade::MaterialAttribute::TextureMatrix, Matrix3::scaling({0.5f, 1.0f})},
    {"baseColorTexturePointer", &baseColorTexture},
    {"highlightColor", 0x00ffff_srgbf},
    {"name", "Canary Green Plastic, really ugly"},
    {"hash", Containers::ArrayView<const void>{sha1}},
}};

// Retrieving the texture pointer
GL::Texture2D* texture = data.attribute<GL::Texture2D*>("baseColorTexturePointer");

Adding material layers

Material layers are internally represented as ranges of the attribute array and by default the whole attribute array is treated as a base material. The actual split into layers can be described using an additional offset array passed to MaterialData(MaterialTypes, Containers::Array<MaterialAttributeData>&&, Containers::Array<UnsignedInt>&&, const void*), where entry i specifies the end offset of layer i — in the following snippet we have two layers (one base material and one clear coat layer), the base material being the first two attributes and the clear coat layer being attributes in range 2 to 6 (thus four attributes):

Trade::MaterialData data{
    Trade::MaterialType::PbrMetallicRoughness|Trade::MaterialType::PbrClearCoat,
    {
        {Trade::MaterialAttribute::BaseColor, 0xffcc33_srgbf},
        {Trade::MaterialAttribute::NoneRoughnessMetallicTexture, 0u},

        {Trade::MaterialLayer::ClearCoat},
        {Trade::MaterialAttribute::LayerFactorTexture, 1u},
        {Trade::MaterialAttribute::RoughnessTexture,  1u},
        {Trade::MaterialAttribute::RoughnessTextureSwizzle,
            Trade::MaterialTextureSwizzle::G}
    },

    {2, 6}
};

Like with just a base material, the attributes get sorted for a $ \mathcal{O}(\log n) $ lookup — but not as a whole, each layer separately. In contrary, because layer order matters, those are not reordered (and thus their lookup is $ \mathcal{O}(n) $ , however it isn't expected to have that many layers for this to matter). The layers can be named by supplying a MaterialAttribute::LayerName attribute (or, like shown above, by using the convenience MaterialAttributeData::MaterialAttributeData(MaterialLayer) constructor) but don't have to — if a layer doesn't have a name, it can be only looked up by its index, not by a name.

Apart from builtin layers, there's no limit in what the layers can be used for — the data can for example describe a completely custom landscape from a set of authored rockTile, sandTile, grassTile textures and procedurally generated blend factors a, b, c, d:

Trade::MaterialData proceduralLandscape{
    Trade::MaterialTypes{}, // Doesn't match any builtin material type
    {
        // Rock layer
        {Trade::MaterialAttribute::LayerFactorTexture, a},
        {Trade::MaterialAttribute::BaseColorTexture, rockTile},

        // Sand layer
        {Trade::MaterialAttribute::LayerFactorTexture, b},
        {"blendType", "mix"},
        {Trade::MaterialAttribute::BaseColorTexture, sandTile},

        // Grass layer
        {Trade::MaterialAttribute::LayerFactorTexture, c},
        {"blendType", "overlay"},
        {"strandLengthTexture", d},
        {Trade::MaterialAttribute::BaseColorTexture, grassTile},
    },

    // There's no base material, everything is in layers
    {0, 2, 5, 9}
};

Internal representation

The attributes are stored sorted by the key in a contiguous array, with each MaterialAttributeData item occupying 64 bytes. The item contains a 1-byte type identifier, the actual value and the rest is occupied with null-terminated name. This means the name length can vary from 14 bytes for Matrix3x4 / Matrix4x3 to 61 bytes for bool (excluding null terminator). As each item has a fixed size anyway, there's no value in supporting space-efficient 8-, 16- or half-float types. Conversely, Double types are currently not supported either as there isn't currently seen any need for extended precision.

Derived classes

class FlatMaterialData new in Git master
Flat material data.
template<MaterialLayer layer>
class MaterialLayerData new in Git master
Material layer data.
class PbrMetallicRoughnessMaterialData new in Git master
PBR metallic/roughness material data.
class PbrSpecularGlossinessMaterialData new in Git master
PBR specular/glossiness material data.
class PhongMaterialData
Phong material data.
template<MaterialLayer layer>
class MaterialLayerData new in Git master
Material layer data.

Public types

enum class Flag: UnsignedInt { DoubleSided = 1 << 0 } deprecated in Git master
Material flag.
using Flags = Containers::EnumSet<Flag> deprecated in Git master
Material flags.

Constructors, destructors, conversion operators

MaterialData(MaterialTypes types, Containers::Array<MaterialAttributeData>&& attributeData, const void* importerState = nullptr) explicit noexcept
Construct.
MaterialData(MaterialTypes types, std::initializer_list<MaterialAttributeData> attributeData, const void* importerState = nullptr) explicit
MaterialData(MaterialTypes types, DataFlags attributeDataFlags, Containers::ArrayView<const MaterialAttributeData> attributeData, const void* importerState = nullptr) explicit noexcept
Construct a non-owned material data.
MaterialData(MaterialTypes types, Containers::Array<MaterialAttributeData>&& attributeData, Containers::Array<UnsignedInt>&& layerData, const void* importerState = nullptr) explicit noexcept
Construct with layers.
MaterialData(MaterialTypes types, std::initializer_list<MaterialAttributeData> attributeData, std::initializer_list<UnsignedInt> layerData, const void* importerState = nullptr) explicit
MaterialData(MaterialTypes types, DataFlags attributeDataFlags, Containers::ArrayView<const MaterialAttributeData> attributeData, DataFlags layerDataFlags, Containers::ArrayView<const UnsignedInt> layerData, const void* importerState = nullptr) explicit noexcept
Construct a non-owned material data with layers.
MaterialData(const MaterialData&) deleted
Copying is not allowed.
MaterialData(MaterialData&&) noexcept
Move constructor.

Public functions

auto operator=(const MaterialData&) -> MaterialData& deleted
Copying is not allowed.
auto operator=(MaterialData&&) -> MaterialData& noexcept
Move assignment.
auto attributeDataFlags() const -> DataFlags
Attribute data flags ¨ Since the attribute list is always assumed to be sorted and partitioned into layers, only attribute values can be edited when the DataFlag::Mutable flag is present.
auto layerDataFlags() const -> DataFlags
Layer data flags.
auto types() const -> MaterialTypes
Material types.
template<class T>
auto as() const & -> const T&
Interpret as a material data of concrete type.
template<class T>
auto as() && -> T
Interpret a rvalue as a material data of concrete type.
auto type() const -> MaterialType deprecated in Git master
Material type.
auto layerData() const -> Containers::ArrayView<const UnsignedInt>
Raw layer offset data.
auto attributeData() const -> Containers::ArrayView<const MaterialAttributeData>
Raw attribute data.
auto layerCount() const -> UnsignedInt
Layer count.
auto attributeDataOffset(UnsignedInt layer) const -> UnsignedInt
Offset of a layer inside attribute data.
auto hasLayer(Containers::StringView layer) const -> bool
Whether a material has given named layer.
auto hasLayer(MaterialLayer layer) const -> bool
auto findLayerId(Containers::StringView layer) const -> Containers::Optional<UnsignedInt>
Find ID of a named layer.
auto findLayerId(MaterialLayer layer) const -> Containers::Optional<UnsignedInt>
auto layerId(Containers::StringView layer) const -> UnsignedInt
ID of a named layer.
auto layerId(MaterialLayer layer) const -> UnsignedInt
auto layerName(UnsignedInt layer) const -> Containers::StringView
Layer name.
auto layerFactor(UnsignedInt layer) const -> Float
Factor of given layer.
auto layerFactor(Containers::StringView layer) const -> Float
Factor of a named layer.
auto layerFactor(MaterialLayer layer) const -> Float
auto layerFactorTexture(UnsignedInt layer) const -> UnsignedInt
Factor texture ID for given layer.
auto layerFactorTexture(Containers::StringView layer) const -> UnsignedInt
Factor texture ID for a named layer.
auto layerFactorTexture(MaterialLayer layer) const -> UnsignedInt
auto layerFactorTextureSwizzle(UnsignedInt layer) const -> MaterialTextureSwizzle
Factor texture swizzle for given layer.
auto layerFactorTextureSwizzle(Containers::StringView layer) const -> MaterialTextureSwizzle
Factor texture swizzle for a named layer.
auto layerFactorTextureSwizzle(MaterialLayer layer) const -> MaterialTextureSwizzle
auto layerFactorTextureMatrix(UnsignedInt layer) const -> Matrix3
Factor texture coordinate transformation matrix for given layer.
auto layerFactorTextureMatrix(Containers::StringView layer) const -> Matrix3
Factor texture coordinate transformation matrix for a named layer.
auto layerFactorTextureMatrix(MaterialLayer layer) const -> Matrix3
auto layerFactorTextureCoordinates(UnsignedInt layer) const -> UnsignedInt
Factor texture coordinate set for given layer.
auto layerFactorTextureCoordinates(Containers::StringView layer) const -> UnsignedInt
Factor texture coordinate set for a named layer.
auto layerFactorTextureCoordinates(MaterialLayer layer) const -> UnsignedInt
auto layerFactorTextureLayer(UnsignedInt layer) const -> UnsignedInt
Factor array texture layer for given layer.
auto layerFactorTextureLayer(Containers::StringView layer) const -> UnsignedInt
Factor array texture layer for a named layer.
auto layerFactorTextureLayer(MaterialLayer layer) const -> UnsignedInt
auto attributeCount(UnsignedInt layer) const -> UnsignedInt
Attribute count in given layer.
auto attributeCount(Containers::StringView layer) const -> UnsignedInt
Attribute count in a named layer.
auto attributeCount(MaterialLayer layer) const -> UnsignedInt
auto attributeCount() const -> UnsignedInt
Attribute count in the base material.
auto hasAttribute(UnsignedInt layer, Containers::StringView name) const -> bool
Whether a material layer has given attribute.
auto hasAttribute(UnsignedInt layer, MaterialAttribute name) const -> bool
auto hasAttribute(Containers::StringView layer, Containers::StringView name) const -> bool
Whether a named material layer has given attribute.
auto hasAttribute(Containers::StringView layer, MaterialAttribute name) const -> bool
auto hasAttribute(MaterialLayer layer, Containers::StringView name) const -> bool
auto hasAttribute(MaterialLayer layer, MaterialAttribute name) const -> bool
auto hasAttribute(Containers::StringView name) const -> bool
Whether the base material has given attribute.
auto hasAttribute(MaterialAttribute name) const -> bool
auto findAttributeId(UnsignedInt layer, Containers::StringView name) const -> Containers::Optional<UnsignedInt>
Find ID of a named attribute in given material layer.
auto findAttributeId(UnsignedInt layer, MaterialAttribute name) const -> Containers::Optional<UnsignedInt>
auto findAttributeId(Containers::StringView layer, Containers::StringView name) const -> Containers::Optional<UnsignedInt>
Find ID of a named attribute in a named material layer.
auto findAttributeId(Containers::StringView layer, MaterialAttribute name) const -> Containers::Optional<UnsignedInt>
auto findAttributeId(MaterialLayer layer, Containers::StringView name) const -> Containers::Optional<UnsignedInt>
auto findAttributeId(MaterialLayer layer, MaterialAttribute name) const -> Containers::Optional<UnsignedInt>
auto findAttributeId(Containers::StringView name) const -> Containers::Optional<UnsignedInt>
Find ID of a named attribute in the base material.
auto findAttributeId(MaterialAttribute name) const -> Containers::Optional<UnsignedInt>
auto attributeId(UnsignedInt layer, Containers::StringView name) const -> UnsignedInt
ID of a named attribute in given material layer.
auto attributeId(UnsignedInt layer, MaterialAttribute name) const -> UnsignedInt
auto attributeId(Containers::StringView layer, Containers::StringView name) const -> UnsignedInt
ID of a named attribute in a named material layer.
auto attributeId(Containers::StringView layer, MaterialAttribute name) const -> UnsignedInt
auto attributeId(MaterialLayer layer, Containers::StringView name) const -> UnsignedInt
auto attributeId(MaterialLayer layer, MaterialAttribute name) const -> UnsignedInt
auto attributeId(Containers::StringView name) const -> UnsignedInt
ID of a named attribute in the base material.
auto attributeId(MaterialAttribute name) const -> UnsignedInt
auto attributeData(UnsignedInt layer, UnsignedInt id) const -> const MaterialAttributeData&
Raw attribute data.
auto attributeData(UnsignedInt id) const -> const MaterialAttributeData&
Raw attribute data in the base material.
auto attributeName(UnsignedInt layer, UnsignedInt id) const -> Containers::StringView
Name of an attribute in given material layer.
auto attributeName(Containers::StringView layer, UnsignedInt id) const -> Containers::StringView
Name of an attribute in a named material layer.
auto attributeName(MaterialLayer layer, UnsignedInt id) const -> Containers::StringView
auto attributeName(UnsignedInt id) const -> Containers::StringView
Name of an attribute in the base material.
auto attributeType(UnsignedInt layer, UnsignedInt id) const -> MaterialAttributeType
Type of an attribute in given material layer.
auto attributeType(UnsignedInt layer, Containers::StringView name) const -> MaterialAttributeType
Type of a named attribute in given material layer.
auto attributeType(UnsignedInt layer, MaterialAttribute name) const -> MaterialAttributeType
auto attributeType(Containers::StringView layer, UnsignedInt id) const -> MaterialAttributeType
Type of an attribute in a named material layer.
auto attributeType(MaterialLayer layer, UnsignedInt id) const -> MaterialAttributeType
auto attributeType(Containers::StringView layer, Containers::StringView name) const -> MaterialAttributeType
Type of a named attribute in a named material layer.
auto attributeType(Containers::StringView layer, MaterialAttribute name) const -> MaterialAttributeType
auto attributeType(MaterialLayer layer, Containers::StringView name) const -> MaterialAttributeType
auto attributeType(MaterialLayer layer, MaterialAttribute name) const -> MaterialAttributeType
auto attributeType(UnsignedInt id) const -> MaterialAttributeType
Type of an attribute in the base material.
auto attributeType(Containers::StringView name) const -> MaterialAttributeType
Type of a named attribute in the base material.
auto attributeType(MaterialAttribute name) const -> MaterialAttributeType
auto attribute(UnsignedInt layer, UnsignedInt id) const -> const void*
Type-erased value of an attribute in given material layer.
auto mutableAttribute(UnsignedInt layer, UnsignedInt id) -> void*
Type-erased mutable value of an attribute in given material layer.
auto attribute(UnsignedInt layer, Containers::StringView name) const -> const void*
Type-erased value of a named attribute in given material layer.
auto attribute(UnsignedInt layer, MaterialAttribute name) const -> const void*
auto mutableAttribute(UnsignedInt layer, Containers::StringView name) -> void*
Type-erased value of a named attribute in given material layer.
auto mutableAttribute(UnsignedInt layer, MaterialAttribute name) -> void*
auto attribute(Containers::StringView layer, UnsignedInt id) const -> const void*
Type-erased value of an attribute in a named material layer.
auto attribute(MaterialLayer layer, UnsignedInt id) const -> const void*
auto mutableAttribute(Containers::StringView layer, UnsignedInt id) -> void*
Type-erased mutable value of an attribute in a named material layer.
auto mutableAttribute(MaterialLayer layer, UnsignedInt id) -> void*
auto attribute(Containers::StringView layer, Containers::StringView name) const -> const void*
Type-erased value of a named attribute in a named material layer.
auto attribute(Containers::StringView layer, MaterialAttribute name) const -> const void*
auto attribute(MaterialLayer layer, Containers::StringView name) const -> const void*
auto attribute(MaterialLayer layer, MaterialAttribute name) const -> const void*
auto mutableAttribute(Containers::StringView layer, Containers::StringView name) -> void*
Type-erased mutable value of a named attribute in a named material layer.
auto mutableAttribute(Containers::StringView layer, MaterialAttribute name) -> void*
auto mutableAttribute(MaterialLayer layer, Containers::StringView name) -> void*
auto mutableAttribute(MaterialLayer layer, MaterialAttribute name) -> void*
auto attribute(UnsignedInt id) const -> const void*
Type-erased value of an attribute in the base material.
auto mutableAttribute(UnsignedInt id) -> void*
Type-erased mutable value of an attribute in the base material.
auto attribute(Containers::StringView name) const -> const void*
Type-erased value of a named attribute in the base material.
auto attribute(MaterialAttribute name) const -> const void*
auto mutableAttribute(Containers::StringView name) -> void*
Type-erased mutable value of a named attribute in the base material.
auto mutableAttribute(MaterialAttribute name) -> void*
template<class T>
auto attribute(UnsignedInt layer, UnsignedInt id) const -> T
Value of an attribute in given material layer.
template<class T>
auto mutableAttribute(UnsignedInt layer, UnsignedInt id) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
Mutable value of an attribute in given material layer.
template<class T>
auto attribute(UnsignedInt layer, Containers::StringView name) const -> T
Value of a named attribute in given material layer.
template<class T>
auto attribute(UnsignedInt layer, MaterialAttribute name) const -> T
template<class T>
auto mutableAttribute(UnsignedInt layer, Containers::StringView name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
Mutable value of a named attribute in given material layer.
template<class T>
auto mutableAttribute(UnsignedInt layer, MaterialAttribute name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
template<class T>
auto attribute(Containers::StringView layer, UnsignedInt id) const -> T
Value of an attribute in a named material layer.
template<class T>
auto attribute(MaterialLayer layer, UnsignedInt id) const -> T
template<class T>
auto mutableAttribute(Containers::StringView layer, UnsignedInt id) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
Mutable value of an attribute in a named material layer.
template<class T>
auto mutableAttribute(MaterialLayer layer, UnsignedInt id) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
template<class T>
auto attribute(Containers::StringView layer, Containers::StringView name) const -> T
Value of a named attribute in a named material layer.
template<class T>
auto attribute(Containers::StringView layer, MaterialAttribute name) const -> T
template<class T>
auto attribute(MaterialLayer layer, Containers::StringView name) const -> T
template<class T>
auto attribute(MaterialLayer layer, MaterialAttribute name) const -> T
template<class T>
auto mutableAttribute(Containers::StringView layer, Containers::StringView name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
Mutable value of a named attribute in a named material layer.
template<class T>
auto mutableAttribute(Containers::StringView layer, MaterialAttribute name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
template<class T>
auto mutableAttribute(MaterialLayer layer, Containers::StringView name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
template<class T>
auto mutableAttribute(MaterialLayer layer, MaterialAttribute name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
template<class T>
auto attribute(UnsignedInt id) const -> T
Value of an attribute in the base material.
template<class T>
auto mutableAttribute(UnsignedInt id) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
Mutable value of an attribute in the base material.
template<class T>
auto attribute(Containers::StringView name) const -> T
Value of a named attribute in the base material.
template<class T>
auto attribute(MaterialAttribute name) const -> T
template<class T>
auto mutableAttribute(Containers::StringView name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
Mutable value of a named attribute in the base material.
template<class T>
auto mutableAttribute(MaterialAttribute name) -> std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type
auto findAttribute(UnsignedInt layer, Containers::StringView name) const -> const void*
Type-erased attribute value in given material layer, if exists.
auto findAttribute(UnsignedInt layer, MaterialAttribute name) const -> const void*
auto tryAttribute(UnsignedInt layer, Containers::StringView name) const -> const void* deprecated in Git master
Type-erased attribute value in given material layer, if exists.
auto tryAttribute(UnsignedInt layer, MaterialAttribute name) const -> const void* deprecated in Git master
auto findAttribute(Containers::StringView layer, Containers::StringView name) const -> const void*
Type-erased attribute value in a named material layer, if exists.
auto findAttribute(Containers::StringView layer, MaterialAttribute name) const -> const void*
auto findAttribute(MaterialLayer layer, Containers::StringView name) const -> const void*
auto findAttribute(MaterialLayer layer, MaterialAttribute name) const -> const void*
auto tryAttribute(Containers::StringView layer, Containers::StringView name) const -> const void* deprecated in Git master
Type-erased attribute value in a named material layer, if exists.
auto tryAttribute(Containers::StringView layer, MaterialAttribute name) const -> const void* deprecated in Git master
auto tryAttribute(MaterialLayer layer, Containers::StringView name) const -> const void* deprecated in Git master
auto tryAttribute(MaterialLayer layer, MaterialAttribute name) const -> const void* deprecated in Git master
template<class T>
auto findAttribute(UnsignedInt layer, Containers::StringView name) const -> Containers::Optional<T>
Value of a named attribute in given material layer, if exists.
template<class T>
auto findAttribute(UnsignedInt layer, MaterialAttribute name) const -> Containers::Optional<T>
template<class T>
auto tryAttribute(UnsignedInt layer, Containers::StringView name) const -> Containers::Optional<T> deprecated in Git master
Type-erased attribute value in given material layer, if exists.
template<class T>
auto tryAttribute(UnsignedInt layer, MaterialAttribute name) const -> Containers::Optional<T> deprecated in Git master
template<class T>
auto findAttribute(Containers::StringView layer, Containers::StringView name) const -> Containers::Optional<T>
Value of a named attribute in a named material layer, if exists.
template<class T>
auto findAttribute(Containers::StringView layer, MaterialAttribute name) const -> Containers::Optional<T>
template<class T>
auto findAttribute(MaterialLayer layer, Containers::StringView name) const -> Containers::Optional<T>
template<class T>
auto findAttribute(MaterialLayer layer, MaterialAttribute name) const -> Containers::Optional<T>
template<class T>
auto tryAttribute(Containers::StringView layer, Containers::StringView name) const -> Containers::Optional<T> deprecated in Git master
Type-erased attribute value in a named material layer, if exists.
template<class T>
auto tryAttribute(Containers::StringView layer, MaterialAttribute name) const -> Containers::Optional<T> deprecated in Git master
template<class T>
auto tryAttribute(MaterialLayer layer, Containers::StringView name) const -> Containers::Optional<T> deprecated in Git master
Type-erased attribute value in given material layer, if exists.
template<class T>
auto tryAttribute(MaterialLayer layer, MaterialAttribute name) const -> Containers::Optional<T> deprecated in Git master
auto findAttribute(Containers::StringView name) const -> const void*
Type-erased attribute value in the base material, if exists.
auto findAttribute(MaterialAttribute name) const -> const void*
auto tryAttribute(Containers::StringView name) const -> const void* deprecated in Git master
Type-erased attribute value in the base material, if exists.
auto tryAttribute(MaterialAttribute name) const -> const void* deprecated in Git master
template<class T>
auto findAttribute(Containers::StringView name) const -> Containers::Optional<T>
Value of a named attribute in the base material, if exists.
template<class T>
auto findAttribute(MaterialAttribute name) const -> Containers::Optional<T>
template<class T>
auto tryAttribute(Containers::StringView name) const -> Containers::Optional<T> deprecated in Git master
Type-erased attribute value in the base material, if exists.
template<class T>
auto tryAttribute(MaterialAttribute name) const -> Containers::Optional<T> deprecated in Git master
template<class T>
auto attributeOr(UnsignedInt layer, Containers::StringView name, const T& defaultValue) const -> T
Value of a named attribute in given layer or a default.
template<class T>
auto attributeOr(UnsignedInt layer, MaterialAttribute name, const T& defaultValue) const -> T
template<class T>
auto attributeOr(Containers::StringView layer, Containers::StringView name, const T& defaultValue) const -> T
Value of a named attribute in a named layer or a default.
template<class T>
auto attributeOr(Containers::StringView layer, MaterialAttribute name, const T& defaultValue) const -> T
template<class T>
auto attributeOr(MaterialLayer layer, Containers::StringView name, const T& defaultValue) const -> T
template<class T>
auto attributeOr(MaterialLayer layer, MaterialAttribute name, const T& defaultValue) const -> T
template<class T>
auto attributeOr(Containers::StringView name, const T& defaultValue) const -> T
Value of a named attribute in the base material or a default.
template<class T>
auto attributeOr(MaterialAttribute name, const T& defaultValue) const -> T
auto isDoubleSided() const -> bool
Whether a material is double-sided.
auto flags() const -> Flags deprecated in Git master
Material flags.
auto alphaMode() const -> MaterialAlphaMode
Alpha mode.
auto alphaMask() const -> Float
Alpha mask.
auto releaseLayerData() -> Containers::Array<UnsignedInt>
Release layer data storage.
auto releaseAttributeData() -> Containers::Array<MaterialAttributeData>
Release attribute data storage.
auto importerState() const -> const void*
Importer-specific state.

Enum documentation

enum class Magnum::Trade::MaterialData::Flag: UnsignedInt

Material flag.

This enum is further extended in subclasses.

Enumerators
DoubleSided

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

Typedef documentation

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

Material flags.

This enum is extended in subclasses.

Function documentation

Magnum::Trade::MaterialData::MaterialData(MaterialTypes types, Containers::Array<MaterialAttributeData>&& attributeData, const void* importerState = nullptr) explicit noexcept

Construct.

Parameters
types Which material types are described by this data. Can be an empty set.
attributeData Attribute data
importerState Importer-specific state

The attributeData gets sorted by name internally, expecting no duplicates.

The attributeDataFlags() / layerDataFlags() are implicitly set to a combination of DataFlag::Owned and DataFlag::Mutable. For non-owned data use the MaterialData(MaterialTypes, DataFlags, Containers::ArrayView<const MaterialAttributeData>, const void*) constructor instead.

Magnum::Trade::MaterialData::MaterialData(MaterialTypes types, std::initializer_list<MaterialAttributeData> attributeData, const void* importerState = nullptr) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Trade::MaterialData::MaterialData(MaterialTypes types, DataFlags attributeDataFlags, Containers::ArrayView<const MaterialAttributeData> attributeData, const void* importerState = nullptr) explicit noexcept

Construct a non-owned material data.

Parameters
types Which material types are described by this data. Can be an empty set.
attributeDataFlags Attribute data flags
attributeData Attribute data
importerState Importer-specific state

Compared to MaterialData(MaterialTypes, Containers::Array<MaterialAttributeData>&&, const void*) creates an instance that doesn't own the passed attribute data. The attributeData is expected to be already sorted by name, without duplicates. The attributeDataFlags can contain DataFlag::Mutable to indicate the external data can be modified, and is expected to not have DataFlag::Owned set. The layerDataFlags() are implicitly set to empty DataFlags.

Magnum::Trade::MaterialData::MaterialData(MaterialTypes types, Containers::Array<MaterialAttributeData>&& attributeData, Containers::Array<UnsignedInt>&& layerData, const void* importerState = nullptr) explicit noexcept

Construct with layers.

Parameters
types Which material types are described by this data. Can be an empty set.
attributeData Attribute data
layerData Layer offset data
importerState Importer-specific state

The attributeData gets sorted by name internally, expecting no duplicates inside each layer. The layerData is expected to be either empty or a monotonically non-decreasing sequence of offsets not larger than attributeData size, with i-th item specifying end offset of i-th layer.

The attributeDataFlags() / layerDataFlags() are implicitly set to a combination of DataFlag::Owned and DataFlag::Mutable. For non-owned data use the MaterialData(MaterialTypes, DataFlags, Containers::ArrayView<const MaterialAttributeData>, DataFlags, Containers::ArrayView<const UnsignedInt>, const void*) constructor instead.

Magnum::Trade::MaterialData::MaterialData(MaterialTypes types, std::initializer_list<MaterialAttributeData> attributeData, std::initializer_list<UnsignedInt> layerData, const void* importerState = nullptr) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Trade::MaterialData::MaterialData(MaterialTypes types, DataFlags attributeDataFlags, Containers::ArrayView<const MaterialAttributeData> attributeData, DataFlags layerDataFlags, Containers::ArrayView<const UnsignedInt> layerData, const void* importerState = nullptr) explicit noexcept

Construct a non-owned material data with layers.

Parameters
types Which material types are described by this data. Can be an empty set.
attributeDataFlags Attribute data flags
attributeData Attribute data
layerDataFlags Layer offset data flags
layerData Layer offset data
importerState Importer-specific state

The data is expected to be already sorted by name, without duplicates inside each layer. The layerData is expected to be either empty or a monotonically non-decreasing sequence of offsets not larger than attributeData size, with i-th item specifying end offset of i-th layer.

The attributeDataFlags / layerDataFlags parameters can contain DataFlag::Mutable to indicate the external data can be modified, and are expected to not have DataFlag::Owned set.

DataFlags Magnum::Trade::MaterialData::attributeDataFlags() const

Attribute data flags ¨ Since the attribute list is always assumed to be sorted and partitioned into layers, only attribute values can be edited when the DataFlag::Mutable flag is present.

DataFlags Magnum::Trade::MaterialData::layerDataFlags() const

Layer data flags.

Since the attribute list is always assumed to be sorted and partitioned into layers, the DataFlag::Mutable flag has no effect here — only attribute values can be edited when DataFlag::Mutable is present in attributeDataFlags().

MaterialTypes Magnum::Trade::MaterialData::types() const

Material types.

Each type indicates that the material data can be interpreted as given type. For custom materials the set can also be empty.

template<class T>
const T& Magnum::Trade::MaterialData::as() const &

Interpret as a material data of concrete type.

Returns a reference to *this cast to given type. T is expected to be a subclass of the same size such as PbrMetallicRoughnessMaterialData, PbrSpecularGlossinessMaterialData or PhongMaterialData.

template<class T>
T Magnum::Trade::MaterialData::as() &&

Interpret a rvalue as a material data of concrete type.

Compared to the above, returns a value and not a reference. The original instance then behaves the same as a moved-from instance.

MaterialType Magnum::Trade::MaterialData::type() const

Material type.

Containers::ArrayView<const UnsignedInt> Magnum::Trade::MaterialData::layerData() const

Raw layer offset data.

May return nullptr if the material doesn't have any extra layers.

Containers::ArrayView<const MaterialAttributeData> Magnum::Trade::MaterialData::attributeData() const

Raw attribute data.

Returns nullptr if the material has no attributes.

UnsignedInt Magnum::Trade::MaterialData::layerCount() const

Layer count.

There's always at least the base material, so this function returns at least 1.

UnsignedInt Magnum::Trade::MaterialData::attributeDataOffset(UnsignedInt layer) const

Offset of a layer inside attribute data.

Returns the offset where attributes for layer start in the array returned by attributeData() const. The layer is expected to be less or equal to layerCount(), i.e. it's always possible to call this function with layer and layer + 1 to get the attribute range for given layer.

bool Magnum::Trade::MaterialData::hasLayer(Containers::StringView layer) const

Whether a material has given named layer.

Layers with no name assigned are skipped. The base material (layer 0 is skipped as well) to avoid confusing base material with a layer. If you want to create a material consisting of just a layer, use 0 for the first layer offset in the constructor.

bool Magnum::Trade::MaterialData::hasLayer(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findLayerId(Containers::StringView layer) const

Find ID of a named layer.

The layer doesn't exist, returns Containers::NullOpt. The lookup is done in an $ \mathcal{O}(n) $ complexity with $ n $ being the layer count.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findLayerId(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::layerId(Containers::StringView layer) const

ID of a named layer.

Like findLayerId(), but the layer is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::layerId(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::StringView Magnum::Trade::MaterialData::layerName(UnsignedInt layer) const

Layer name.

Retrieves a MaterialAttribute::LayerName attribute from given layer, if present. Returns a nullptr view if the layer has no name, and an empty non-null view if the layer name is empty. The layer is expected to be smaller than layerCount() const.

The name, if present, is ignored for the base material (layer 0) to avoid confsing base material with a layer. If you want to create a material consisting of just a layer, use 0 for the first layer offset in the constructor.

Float Magnum::Trade::MaterialData::layerFactor(UnsignedInt layer) const

Factor of given layer.

Convenience access to the MaterialAttribute::LayerFactor attribute. If not present, the default is 1.0f. The layer is expected to be smaller than layerCount() const.

If the layer has MaterialAttribute::LayerFactorTexture, the factor and texture is meant to be multiplied together.

Float Magnum::Trade::MaterialData::layerFactor(Containers::StringView layer) const

Factor of a named layer.

Convenience access to the MaterialAttribute::LayerFactor attribute. If not present, the default is 1.0f. The layer is expected to exist.

If the layer has MaterialAttribute::LayerFactorTexture, the factor and texture is meant to be multiplied together.

Float Magnum::Trade::MaterialData::layerFactor(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::layerFactorTexture(UnsignedInt layer) const

Factor texture ID for given layer.

Available only if the MaterialAttribute::LayerFactorTexture attribute is present. Meant to be multiplied with layerFactor(). The layer is expected to be smaller than layerCount().

UnsignedInt Magnum::Trade::MaterialData::layerFactorTexture(Containers::StringView layer) const

Factor texture ID for a named layer.

Available only if the MaterialAttribute::LayerFactorTexture attribute is present. Meant to be multiplied with layerFactor(). The layer is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::layerFactorTexture(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MaterialTextureSwizzle Magnum::Trade::MaterialData::layerFactorTextureSwizzle(UnsignedInt layer) const

Factor texture swizzle for given layer.

Convenience access to the MaterialAttribute::LayerFactorTextureSwizzle attribute. If not present, the default is MaterialTextureSwizzle::R. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to be smaller than layerCount().

MaterialTextureSwizzle Magnum::Trade::MaterialData::layerFactorTextureSwizzle(Containers::StringView layer) const

Factor texture swizzle for a named layer.

Convenience access to the MaterialAttribute::LayerFactorTextureSwizzle attribute. If not present, the default is MaterialTextureSwizzle::R. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to exist.

MaterialTextureSwizzle Magnum::Trade::MaterialData::layerFactorTextureSwizzle(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Matrix3 Magnum::Trade::MaterialData::layerFactorTextureMatrix(UnsignedInt layer) const

Factor texture coordinate transformation matrix for given layer.

Convenience access to the MaterialAttribute::LayerFactorTextureMatrix / MaterialAttribute::TextureMatrix attributes in given layer or a MaterialAttribute::TextureMatrix attribute in the base material. If neither is present, the default is an identity matrix. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to be smaller than layerCount().

Matrix3 Magnum::Trade::MaterialData::layerFactorTextureMatrix(Containers::StringView layer) const

Factor texture coordinate transformation matrix for a named layer.

Convenience access to the MaterialAttribute::LayerFactorTextureMatrix / MaterialAttribute::TextureMatrix attributes in given layer or a MaterialAttribute::TextureMatrix attribute in the base material. If neither is present, the default is an identity matrix. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to exist.

Matrix3 Magnum::Trade::MaterialData::layerFactorTextureMatrix(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::layerFactorTextureCoordinates(UnsignedInt layer) const

Factor texture coordinate set for given layer.

Convenience access to the MaterialAttribute::LayerFactorTextureCoordinates / MaterialAttribute::TextureCoordinates attributes in given layer or a MaterialAttribute::TextureCoordinates attribute in the base material. If neither is present, the default is 0. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to be smaller than layerCount().

UnsignedInt Magnum::Trade::MaterialData::layerFactorTextureCoordinates(Containers::StringView layer) const

Factor texture coordinate set for a named layer.

Convenience access to the MaterialAttribute::LayerFactorTextureCoordinates / MaterialAttribute::TextureCoordinates attributes in given layer or a MaterialAttribute::TextureCoordinates attribute in the base material. If neither is present, the default is 0. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::layerFactorTextureCoordinates(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::layerFactorTextureLayer(UnsignedInt layer) const

Factor array texture layer for given layer.

Convenience access to the MaterialAttribute::LayerFactorTextureLayer / MaterialAttribute::TextureLayer attributes in given layer or a MaterialAttribute::TextureLayer attribute in the base material. If neither is present, the default is 0. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to be smaller than layerCount().

UnsignedInt Magnum::Trade::MaterialData::layerFactorTextureLayer(Containers::StringView layer) const

Factor array texture layer for a named layer.

Convenience access to the MaterialAttribute::LayerFactorTextureLayer / MaterialAttribute::TextureLayer attributes in given layer or a MaterialAttribute::TextureLayer attribute in the base material. If neither is present, the default is 0. Available only if the MaterialAttribute::LayerFactorTexture attribute is present. The layer is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::layerFactorTextureLayer(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeCount(UnsignedInt layer) const

Attribute count in given layer.

The layer is expected to be smaller than layerCount() const.

UnsignedInt Magnum::Trade::MaterialData::attributeCount(Containers::StringView layer) const

Attribute count in a named layer.

The layer is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::attributeCount(MaterialLayer layer) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeCount() const

Attribute count in the base material.

Equivalent to calling attributeCount(UnsignedInt) const with layer set to 0.

bool Magnum::Trade::MaterialData::hasAttribute(UnsignedInt layer, Containers::StringView name) const

Whether a material layer has given attribute.

The layer is expected to be smaller than layerCount() const.

bool Magnum::Trade::MaterialData::hasAttribute(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool Magnum::Trade::MaterialData::hasAttribute(Containers::StringView layer, Containers::StringView name) const

Whether a named material layer has given attribute.

The layer is expected to exist.

bool Magnum::Trade::MaterialData::hasAttribute(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool Magnum::Trade::MaterialData::hasAttribute(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool Magnum::Trade::MaterialData::hasAttribute(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool Magnum::Trade::MaterialData::hasAttribute(Containers::StringView name) const

Whether the base material has given attribute.

Equivalent to calling hasAttribute(UnsignedInt, Containers::StringView) const with layer set to 0.

bool Magnum::Trade::MaterialData::hasAttribute(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(UnsignedInt layer, Containers::StringView name) const

Find ID of a named attribute in given material layer.

If name doesn't exist, returns Containers::NullOpt. The layer is expected to be smaller than layerCount() const. The lookup is done in an $ \mathcal{O}(\log n) $ complexity with $ n $ being attribute count in given layer.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(Containers::StringView layer, Containers::StringView name) const

Find ID of a named attribute in a named material layer.

If name doesn't exist, returns Containers::NullOpt. The layer is expected to exist. The lookup is done in an $ \mathcal{O}(m + \log n) $ complexity with $ m $ being layer count and $ n $ being attribute count in given layer.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(Containers::StringView name) const

Find ID of a named attribute in the base material.

Equivalent to calling findAttributeId(UnsignedInt, Containers::StringView) const with layer set to 0.

Containers::Optional<UnsignedInt> Magnum::Trade::MaterialData::findAttributeId(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeId(UnsignedInt layer, Containers::StringView name) const

ID of a named attribute in given material layer.

Like findAttributeId(UnsignedInt, Containers::StringView) const, but the name is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::attributeId(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeId(Containers::StringView layer, Containers::StringView name) const

ID of a named attribute in a named material layer.

Like findAttributeId(Containers::StringView, Containers::StringView) const, but the name is expected to exist.

UnsignedInt Magnum::Trade::MaterialData::attributeId(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeId(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeId(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MaterialData::attributeId(Containers::StringView name) const

ID of a named attribute in the base material.

Equivalent to calling attributeId(UnsignedInt, Containers::StringView) const with layer set to 0.

UnsignedInt Magnum::Trade::MaterialData::attributeId(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const MaterialAttributeData& Magnum::Trade::MaterialData::attributeData(UnsignedInt layer, UnsignedInt id) const

Raw attribute data.

The layer is expected to be smaller than layerCount() const, id is expected to be smaller than attributeCount(UnsignedInt) const.

const MaterialAttributeData& Magnum::Trade::MaterialData::attributeData(UnsignedInt id) const

Raw attribute data in the base material.

The id is expected to be smaller than attributeCount() const.

Containers::StringView Magnum::Trade::MaterialData::attributeName(UnsignedInt layer, UnsignedInt id) const

Name of an attribute in given material layer.

The layer is expected to be smaller than layerCount() const and the id is expected to be smaller than attributeCount(UnsignedInt) const in that layer. The returned view always has Containers::StringViewFlag::NullTerminated set.

Containers::StringView Magnum::Trade::MaterialData::attributeName(Containers::StringView layer, UnsignedInt id) const

Name of an attribute in a named material layer.

The layer is expected to exist and the id is expected to be smaller than attributeCount(UnsignedInt) const in that layer.

Containers::StringView Magnum::Trade::MaterialData::attributeName(MaterialLayer layer, UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Containers::StringView Magnum::Trade::MaterialData::attributeName(UnsignedInt id) const

Name of an attribute in the base material.

Equivalent to calling attributeName(UnsignedInt, UnsignedInt) const with layer set to 0.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(UnsignedInt layer, UnsignedInt id) const

Type of an attribute in given material layer.

The layer is expected to be smaller than layerCount() const and id is expected to be smaller than attributeCount(UnsignedInt) const in that layer.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(UnsignedInt layer, Containers::StringView name) const

Type of a named attribute in given material layer.

The layer is expected to be smaller than layerCount() const and name is expected to exist in that layer.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(Containers::StringView layer, UnsignedInt id) const

Type of an attribute in a named material layer.

The layer is expected to exist and the id is expected to be smaller than attributeCount(UnsignedInt) const in that layer.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(MaterialLayer layer, UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(Containers::StringView layer, Containers::StringView name) const

Type of a named attribute in a named material layer.

The layer is expected to exist and name is expected to exist in that layer.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(UnsignedInt id) const

Type of an attribute in the base material.

Equivalent to calling attributeType(UnsignedInt, UnsignedInt) const with layer set to 0.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(Containers::StringView name) const

Type of a named attribute in the base material.

Equivalent to calling attributeType(UnsignedInt, Containers::StringView) const with layer set to 0.

MaterialAttributeType Magnum::Trade::MaterialData::attributeType(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::attribute(UnsignedInt layer, UnsignedInt id) const

Type-erased value of an attribute in given material layer.

The layer is expected to be smaller than layerCount() const and id is expected to be smaller than attributeCount(UnsignedInt) const in that layer. Cast the pointer to a concrete type based on type().

void* Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt layer, UnsignedInt id)

Type-erased mutable value of an attribute in given material layer.

Like attribute(UnsignedInt, UnsignedInt) const but returns a mutable pointer. Expects that the material is mutable.

const void* Magnum::Trade::MaterialData::attribute(UnsignedInt layer, Containers::StringView name) const

Type-erased value of a named attribute in given material layer.

The layer is expected to be smaller than layerCount() const and name is expected to exist in that layer. Cast the pointer to a concrete type based on attributeType().

const void* Magnum::Trade::MaterialData::attribute(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void* Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt layer, Containers::StringView name)

Type-erased value of a named attribute in given material layer.

Like attribute(UnsignedInt, Containers::StringView) const, but returns a mutable pointer. Expects that the material is mutable.

void* Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt layer, MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::attribute(Containers::StringView layer, UnsignedInt id) const

Type-erased value of an attribute in a named material layer.

The layer is expected to exist and the id is expected to be smaller than attributeCount(UnsignedInt) const in that layer. Cast the pointer to a concrete type based on attributeType().

const void* Magnum::Trade::MaterialData::attribute(MaterialLayer layer, UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void* Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView layer, UnsignedInt id)

Type-erased mutable value of an attribute in a named material layer.

Like attribute(Containers::StringView, UnsignedInt) const but returns a mutable pointer. Expects that the material is mutable.

void* Magnum::Trade::MaterialData::mutableAttribute(MaterialLayer layer, UnsignedInt id)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::attribute(Containers::StringView layer, Containers::StringView name) const

Type-erased value of a named attribute in a named material layer.

The layer is expected to exist and name is expected to exist in that layer. Cast the pointer to a concrete type based on attributeType().

const void* Magnum::Trade::MaterialData::attribute(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::attribute(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::attribute(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void* Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView layer, Containers::StringView name)

Type-erased mutable value of a named attribute in a named material layer.

Like attribute(Containers::StringView, Containers::StringView) const but returns a mutable pointer. Expects that the material is mutable.

void* Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView layer, MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void* Magnum::Trade::MaterialData::mutableAttribute(MaterialLayer layer, Containers::StringView name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void* Magnum::Trade::MaterialData::mutableAttribute(MaterialLayer layer, MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::attribute(UnsignedInt id) const

Type-erased value of an attribute in the base material.

Equivalent to calling attribute(UnsignedInt, UnsignedInt) const with layer set to 0.

void* Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt id)

Type-erased mutable value of an attribute in the base material.

Like attribute(UnsignedInt) const but returns a mutable pointer. Expects that the material is mutable.

const void* Magnum::Trade::MaterialData::attribute(Containers::StringView name) const

Type-erased value of a named attribute in the base material.

Equivalent to calling attribute(UnsignedInt, Containers::StringView) const with layer set to 0.

const void* Magnum::Trade::MaterialData::attribute(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void* Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView name)

Type-erased mutable value of a named attribute in the base material.

Like attribute(Containers::StringView) const but returns a mutable pointer. Expects that the material is mutable.

void* Magnum::Trade::MaterialData::mutableAttribute(MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attribute(UnsignedInt layer, UnsignedInt id) const

Value of an attribute in given material layer.

The layer is expected to be smaller than layerCount() const and id is expected to be smaller than attributeCount(UnsignedInt) const in that layer. Expects that T corresponds to attributeType(UnsignedInt, UnsignedInt) const for given layer and id. In case of a string, the returned view always has Containers::StringViewFlag::NullTerminated set.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt layer, UnsignedInt id)

Mutable value of an attribute in given material layer.

Like attribute(UnsignedInt, UnsignedInt) const but returns a mutable reference. Expects that the material is mutable. In case of a string / buffer, you're expected to use Containers::MutableStringView / Containers::ArrayView<void> instead of Containers::StringView / Containers::ArrayView<const void> for T and you get a Containers::MutableStringView / Containers::ArrayView<void> back by-value, not by-reference. Changing the string / buffer size is not possible.

template<class T>
T Magnum::Trade::MaterialData::attribute(UnsignedInt layer, Containers::StringView name) const

Value of a named attribute in given material layer.

The layer is expected to be smaller than layerCount() const and name is expected to exist in that layer. Expects that T corresponds to attributeType(UnsignedInt, Containers::StringView) const for given layer and name. In case of a string, the returned view always has Containers::StringViewFlag::NullTerminated set.

template<class T>
T Magnum::Trade::MaterialData::attribute(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt layer, Containers::StringView name)

Mutable value of a named attribute in given material layer.

Like attribute(UnsignedInt, Containers::StringView) const but returns a mutable reference. Expects that the material is mutable. In case of a string / buffer, you're expected to use Containers::MutableStringView / Containers::ArrayView<void> instead of Containers::StringView / Containers::ArrayView<const void> for T and you get a Containers::MutableStringView / Containers::ArrayView<void> back by-value, not by-reference. Changing the string / buffer size is not possible.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt layer, MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attribute(Containers::StringView layer, UnsignedInt id) const

Value of an attribute in a named material layer.

The layer is expected to exist and id is expected to be smaller than attributeCount(UnsignedInt) const in that layer. Expects that T corresponds to attributeType(Containers::StringView, UnsignedInt) const for given layer and id. In case of a string, the returned view always has Containers::StringViewFlag::NullTerminated set.

template<class T>
T Magnum::Trade::MaterialData::attribute(MaterialLayer layer, UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView layer, UnsignedInt id)

Mutable value of an attribute in a named material layer.

Like attribute(Containers::StringView, UnsignedInt) const but returns a mutable reference. Expects that the material is mutable. In case of a string / buffer, you're expected to use Containers::MutableStringView / Containers::ArrayView<void> instead of Containers::StringView / Containers::ArrayView<const void> for T and you get a Containers::MutableStringView / Containers::ArrayView<void> back by-value, not by-reference. Changing the string / buffer size is not possible.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(MaterialLayer layer, UnsignedInt id)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attribute(Containers::StringView layer, Containers::StringView name) const

Value of a named attribute in a named material layer.

The layer is expected to exist and name is expected to exist in that layer. Expects that T corresponds to attributeType(Containers::StringView, Containers::StringView) const for given layer and name. In case of a string, the returned view always has Containers::StringViewFlag::NullTerminated set.

template<class T>
T Magnum::Trade::MaterialData::attribute(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attribute(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attribute(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView layer, Containers::StringView name)

Mutable value of a named attribute in a named material layer.

Like attribute(Containers::StringView, Containers::StringView) const but returns a mutable reference. Expects that the material is mutable. In case of a string / buffer, you're expected to use Containers::MutableStringView / Containers::ArrayView<void> instead of Containers::StringView / Containers::ArrayView<const void> for T and you get a Containers::MutableStringView / Containers::ArrayView<void> back by-value, not by-reference. Changing the string / buffer size is not possible.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView layer, MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(MaterialLayer layer, Containers::StringView name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(MaterialLayer layer, MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attribute(UnsignedInt id) const

Value of an attribute in the base material.

Equivalent to calling attribute(UnsignedInt, UnsignedInt) const with layer set to 0.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(UnsignedInt id)

Mutable value of an attribute in the base material.

Equivalent to calling mutableAttribute(UnsignedInt, UnsignedInt) with layer set to 0.

template<class T>
T Magnum::Trade::MaterialData::attribute(Containers::StringView name) const

Value of a named attribute in the base material.

Equivalent to calling attribute(UnsignedInt, Containers::StringView) const with layer set to 0.

template<class T>
T Magnum::Trade::MaterialData::attribute(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(Containers::StringView name)

Mutable value of a named attribute in the base material.

Equivalent to calling mutableAttribute(UnsignedInt, Containers::StringView) with layer set to 0.

template<class T>
std::conditional<std::is_same<T, Containers::MutableStringView>::value||std::is_same<T, Containers::ArrayView<void>>::value, T, T&>::type Magnum::Trade::MaterialData::mutableAttribute(MaterialAttribute name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::findAttribute(UnsignedInt layer, Containers::StringView name) const

Type-erased attribute value in given material layer, if exists.

Compared to attribute(UnsignedInt, Containers::StringView name) const, if name doesn't exist, returns nullptr instead of asserting. Expects that layer is smaller than layerCount() const. Cast the pointer to a concrete type based on attributeType().

const void* Magnum::Trade::MaterialData::findAttribute(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::tryAttribute(UnsignedInt layer, Containers::StringView name) const

Type-erased attribute value in given material layer, if exists.

const void* Magnum::Trade::MaterialData::findAttribute(Containers::StringView layer, Containers::StringView name) const

Type-erased attribute value in a named material layer, if exists.

Compared to attribute(Containers::StringView, Containers::StringView name) const, if name doesn't exist, returns nullptr instead of asserting. Expects that layer exists. Cast the pointer to a concrete type based on attributeType().

const void* Magnum::Trade::MaterialData::findAttribute(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::findAttribute(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::findAttribute(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::tryAttribute(Containers::StringView layer, Containers::StringView name) const

Type-erased attribute value in a named material layer, if exists.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(UnsignedInt layer, Containers::StringView name) const

Value of a named attribute in given material layer, if exists.

Compared to attribute(UnsignedInt, Containers::StringView name) const, if name doesn't exist, returns Containers::NullOpt instead of asserting. Expects that layer is smaller than layerCount() const and that T corresponds to attributeType(UnsignedInt, Containers::StringView) const for given layer and name.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(UnsignedInt layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::tryAttribute(UnsignedInt layer, Containers::StringView name) const

Type-erased attribute value in given material layer, if exists.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(Containers::StringView layer, Containers::StringView name) const

Value of a named attribute in a named material layer, if exists.

Compared to attribute(Containers::StringView, Containers::StringView name) const, if name doesn't exist, returns Containers::NullOpt instead of asserting. Expects that layer exists and that T corresponds to attributeType(Containers::StringView, Containers::StringView) const for given layer and name.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(Containers::StringView layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(MaterialLayer layer, Containers::StringView name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(MaterialLayer layer, MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::tryAttribute(Containers::StringView layer, Containers::StringView name) const

Type-erased attribute value in a named material layer, if exists.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::tryAttribute(MaterialLayer layer, Containers::StringView name) const

Type-erased attribute value in given material layer, if exists.

const void* Magnum::Trade::MaterialData::findAttribute(Containers::StringView name) const

Type-erased attribute value in the base material, if exists.

Equivalent to calling findAttribute(UnsignedInt, Containers::StringView) const with layer set to 0.

const void* Magnum::Trade::MaterialData::findAttribute(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MaterialData::tryAttribute(Containers::StringView name) const

Type-erased attribute value in the base material, if exists.

const void* Magnum::Trade::MaterialData::tryAttribute(MaterialAttribute name) const

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(Containers::StringView name) const

Value of a named attribute in the base material, if exists.

Equivalent to calling findAttribute(UnsignedInt, Containers::StringView) const with layer set to 0.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::findAttribute(MaterialAttribute name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::tryAttribute(Containers::StringView name) const

Type-erased attribute value in the base material, if exists.

template<class T>
Containers::Optional<T> Magnum::Trade::MaterialData::tryAttribute(MaterialAttribute name) const

template<class T>
T Magnum::Trade::MaterialData::attributeOr(UnsignedInt layer, Containers::StringView name, const T& defaultValue) const

Value of a named attribute in given layer or a default.

Compared to attribute(UnsignedInt, Containers::StringView name) const, if name doesn't exist, returns defaultValue instead of asserting. Expects that layer is smaller than layerCount() const and that T corresponds to attributeType(UnsignedInt, Containers::StringView) const for given layer and name.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(UnsignedInt layer, MaterialAttribute name, const T& defaultValue) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(Containers::StringView layer, Containers::StringView name, const T& defaultValue) const

Value of a named attribute in a named layer or a default.

Compared to attribute(Containers::StringView, Containers::StringView name) const, if name doesn't exist, returns defaultValue instead of asserting. Expects that layer exists and that T corresponds to attributeType(Containers::StringView, Containers::StringView) const for given layer and name.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(Containers::StringView layer, MaterialAttribute name, const T& defaultValue) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(MaterialLayer layer, Containers::StringView name, const T& defaultValue) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(MaterialLayer layer, MaterialAttribute name, const T& defaultValue) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(Containers::StringView name, const T& defaultValue) const

Value of a named attribute in the base material or a default.

Equivalent to calling attributeOr(UnsignedInt, Containers::StringView, const T&) const with layer set to 0.

template<class T>
T Magnum::Trade::MaterialData::attributeOr(MaterialAttribute name, const T& defaultValue) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool Magnum::Trade::MaterialData::isDoubleSided() const

Whether a material is double-sided.

Convenience access to the MaterialAttribute::DoubleSided attribute. If not present, the default is false.

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

Material flags.

Not all bits returned might be defined by Flag, subclasses may define extra values.

MaterialAlphaMode Magnum::Trade::MaterialData::alphaMode() const

Alpha mode.

Convenience access to MaterialAttribute::AlphaBlend and MaterialAttribute::AlphaMask attributes. If neither is present, the default is MaterialAlphaMode::Opaque.

Float Magnum::Trade::MaterialData::alphaMask() const

Alpha mask.

Convenience access to the MaterialAttribute::AlphaMask attribute. If not present, the default is 0.5f.

Containers::Array<UnsignedInt> Magnum::Trade::MaterialData::releaseLayerData()

Release layer data storage.

Releases the ownership of the layer offset array and resets internal layer-related state to default. The material then behaves like if it has no layers. Note that the returned array has a custom no-op deleter when the data are not owned by the material, and while the returned array type is mutable, the actual memory might be not.

Containers::Array<MaterialAttributeData> Magnum::Trade::MaterialData::releaseAttributeData()

Release attribute data storage.

Releases the ownership of the attribute array and resets internal attribute-related state to default. The material then behaves like if it has no attributes. Note that the returned array has a custom no-op deleter when the data are not owned by the material, and while the returned array type is mutable, the actual memory might be not.

const void* Magnum::Trade::MaterialData::importerState() const

Importer-specific state.

See AbstractImporter::importerState() for more information.

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

Debug output operator.

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

Debug output operator.