Skip to content

Kuesa::Qt3D::Particles

Module: Kuesa Qt 3D API

Particle system that controls emission and the various properties or particles over their lifetime. More...

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

Inherits from Qt3DCore::QEntity

Public Types

Name
enum class AlignMode { FaceCamera, Velocity}

Public Slots

Name
void setParticleCount(int particleCount)
void setFrameTime(float frameTime)
void setMaxParticlesEmittedPerFrame(int maxParticlesEmittedPerFrame)
void setGravity(const QVector3D & gravity)
void setEmitterPosition(const QVector3D & emitterPosition)
void setEmitterPositionRandom(const QVector3D & emitterPositionRandom)
void setEmitterVelocity(const QVector3D & emitterVelocity)
void setEmitterVelocityRandom(const QVector3D & emitterVelocityRandom)
void setParticleLifespan(float lifespan)
void setParticleLifespanRandom(float lifespanRandom)
void setInitialSize(const QVector2D & initialSize)
void setFinalSize(const QVector2D & finalSize)
void setInitialColor(const QVector4D & initialColor)
void setFinalColor(const QVector4D & finalColor)
void setInitialAngle(float initialAngle)
void setInitialAngleRandom(float initialAngleRandom)
void setRotationRate(float rotationRate)
void setRotationRateRandom(float rotationRateRandom)
void setSpriteTexture(Qt3DRender::QAbstractTexture * spriteTexture)
void setAlignMode(AlignMode alignMode)

Public Signals

Name
void particleCountChanged(int particleCount)
void frameTimeChanged(float frameTime)
void maxParticlesEmittedPerFrameChanged(int maxParticlesEmittedPerFrame)
void gravityChanged(const QVector3D & gravity)
void emitterPositionChanged(const QVector3D & emitterPosition)
void emitterPositionRandomChanged(const QVector3D & emitterPositionRandom)
void emitterVelocityChanged(const QVector3D & emitterVelocity)
void emitterVelocityRandomChanged(const QVector3D & emitterVelocityRandom)
void particleLifespanChanged(float particleLifespan)
void particleLifespanRandomChanged(float particleLifespanRandom)
void initialSizeChanged(const QVector2D & initialSize)
void finalSizeChanged(const QVector2D & finalSize)
void initialColorChanged(const QVector4D & initialColor)
void finalColorChanged(const QVector4D & finalColor)
void initialAngleChanged(float initialAngle)
void initialAngleRandomChanged(float initialAngleRandom)
void rotationRateChanged(float rotationRate)
void rotationRateRandomChanged(float rotationRateRandom)
void spriteTextureChanged(const Qt3DRender::QAbstractTexture * spriteTexture)
void alignModeChanged(AlignMode alignMode)

Public Functions

Name
Q_ENUM(AlignMode )
Particles(Qt3DCore::QEntity * parent =nullptr)
int particleCount() const
float frameTime() const
int maxParticlesEmittedPerFrame() const
QVector3D gravity() const
QVector3D emitterPosition() const
QVector3D emitterPositionRandom() const
QVector3D emitterVelocity() const
QVector3D emitterVelocityRandom() const
float particleLifespan() const
float particleLifespanRandom() const
QVector2D initialSize() const
QVector2D finalSize() const
QVector4D initialColor() const
QVector4D finalColor() const
float initialAngle() const
float initialAngleRandom() const
float rotationRate() const
float rotationRateRandom() const
Qt3DRender::QAbstractTexture * spriteTexture() const
AlignMode alignMode() const

Public Properties

Name
int particleCount
float frameTime
int maxParticlesEmittedPerFrame
QVector3D gravity
QVector3D emitterPosition
QVector3D emitterPositionRandom
QVector3D emitterVelocity
QVector3D emitterVelocityRandom
float particleLifespan
float particleLifespanRandom
QVector2D initialSize
QVector2D finalSize
QVector4D initialColor
QVector4D finalColor
float initialAngle
float initialAngleRandom
float rotationRate
float rotationRateRandom
Qt3DRender::QAbstractTexture * spriteTexture
AlignMode alignMode

Detailed Description

1
class Kuesa::Qt3D::Particles;

Particle system that controls emission and the various properties or particles over their lifetime.

Since: Kuesa 2.0

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <Qt3DExtras/Qt3DWindow>
#include <ForwardRenderer>
#include <SceneEntity>
#include <Particles>

Qt3DExtras::Qt3DWindow win;
Kuesa::Qt3D::SceneEntity *root = new Kuesa::Qt3D::SceneEntity();
Kuesa::Qt3D::ForwardRenderer *frameGraph = new Kuesa::Qt3D::ForwardRenderer();
frameGraph->setParticlesEnabled(true)

