Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::InstancedRenderable Class Referenceabstract

Graphics class that represents an instancer renderable. More...

Inheritance diagram for Nz::InstancedRenderable:
Nz::RefCounted Nz::Billboard Nz::Model Nz::Sprite Nz::TextSprite Nz::TileMap Nz::SkeletalModel

Public Member Functions

 InstancedRenderable ()
 Constructs a InstancedRenderable object by default.
 
 InstancedRenderable (const InstancedRenderable &renderable)
 Constructs a InstancedRenderable object by assignation. More...
 
 InstancedRenderable (InstancedRenderable &&renderable)=delete
 
virtual ~InstancedRenderable ()
 Destructs the object and calls OnInstancedRenderableRelease. More...
 
virtual void AddToRenderQueue (AbstractRenderQueue *renderQueue, const InstanceData &instanceData) const =0
 
virtual bool Cull (const Frustumf &frustum, const InstanceData &instanceData) const
 Culls the instanced if not in the frustum. More...
 
void EnsureBoundingVolumeUpdated () const
 Ensures that the bounding volume is up to date.
 
virtual const BoundingVolumefGetBoundingVolume () const
 Gets the bounding volume. More...
 
const MaterialRefGetMaterial (std::size_t matIndex=0) const
 Gets one of the material used by the object. More...
 
const MaterialRefGetMaterial (std::size_t skinIndex, std::size_t matIndex) const
 Gets one of the material used by the object, independently from the active skin. More...
 
std::size_t GetMaterialCount () const
 Gets the number of material per skin. More...
 
std::size_t GetSkin () const
 Gets the current active skin index. More...
 
std::size_t GetSkinCount () const
 Gets the number of skins this object has. More...
 
virtual void InvalidateData (InstanceData *instanceData, UInt32 flags) const
 Invalidates data for instanced. More...
 
void SetSkin (std::size_t skinIndex)
 Changes the active skin. More...
 
void SetSkinCount (std::size_t skinCount)
 Changes the maximum skin count of the object. More...
 
virtual void UpdateBoundingVolume (InstanceData *instanceData) const
 Updates the bounding volume. More...
 
virtual void UpdateData (InstanceData *instanceData) const
 Updates the instance data. More...
 
InstancedRenderableoperator= (const InstancedRenderable &renderable)
 Sets the current instanced renderable with the content of the other one. More...
 
InstancedRenderableoperator= (InstancedRenderable &&renderable)=delete
 
 NazaraSignal (OnInstancedRenderableInvalidateBoundingVolume, const InstancedRenderable *)
 
 NazaraSignal (OnInstancedRenderableInvalidateData, const InstancedRenderable *, UInt32)
 
 NazaraSignal (OnInstancedRenderableInvalidateMaterial, const InstancedRenderable *, std::size_t, std::size_t, const MaterialRef &)
 
 NazaraSignal (OnInstancedRenderableRelease, const InstancedRenderable *)
 
 NazaraSignal (OnInstancedRenderableResetMaterials, const InstancedRenderable *, std::size_t)
 
 NazaraSignal (OnInstancedRenderableSkinChange, const InstancedRenderable *, std::size_t)
 
- Public Member Functions inherited from Nz::RefCounted
 RefCounted (bool persistent=true)
 Constructs a RefCounted object with a persistance aspect. More...
 
 RefCounted (const RefCounted &)=delete
 
 RefCounted (RefCounted &&)=default
 
virtual ~RefCounted ()
 Destructs the object. More...
 
void AddReference () const
 Adds a reference to the object.
 
unsigned int GetReferenceCount () const
 Gets the number of references to the object. More...
 
bool IsPersistent () const
 Checks whether the object is persistent. More...
 
bool RemoveReference () const
 Removes a reference to the object. More...
 
bool SetPersistent (bool persistent=true, bool checkReferenceCount=false)
 Sets the persistence of the object. More...
 
RefCountedoperator= (const RefCounted &)=delete
 
RefCountedoperator= (RefCounted &&)=default
 

Protected Member Functions

void InvalidateBoundingVolume ()
 Invalidates the bounding volume.
 
void InvalidateInstanceData (UInt32 flags)
 Invalidates the instance data based on flags. More...
 
virtual void MakeBoundingVolume () const =0
 
void ResetMaterials (std::size_t matCount, std::size_t skinCount=1)
 Resets the materials, material count and skin count. More...
 
void SetMaterial (std::size_t matIndex, MaterialRef material)
 Changes the material used at the specified index by another one. More...
 
void SetMaterial (std::size_t skinIndex, std::size_t matIndex, MaterialRef material)
 Changes the material used at the specified index by another one, independently from the active skin. More...
 

Protected Attributes

BoundingVolumef m_boundingVolume
 

Detailed Description

Graphics class that represents an instancer renderable.

Remarks
This class is abstract

Constructor & Destructor Documentation

◆ InstancedRenderable()

Nz::InstancedRenderable::InstancedRenderable ( const InstancedRenderable renderable)
inline

Constructs a InstancedRenderable object by assignation.

Parameters
renderableInstancedRenderable to copy into this

◆ ~InstancedRenderable()

Nz::InstancedRenderable::~InstancedRenderable ( )
virtual

Destructs the object and calls OnInstancedRenderableRelease.

See also
OnInstancedRenderableRelease

Member Function Documentation

◆ Cull()

bool Nz::InstancedRenderable::Cull ( const Frustumf frustum,
const InstanceData &  instanceData 
) const
virtual

Culls the instanced if not in the frustum.

