Skip to content

Kuesa::Qt3D::MeshInstantiator

Module: Kuesa Qt 3D API

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

#include <Kuesa/Qt3D/api/meshinstantiator.h>

Inherits from Kuesa::Qt3D::KuesaNode, Qt3DCore::QNode

Public Signals

Name
void countChanged(int count)
void transformationMatricesChanged(const std::vector< QMatrix4x4 > & transformationMatrices)
void entityNameChanged(const QString & entityName)

Public Functions

Name
MeshInstantiator(Qt3DCore::QNode * parent =nullptr)
~MeshInstantiator() =default
int count() const
void setEntityName(const QString & entityName)
QString entityName() const
void setTransformationMatrices(const std::vector< QMatrix4x4 > & transformationMatrices)
const std::vector< QMatrix4x4 > & transformationMatrices() const

Public Properties

Name
QString entityName
int count

Additional inherited members

Public Slots inherited from Kuesa::Qt3D::KuesaNode

Name
void setSceneEntity(Kuesa::Qt3D::SceneEntity * sceneEntity)

Public Signals inherited from Kuesa::Qt3D::KuesaNode

Name
void sceneEntityChanged(Kuesa::Qt3D::SceneEntity * sceneEntity)

Public Functions inherited from Kuesa::Qt3D::KuesaNode

Name
KuesaNode(Qt3DCore::QNode * parent =nullptr)
SceneEntity * sceneEntity() const

Public Properties inherited from Kuesa::Qt3D::KuesaNode

Name
Kuesa::Qt3D::SceneEntity * sceneEntity

Protected Attributes inherited from Kuesa::Qt3D::KuesaNode

Name
SceneEntity * m_sceneEntity

Detailed Description

1
class Kuesa::Qt3D::MeshInstantiator;

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

Since: Kuesa 2.0

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.

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::Qt3D::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.

Public Signals Documentation

signal countChanged

1
2
3
void countChanged(
    int count
)

signal transformationMatricesChanged

1
2
3
void transformationMatricesChanged(
    const std::vector< QMatrix4x4 > & transformationMatrices
)

signal entityNameChanged

1
2
3
void entityNameChanged(
    const QString & entityName
)

Public Functions Documentation

function MeshInstantiator

1
2
3
explicit MeshInstantiator(
    Qt3DCore::QNode * parent =nullptr
)

function ~MeshInstantiator

1
~MeshInstantiator() =default

function count

1
int count() const

function setEntityName

1
2
3
void setEntityName(
    const QString & entityName
)

function entityName

1
QString entityName() const

function setTransformationMatrices

1
2
3
void setTransformationMatrices(
    const std::vector< QMatrix4x4 > & transformationMatrices
)

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

function transformationMatrices

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

Returns the transformation matrices.

Public Property Documentation

property entityName

1
QString entityName;

The name of the entity to be retrieved from the

property count

1
int count;

\readonly

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.


Updated on 2022-10-18 at 11:12:52 +0200