Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::Material Class Referencefinal

Represents a surface material with uniform properties and texture samplers. More...

#include <aeongames/Material.hpp>

Inheritance diagram for AeonGames::Material:
Inheritance graph
Collaboration diagram for AeonGames::Material:
Collaboration graph

Public Types

using UniformValue = std::variant<uint32_t, int32_t, float, Vector2, Vector3, Vector4, Matrix4x4>
 Variant type holding any supported uniform value.
using UniformKeyValue = std::tuple<std::string, UniformValue>
 Key-value pair mapping a uniform name to its value.
using SamplerKeyValue = std::tuple<uint32_t, ResourceId>
 Key-value pair mapping a sampler binding index to an image resource id.

Public Member Functions

DLL Material ()
 Default constructor.
DLL Material (const Material &aMaterial)
 The Copy Contsructor is used for virtual copying.
DLL Materialoperator= (const Material &aMaterial)
 Assignment operator due to rule of zero/three/five.
Materialoperator= (Material &&)=delete
 No move assignment allowed.
 Material (Material &&)=delete
 No move allowed.
DLL ~Material () final
 Destructor.
DLL const std::vector< uint8_t > & GetUniformBuffer () const
 Get the raw uniform buffer.
Loaders
DLL void LoadFromPBMsg (const MaterialMsg &aMaterialMsg)
 Load material data from a protobuf message.
DLL void LoadFromMemory (const void *aBuffer, size_t aBufferSize) final
 Load material data from a raw memory buffer.
DLL void Unload () final
 Unload material data and release resources.
Property and Sampler Setters
DLL void Set (size_t aIndex, const UniformValue &aValue)
 Set a uniform value by index.
DLL void Set (const UniformKeyValue &aValue)
 Set a uniform value by name-value pair.
DLL void SetSampler (const std::string &aName, const ResourceId &aValue)
 Set a sampler binding by name.
Property and Sampler Getters
DLL ResourceId GetSampler (const std::string &aName)
 Get the resource id of a sampler by name.
DLL const std::vector< std::tuple< uint32_t, ResourceId > > & GetSamplers () const
 Get all sampler bindings.
Public Member Functions inherited from AeonGames::Resource
virtual ~Resource ()
 Virtual destructor.
DLL void LoadFromId (uint32_t aId)
 Load the resource identified by a numeric id.
DLL void LoadFromFile (const std::string &aFilename)
 Load the resource from a file on disk.
DLL size_t GetConsecutiveId () const
 Get the Consecutive Id for the resource object.

Detailed Description

Represents a surface material with uniform properties and texture samplers.

Definition at line 37 of file Material.hpp.

Member Typedef Documentation

◆ SamplerKeyValue

using AeonGames::Material::SamplerKeyValue = std::tuple<uint32_t, ResourceId>

Key-value pair mapping a sampler binding index to an image resource id.

Definition at line 45 of file Material.hpp.

◆ UniformKeyValue

using AeonGames::Material::UniformKeyValue = std::tuple<std::string, UniformValue>

Key-value pair mapping a uniform name to its value.

Definition at line 43 of file Material.hpp.

◆ UniformValue

using AeonGames::Material::UniformValue = std::variant<uint32_t, int32_t, float, Vector2, Vector3, Vector4, Matrix4x4>

Variant type holding any supported uniform value.

Definition at line 41 of file Material.hpp.

Constructor & Destructor Documentation

◆ Material()

AeonGames::Material::Material ( const Material & aMaterial)

The Copy Contsructor is used for virtual copying.

Definition at line 37 of file Material.cpp.

Member Function Documentation

◆ GetSampler()

ResourceId AeonGames::Material::GetSampler ( const std::string & aName)

Get the resource id of a sampler by name.

Parameters
aNameSampler name.
Returns
Resource id bound to the sampler.

Definition at line 250 of file Material.cpp.

◆ GetSamplers()

const std::vector< std::tuple< uint32_t, ResourceId > > & AeonGames::Material::GetSamplers ( ) const

Get all sampler bindings.

Returns
Const reference to the vector of sampler key-value pairs.

Definition at line 245 of file Material.cpp.

◆ GetUniformBuffer()

const std::vector< uint8_t > & AeonGames::Material::GetUniformBuffer ( ) const

Get the raw uniform buffer.

Returns
Const reference to the uniform data byte vector.

Definition at line 45 of file Material.cpp.

◆ LoadFromMemory()

void AeonGames::Material::LoadFromMemory ( const void * aBuffer,
size_t aBufferSize )
finalvirtual

Load material data from a raw memory buffer.

Parameters
aBufferPointer to the buffer.
aBufferSizeSize of the buffer in bytes.

Implements AeonGames::Resource.

Definition at line 186 of file Material.cpp.

◆ LoadFromPBMsg()

void AeonGames::Material::LoadFromPBMsg ( const MaterialMsg & aMaterialMsg)

Load material data from a protobuf message.

Parameters
aMaterialMsgThe protobuf message to load from.

Definition at line 191 of file Material.cpp.

◆ operator=()

Material & AeonGames::Material::operator= ( const Material & aMaterial)

Assignment operator due to rule of zero/three/five.

Definition at line 38 of file Material.cpp.

◆ Set() [1/2]

void AeonGames::Material::Set ( const UniformKeyValue & aValue)

Set a uniform value by name-value pair.

Parameters
aValueKey-value pair with the uniform name and value.

Definition at line 210 of file Material.cpp.

◆ Set() [2/2]

void AeonGames::Material::Set ( size_t aIndex,
const UniformValue & aValue )

Set a uniform value by index.

Parameters
aIndexIndex of the uniform variable.
aValueNew value to assign.

Definition at line 205 of file Material.cpp.

◆ SetSampler()

void AeonGames::Material::SetSampler ( const std::string & aName,
const ResourceId & aValue )

Set a sampler binding by name.

Parameters
aNameSampler name.
aValueResource id of the image to bind.

Definition at line 231 of file Material.cpp.

◆ Unload()

void AeonGames::Material::Unload ( )
finalvirtual

Unload material data and release resources.

Implements AeonGames::Resource.

Definition at line 265 of file Material.cpp.


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