Kuesa::Qt3D::Particles *particles = new Kuesa::Qt3D::Particles(root);
particles->setParticleCount(128);
particles->setMaxParticlesEmittedPerFrame(4);
particles->setGravity(QVector3D(0.0f, -1.0f, 0.0f));
...

win->setRootEntity(root);
win->setActiveFrameGraph(forwardRenderer);
...

Public Types Documentation

enum AlignMode

Enumerator Value Description
FaceCamera
Velocity

This enum type describes the available particle alignment modes.

  • FaceCamera The particle faces the camera at all times.
  • Velocity The particle's local Y axis is aligned to its direction.

Public Slots Documentation

slot setParticleCount

1
2
3
void setParticleCount(
    int particleCount
)

slot setFrameTime

1
2
3
void setFrameTime(
    float frameTime
)

slot setMaxParticlesEmittedPerFrame

1
2
3
void setMaxParticlesEmittedPerFrame(
    int maxParticlesEmittedPerFrame
)

slot setGravity

1
2
3
void setGravity(
    const QVector3D & gravity
)

slot setEmitterPosition

1
2
3
void setEmitterPosition(
    const QVector3D & emitterPosition
)

slot setEmitterPositionRandom

1
2
3
void setEmitterPositionRandom(
    const QVector3D & emitterPositionRandom
)

slot setEmitterVelocity

1
2
3
void setEmitterVelocity(
    const QVector3D & emitterVelocity
)

slot setEmitterVelocityRandom

1
2
3
void setEmitterVelocityRandom(
    const QVector3D & emitterVelocityRandom
)

slot setParticleLifespan

1
2
3
void setParticleLifespan(
    float lifespan
)

slot setParticleLifespanRandom

1
2
3
void setParticleLifespanRandom(
    float lifespanRandom
)

slot setInitialSize

1
2
3
void setInitialSize(
    const QVector2D & initialSize
)

slot setFinalSize

1
2
3
void setFinalSize(
    const QVector2D & finalSize
)

slot setInitialColor

1
2
3
void setInitialColor(
    const QVector4D & initialColor
)

slot setFinalColor

1
2
3
void setFinalColor(
    const QVector4D & finalColor
)

slot setInitialAngle

1
2
3
void setInitialAngle(
    float initialAngle
)

slot setInitialAngleRandom

1
2
3
void setInitialAngleRandom(
    float initialAngleRandom
)

slot setRotationRate

1
2
3
void setRotationRate(
    float rotationRate
)

slot setRotationRateRandom

1
2
3
void setRotationRateRandom(
    float rotationRateRandom
)

slot setSpriteTexture

1
2
3
void setSpriteTexture(
    Qt3DRender::QAbstractTexture * spriteTexture
)

slot setAlignMode

1
2
3
void setAlignMode(
    AlignMode alignMode
)

Public Signals Documentation

signal particleCountChanged

1
2
3
void particleCountChanged(
    int particleCount
)

signal frameTimeChanged

1
2
3
void frameTimeChanged(
    float frameTime
)

signal maxParticlesEmittedPerFrameChanged

1
2
3
void maxParticlesEmittedPerFrameChanged(
    int maxParticlesEmittedPerFrame
)

signal gravityChanged

1
2
3
void gravityChanged(
    const QVector3D & gravity
)

signal emitterPositionChanged

1
2
3
void emitterPositionChanged(
    const QVector3D & emitterPosition
)

signal emitterPositionRandomChanged

1
2
3
void emitterPositionRandomChanged(
    const QVector3D & emitterPositionRandom
)

signal emitterVelocityChanged

1
2
3
void emitterVelocityChanged(
    const QVector3D & emitterVelocity
)

signal emitterVelocityRandomChanged

1
2
3
void emitterVelocityRandomChanged(
    const QVector3D & emitterVelocityRandom
)

signal particleLifespanChanged

1
2
3
void particleLifespanChanged(
    float particleLifespan
)

signal particleLifespanRandomChanged

1
2
3
void particleLifespanRandomChanged(
    float particleLifespanRandom
)

signal initialSizeChanged

1
2
3
void initialSizeChanged(
    const QVector2D & initialSize
)

signal finalSizeChanged

1
2
3
void finalSizeChanged(
    const QVector2D & finalSize
)

signal initialColorChanged

1
2
3
void initialColorChanged(
    const QVector4D & initialColor
)

signal finalColorChanged

1
2
3
void finalColorChanged(
    const QVector4D & finalColor
)

signal initialAngleChanged

1
2
3
void initialAngleChanged(
    float initialAngle
)

signal initialAngleRandomChanged

1
2
3
void initialAngleRandomChanged(
    float initialAngleRandom
)

signal rotationRateChanged

1
2
3
void rotationRateChanged(
    float rotationRate
)

signal rotationRateRandomChanged