Returns
true If instanced is in the frustum
Parameters
frustumSymbolizing the field of view
transformMatrixMatrix transformation for our object

◆ GetBoundingVolume()

const BoundingVolumef & Nz::InstancedRenderable::GetBoundingVolume ( ) const
virtual

Gets the bounding volume.

Returns
Bounding volume of the instanced

◆ GetMaterial() [1/2]

const MaterialRef & Nz::InstancedRenderable::GetMaterial ( std::size_t  matIndex = 0) const
inline

Gets one of the material used by the object.

Returns
A reference to the material.

This function returns the active material at the specified index, depending on the current active skin.

Parameters
matIndexMaterial index to query
See also
GetSkin, GetMaterialCount, SetSkin

◆ GetMaterial() [2/2]

const MaterialRef & Nz::InstancedRenderable::GetMaterial ( std::size_t  skinIndex,
std::size_t  matIndex 
) const
inline

Gets one of the material used by the object, independently from the active skin.

Returns
A reference to the material.

This function returns the active material at the specified index and the specified skin index. This function is the only way to query a material independently from the active skin.

Parameters
skinIndexSkin index to query
matIndexMaterial index to query
See also
GetSkinCount, GetMaterialCount, SetSkin

◆ GetMaterialCount()

std::size_t Nz::InstancedRenderable::GetMaterialCount ( ) const
inline

Gets the number of material per skin.

Returns
The current material count per skin

This function returns how many different materials entries exists per skin and is independent from the number of skin.

◆ GetSkin()

std::size_t Nz::InstancedRenderable::GetSkin ( ) const
inline

Gets the current active skin index.

Returns
Current skin index
See also
SetSkin

◆ GetSkinCount()

std::size_t Nz::InstancedRenderable::GetSkinCount ( ) const
inline

Gets the number of skins this object has.

Returns
Skin count
See also
GetSkin, SetSkinCount

◆ InvalidateData()

void Nz::InstancedRenderable::InvalidateData ( InstanceData *  instanceData,
UInt32  flags 
) const
virtual

Invalidates data for instanced.

Parameters
instanceDataPointer to data of instances
flagsFlags for the instances
Remarks
Produces a NazaraAssert if instanceData is invalid

◆ InvalidateInstanceData()

void Nz::InstancedRenderable::InvalidateInstanceData ( UInt32  flags)
inlineprotected

Invalidates the instance data based on flags.

Parameters
flagsFlags to invalidate

◆ operator=()

InstancedRenderable & Nz::InstancedRenderable::operator= ( const InstancedRenderable renderable)
inline

Sets the current instanced renderable with the content of the other one.

Returns
A reference to this
Parameters
renderableThe other InstancedRenderable

◆ ResetMaterials()

void Nz::InstancedRenderable::ResetMaterials ( std::size_t  matCount,
std::size_t  skinCount = 1 
)
inlineprotected

Resets the materials, material count and skin count.

This function clears the materials in use by the InstancedRenderable and resets its material count per skin along with its skin count. This is the only way of setting the material count per skin and should be called at least by the constructor of the derived class. Please note that all materials will be set to the default material, which should not be changed.

This function also resets the current skin to the first one.

Parameters
matCountThe new material count per skin value, must be at least 1
skinCountThe new skin count value
See also
GetMaterial, GetMaterialCount, GetSkinCount, SetSkinCount

◆ SetMaterial() [1/2]

void Nz::InstancedRenderable::SetMaterial ( std::size_t  matIndex,
MaterialRef  material 
)
inlineprotected

Changes the material used at the specified index by another one.

This function changes the active material at the specified index, depending on the current active skin, to the one passed as parameter.

Parameters
matIndexMaterial index
materialNew material, cannot be null
Remarks
If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
See also
SetMaterial

◆ SetMaterial() [2/2]

void Nz::InstancedRenderable::SetMaterial ( std::size_t  skinIndex,
std::size_t  matIndex,
MaterialRef  material 
)
inlineprotected

Changes the material used at the specified index by another one, independently from the active skin.

This function changes the active material at the specified index and for the specified skin index, to the one passed as parameter.

Parameters
skinIndexSkin index
matIndexMaterial index
materialNew material, cannot be null
Remarks
If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
See also
SetMaterial

◆ SetSkin()

void Nz::InstancedRenderable::SetSkin ( std::size_t  skinIndex)
inline

Changes the active skin.

Each InstancedRenderable has the possibility to have multiples skins, which are sets of materials. Using this function allows you to have an object reference multiple materials, while using only some of thems (depending on the type of the object, see GetMaterialCount).

Parameters
skinIndexSkin index to change to
See also
SetSkinCount

◆ SetSkinCount()

void Nz::InstancedRenderable::SetSkinCount ( std::size_t  skinCount)
inline

Changes the maximum skin count of the object.

This functions allows the object to store up to skinCount skins, which can then be switched to using SetSkin. Please note that the possibly new skins will be set to the default material, which should not be changed.

Parameters
skinCountSkin index to change to
See also
SetSkin

◆ UpdateBoundingVolume()

void Nz::InstancedRenderable::UpdateBoundingVolume ( InstanceData *  instanceData) const
virtual

Updates the bounding volume.

Parameters
instanceDataPointer to data of instances
Remarks
Produces a NazaraAssert if instanceData is invalid

◆ UpdateData()

void Nz::InstancedRenderable::UpdateData ( InstanceData *  instanceData) const
virtual

Updates the instance data.

Parameters
instanceDataPointer to data of instances
Remarks
Produces a NazaraAssert if instanceData is invalid

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