Kuesa Runtime

MeshInstantiator Class

class Kuesa::MeshInstantiator

Kuesa::MeshInstantiator allows to render several instances of a same mesh with different transformations. More...

Header: #include <Kuesa/MeshInstantiator>
Since: Kuesa 1.3
Instantiated By: MeshInstantiator
Inherits: Kuesa::KuesaNode

This class was introduced in Kuesa 1.3.

Properties

Public Functions

int count() const
QString entityName() const
void setEntityName(const QString &entityName)
void setTransformationMatrices(const std::vector<QMatrix4x4> &transformationMatrices)
const std::vector<QMatrix4x4> &transformationMatrices() const

Signals

void countChanged(int count)
void entityNameChanged(const QString &entityName)

Detailed Description

Instanced drawing is a drawing technique that relies on a single draw call being made to the graphics API and letting the GPU draw several instances of the same base mesh.

Each mesh instance can be controlled by per instance properties provided under the form of per instance attributes.

Kuesa::MeshInstantiator simplifies that process by expecting users provide an array of QMatrix4x4 transformations. The number of transformations dictates the number of instances to draw and each instance will be transformed by one of the transformations.

There is no strict limitations on how many instances can be drawn as it is GPU dependent. For simple meshes, this can easily be thousands of instances.

Note: For the instances to be visible, you should ensure that either frustum culling is disabled or that the initial instances (the mesh with no transformation applies) fit within the view frustum. Furthermore care needs to be taken to not share the material you intend to use with the instanced meshes with the material used for non instanced meshes.

Property Documentation

count : const int

The number of instances being drawn. The number of instances being drawn. It will be at least 1 even if no transformation matrices were provided.

Access functions:

int count() const

Notifier signal:

void countChanged(int count)

entityName : QString

The name of the entity to be retrieved from the Kuesa::EntityCollection and instantiated.

Access functions:

QString entityName() const
void setEntityName(const QString &entityName)

Notifier signal:

void entityNameChanged(const QString &entityName)

Member Function Documentation

void MeshInstantiator::setTransformationMatrices(const std::vector<QMatrix4x4> &transformationMatrices)

Set the transformation matrices transformationMatrices to be associated and applied to the instances.

See also transformationMatrices().

const std::vector<QMatrix4x4> &MeshInstantiator::transformationMatrices() const

Returns the transformation matrices.

See also setTransformationMatrices().