1
2
3
void rotationRateRandomChanged(
    float rotationRateRandom
)

signal spriteTextureChanged

1
2
3
void spriteTextureChanged(
    const Qt3DRender::QAbstractTexture * spriteTexture
)

signal alignModeChanged

1
2
3
void alignModeChanged(
    AlignMode alignMode
)

Public Functions Documentation

function Q_ENUM

1
2
3
Q_ENUM(
    AlignMode 
)

function Particles

1
2
3
explicit Particles(
    Qt3DCore::QEntity * parent =nullptr
)

function particleCount

1
int particleCount() const

function frameTime

1
float frameTime() const

function maxParticlesEmittedPerFrame

1
int maxParticlesEmittedPerFrame() const

function gravity

1
QVector3D gravity() const

function emitterPosition

1
QVector3D emitterPosition() const

function emitterPositionRandom

1
QVector3D emitterPositionRandom() const

function emitterVelocity

1
QVector3D emitterVelocity() const

function emitterVelocityRandom

1
QVector3D emitterVelocityRandom() const

function particleLifespan

1
float particleLifespan() const

function particleLifespanRandom

1
float particleLifespanRandom() const

function initialSize

1
QVector2D initialSize() const

function finalSize

1
QVector2D finalSize() const

function initialColor

1
QVector4D initialColor() const

function finalColor

1
QVector4D finalColor() const

function initialAngle

1
float initialAngle() const

function initialAngleRandom

1
float initialAngleRandom() const

function rotationRate

1
float rotationRate() const

function rotationRateRandom

1
float rotationRateRandom() const

function spriteTexture

1
Qt3DRender::QAbstractTexture * spriteTexture() const

function alignMode

1
AlignMode alignMode() const

Public Property Documentation

property particleCount

1
int particleCount;

Since: Kuesa 2.0

Holds the maximum number of particles the system can handle. Currently the maximum value is 2048.

\default 32

property frameTime

1
float frameTime;

Since: Kuesa 2.0

Holds the speed at which updates need to be made in milliseconds.

\default 1/60

property maxParticlesEmittedPerFrame

1
int maxParticlesEmittedPerFrame;

Since: Kuesa 2.0

Holds the maximum number of new particles that can be created each frame.

\default 4

property gravity

1
QVector3D gravity;

Since: Kuesa 2.0

Holds the gravity value to apply to the particles.

property emitterPosition

1
QVector3D emitterPosition;

Since: Kuesa 2.0

Holds the world position of the particle emitter.

property emitterPositionRandom

1
QVector3D emitterPositionRandom;

Since: Kuesa 2.0

Holds the randomness factor applied to the world position.

property emitterVelocity

1
QVector3D emitterVelocity;

Since: Kuesa 2.0

Holds the velocity applied to the particles.

property emitterVelocityRandom

1
QVector3D emitterVelocityRandom;

Since: Kuesa 2.0

Holds the velocity randomness factor applied to the particles.

property particleLifespan

1
float particleLifespan;

Since: Kuesa 2.0 \default 1

Holds the lifetime of the particles.

property particleLifespanRandom

1
float particleLifespanRandom;

Since: Kuesa 2.0

Holds the lifetime randomness factor applied to the particles.

property initialSize

1
QVector2D initialSize;

Since: Kuesa 2.0 \default 0

Holds the initial size of the particles.

property finalSize

1
QVector2D finalSize;

Since: Kuesa 2.0

Holds the final size of the particles.

property initialColor

1
QVector4D initialColor;

Since: Kuesa 2.0

Holds the initial color of the particles.

property finalColor

1
QVector4D finalColor;

Since: Kuesa 2.0

Holds the final color of the particles.

property initialAngle

1
float initialAngle;

Since: Kuesa 2.0

Holds the initial rotation angle in radians of the particles.

property initialAngleRandom

1
float initialAngleRandom;

Since: Kuesa 2.0

Holds the initial rotation randomness factor applied to the particles.

property rotationRate

1
float rotationRate;

Since: Kuesa 2.0

Holds the rotation speed applied to the particles.

property rotationRateRandom

1
float rotationRateRandom;

Since: Kuesa 2.0

Holds the rotation speed randomness factor applied to the particles.

property spriteTexture

1
Qt3DRender::QAbstractTexture * spriteTexture;

Since: Kuesa 2.0

Holds the 2D sprite texture to apply to the particles.

property alignMode

1
AlignMode alignMode;

Since: Kuesa 2.0

Holds the alignment mode for the particles.

  • FaceCamera The particle faces the camera at all times.
  • Velocity The particle's local Y axis is aligned to its direction.

If the Velocity alignment mode is used, the initialAngle and rotationRate properties are ignored.


Updated on 2023-07-03 at 11:02:09 +0000