Confetti
0.1.0
A C++ particle system using Vulkan
|
An external (to any particle or emitter) set of factors that affect a particle's position and velocity. More...
#include <Confetti/Environment.h>
Classes | |
struct | Surface |
A plane that the particles bounce against. More... | |
Public Types | |
using | Clipper = glm::vec4 |
A plane that clips particles. | |
using | SurfaceList = std::vector< Surface > |
A list of Surfaces. | |
using | ClipperList = std::vector< Clipper > |
A list of Clippers. | |
Public Member Functions | |
Environment (glm::vec3 const &gravity={ 0.0f, 0.0f, 0.0f }, float airFriction=0.0f, glm::vec3 const &windVelocity={ 0.0f, 0.0f, 0.0f }, float gustiness=0.0f, SurfaceList const &bpl=SurfaceList(), ClipperList const &cpl=ClipperList()) | |
Constructor. More... | |
void | setGravity (glm::vec3 const &gravity) |
Sets gravity. | |
glm::vec3 | gravity () const |
Returns gravity. | |
void | setAirFriction (float airFriction) |
Sets air friction. | |
float | airFriction () const |
Returns air friction. | |
void | setWindVelocity (glm::vec3 const &wind) |
Sets wind velocity. | |
glm::vec3 | windVelocity () const |
Returns wind velocity. | |
void | setGustiness (float gustiness) |
Sets gustiness. | |
float | gustiness () const |
Returns gustiness. | |
void | setSurfaces (SurfaceList const &bpl) |
Sets the list of surface. | |
SurfaceList const & | surfaces () const |
Returns the list of surface. | |
void | setClippers (ClipperList const &cpl) |
Sets the list of clip planes. | |
ClipperList const & | clippers () const |
Returns the list of clip planes. | |
void | update (float dt) |
Updates the environment. More... | |
glm::vec3 | terminalVelocity () const |
Returns the terminal velocity. | |
glm::vec3 | terminalDistance () const |
Returns the distance traveled by a particle at terminal velocity during the last update. | |
float | ect1 () const |
Returns the value 1.0f - exp( -airFriction_ * dt ) calculated during the last update. | |
An external (to any particle or emitter) set of factors that affect a particle's position and velocity.
An environment contains the following factors. All factors are optional.
- gravity: Particles will accelerate according to the gravity acceleration vector. - air friction: Particles will decelerate in the direction of motion according to the air friction value. This value is used to compute a terminal velocity, specifically wind velocity plus sqrt(gravity/airFriction). It represents a combination of the mass of the particle, the drag coefficient, the density of the air, and the projected area of the particle. - wind: Particles can be affected by a wind that consists of a constant speed and direction modified randomly according to the gustiness factor. Gustiness is a constant acceleration applied to the wind velocity in a random direction.
|
explicit |
Constructor.
gravity | Acceleration due to gravity (default: { 0.0f, 0.0f, 0.0f }) |
friction | Deceleration due to air friction as a fraction of gravity (default: 0.0f) |
windVelocity | Prevalent wind velocity (default: { 0.0f, 0.0f, 0.0f }) |
gustiness | Gust acceleration value (default: 0.0f) |
bpl | List of surfaces (default: SurfaceList()) |
cpl | List of clip planes (default: ClipperList()) |
void Confetti::Environment::update | ( | float | dt | ) |
Updates the environment.
dt | Amount of time (in seconds) passed since the last update. |