GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::Decals3D Class Reference

Set of decals in 3D space. More...

#include <GREM/graphics_3d/Decals3D.hpp>

Classes

struct  Parameters
 Struct of shader parameters representing the decals. More...

Public Types

using ParameterBuffer = UniformBuffer<Parameters, "Decals3DParameters">
 Shader buffer for decal parameters.

Public Member Functions

 Decals3D (Device &device, const Decals3DOptions &options={})
 Construct a set of decals.
void clearDecalMaterials () noexcept
 Remove all decal materials and images from the set, and consequently all decals as well.
DecalMaterialID createDecalMaterial (const DecalMaterialOptions &options)
 Create a decal material.
void clearDecals () noexcept
 Remove all decals from the set.
DecalID createDecal (DecalMaterialID materialID, const DecalOptions3D &options)
 Create a decal.
bool containsDecal (DecalID id) const noexcept
 Check if a specific decal handle is still valid, meaning that the decal has not yet been destroyed.
bool destroyDecal (DecalID id)
 Destroy a decal and remove it from the set.
void setDecalPosition (DecalID id, vec3 newPosition)
 Update the position of a decal.
void setDecalRange (DecalID id, float newRange)
 Update the range of a decal.
void setDecalOrientation (DecalID id, quat newOrientation)
 Update the rotation of a decal.
void setDecalSize (DecalID id, vec2 newSize)
 Update the size of a decal.
void setDecalOrigin (DecalID id, vec2 newOrigin)
 Update the origin of a decal.
void setDecalColor (DecalID id, Color newColor)
 Update the tint color of a decal.
void setDecalEmissiveFactor (DecalID id, vec3 newEmissiveFactor)
 Update the emissive factor of a decal.
void setDecalModelInstanceIdentifier (DecalID id, uint32_t newModelInstanceIdentifier)
 Update the model instance identifier of a decal.
void setOptions (const Decals3DOptions &newOptions)
 Set the configuration options of the decal set.
Decals3DOptions getOptions () const noexcept
 Get the configuration options of the decal set.
auto forEachDecal (auto callback)
 Execute a callback function for each decal in the decal set.

Detailed Description

Set of decals in 3D space.

Member Typedef Documentation

◆ ParameterBuffer

Shader buffer for decal parameters.

Constructor & Destructor Documentation

◆ Decals3D()

grem::graphics::Decals3D::Decals3D ( Device & device,
const Decals3DOptions & options = {} )
explicit

Construct a set of decals.

Parameters
devicedevice to create the decals for. Must outlive the decals.
optionsdecal set options, see Decals3DOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ clearDecalMaterials()

void grem::graphics::Decals3D::clearDecalMaterials ( )
noexcept

Remove all decal materials and images from the set, and consequently all decals as well.

◆ createDecalMaterial()

DecalMaterialID grem::graphics::Decals3D::createDecalMaterial ( const DecalMaterialOptions & options)
nodiscard

Create a decal material.

Parameters
optionsdecal material options, see DecalMaterialOptions.
Returns
an identifier for the inserted decal material.
Exceptions
graphics::Erroron failure to copy an image or expand a texture atlas.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ clearDecals()

void grem::graphics::Decals3D::clearDecals ( )
noexcept

Remove all decals from the set.

◆ createDecal()

DecalID grem::graphics::Decals3D::createDecal ( DecalMaterialID materialID,
const DecalOptions3D & options )

Create a decal.

Parameters
materialIDidentifier for the decal material. Must be a valid identifier acquired using createDecalMaterial().
optionsdecal options, see DecalOptions3D.
Returns
a handle to the new decal that can be used to refer back to it later in order to make changes to it.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ containsDecal()

bool grem::graphics::Decals3D::containsDecal ( DecalID id) const
nodiscardnoexcept

Check if a specific decal handle is still valid, meaning that the decal has not yet been destroyed.

Parameters
idhandle to the decal.
Returns
true if the associated decal still exists, false if the decal has been destroyed.

◆ destroyDecal()

bool grem::graphics::Decals3D::destroyDecal ( DecalID id)

Destroy a decal and remove it from the set.

Parameters
idhandle to the decal.
Returns
true if the specified decal was found and destroyed, false otherwise.
Note
If the specified decal has already been destroyed, this function has no effect.

◆ setDecalPosition()

void grem::graphics::Decals3D::setDecalPosition ( DecalID id,
vec3 newPosition )

Update the position of a decal.

Parameters
idhandle to the decal.
newPositionnew position of the decal, in world coordinates.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalRange()

void grem::graphics::Decals3D::setDecalRange ( DecalID id,
float newRange )

Update the range of a decal.

Parameters
idhandle to the decal.
newRangenew maximum range from the decal position, in world coordinates, where the decal will apply to meshes.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalOrientation()

void grem::graphics::Decals3D::setDecalOrientation ( DecalID id,
quat newOrientation )

Update the rotation of a decal.

Parameters
idhandle to the decal.
newOrientationnew rotation of the decal around its origin.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalSize()

void grem::graphics::Decals3D::setDecalSize ( DecalID id,
vec2 newSize )

Update the size of a decal.

Parameters
idhandle to the decal.
newSizenew size of the decal, in world coordinates.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalOrigin()

void grem::graphics::Decals3D::setDecalOrigin ( DecalID id,
vec2 newOrigin )

Update the origin of a decal.

Parameters
idhandle to the decal.
newOriginnew offset, in texture coordinates, specifying the origin relative to the bottom left of the decal. For example, a value of (0.5, 0.5) corresponds to the middle of the decal.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalColor()

void grem::graphics::Decals3D::setDecalColor ( DecalID id,
Color newColor )

Update the tint color of a decal.

Parameters
idhandle to the decal.
newColornew tint color to use in the shader.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalEmissiveFactor()

void grem::graphics::Decals3D::setDecalEmissiveFactor ( DecalID id,
vec3 newEmissiveFactor )

Update the emissive factor of a decal.

Parameters
idhandle to the decal.
newEmissiveFactornew emissive factor to use in the shader.
Note
If the given decal handle is invalid, this function has no effect.

◆ setDecalModelInstanceIdentifier()

void grem::graphics::Decals3D::setDecalModelInstanceIdentifier ( DecalID id,
uint32_t newModelInstanceIdentifier )

Update the model instance identifier of a decal.

Parameters
idhandle to the decal.
newModelInstanceIdentifiernew model instance identifier that the decal applies to, or the maximum value to apply to all instances.
Note
If the given decal handle is invalid, this function has no effect.

◆ setOptions()

void grem::graphics::Decals3D::setOptions ( const Decals3DOptions & newOptions)
inline

Set the configuration options of the decal set.

Parameters
newOptionsnew configuration options, see Decals3DOptions.

◆ getOptions()

Decals3DOptions grem::graphics::Decals3D::getOptions ( ) const
inlinenodiscardnoexcept

Get the configuration options of the decal set.

Returns
the current configuration options.

◆ forEachDecal()

auto grem::graphics::Decals3D::forEachDecal ( auto callback)
inline

Execute a callback function for each decal in the decal set.

Parameters
callbackfunction to execute, which should accept the decal ID as a parameter. The callback function should return either void or a bool that specifies whether to stop the traversal or not. A value of true means to stop and return early, while a value of false means to continue traversing.
Returns
void if the callback function returns void, true if the callback returns bool and exited early, false if the callback function returns bool but didn't exit early.
Exceptions
anyexception thrown by the callback function.
Note
The order of traversal is unspecified.
Warning
Decals must not be added or removed from the set during traversal, unless the traversal is stopped immediately afterwards.

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