VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
ParticleEmitterComponent.hpp
Go to the documentation of this file.
1
6
7#pragma once
8#include "components/AssetTypes.hpp"
9#include "components/ColorTypes.hpp"
10#include <glm/vec2.hpp>
11#include <glm/vec3.hpp>
12#include <vector>
13
14namespace vex {
15
17 struct alignas(16) ParticleGPUData {
18 glm::vec4 position;
19 float scaleX;
20 float scaleY;
21 uint32_t textureID;
22 uint32_t isUnlit;
23 glm::vec4 color;
24 };
25
26
27
29 struct Particle {
30 glm::vec3 position = glm::vec3(0.0f);
31 glm::vec3 velocity = glm::vec3(0.0f);
32 vex::rgba color = vex::rgba(1.0f, 1.0f, 1.0f, 1.0f);
33 vex::rgba startColor = vex::rgba(1.0f, 1.0f, 1.0f, 1.0f);
34 vex::rgba endColor = vex::rgba(1.0f, 1.0f, 1.0f, 0.0f);
35 float startSize = 1.0f;
36 float endSize = 0.0f;
37 float life = 0.0f;
38 float startingLife = 1.0f;
39 };
40
44 bool isTransparent = true;
45 bool isUnlit = true;
46 bool active = true;
47 float spawnRate = 0.1f;
48 float spawnTimer = 0.0f;
49 glm::vec3 gravity = glm::vec3(0.0f, -9.81f, 0.0f);
50 glm::vec3 initialVelocity = glm::vec3(0.0f, 5.0f, 0.0f);
51 glm::vec3 velocityVariation = glm::vec3(2.0f, 2.0f, 2.0f);
52 float particleLife = 3.0f;
53 float particleLifeVariation = 0.5f;
54 float startSize = 1.0f;
55 float endSize = 0.0f;
56 vex::rgba startColor = vex::rgba(1.0f, 1.0f, 1.0f, 1.0f);
57 vex::rgba endColor = vex::rgba(1.0f, 1.0f, 1.0f, 0.0f);
58 std::vector<Particle> cpuParticles;
59 std::vector<ParticleGPUData> activeParticles;
60 };
61
62}
Component that emits and manages a system of particles.
vex::texture_asset_path texturePath
Path to the texture applied to particles.
bool active
Indicates if the emitter is active and emitting particles.
vex::rgba startColor
Color of particles at spawn.
float particleLifeVariation
Random variation range applied to lifetime.
float particleLife
Base lifetime for new particles.
glm::vec3 velocityVariation
Random variation range applied to initial velocity.
std::vector< ParticleGPUData > activeParticles
GPU data buffer built every frame for rendering.
float spawnTimer
Internal timer to track time since last spawn.
float startSize
Base size for new particles.
bool isTransparent
Indicates if the particles should be rendered in the transparent pass.
std::vector< Particle > cpuParticles
Internal list of active CPU particles.
vex::rgba endColor
Color of particles at the end of their life.
bool isUnlit
Indicates if the particles should ignore lighting.
float endSize
Size of particles at the end of their life.
glm::vec3 initialVelocity
Base starting velocity for new particles.
glm::vec3 gravity
Gravity applied to particles.
float spawnRate
Time in seconds between particle spawns.
Structure passed to the GPU containing per-particle rendering data.
uint32_t textureID
Bindless texture index.
uint32_t isUnlit
Flag determining if the particle is unlit (1) or affected by lighting (0).
float scaleY
Particle vertical scale.
float scaleX
Particle horizontal scale.
glm::vec4 color
Particle color (rgba).
glm::vec4 position
Particle position (xyz) and unused (w).
CPU-side representation of a single particle during its lifetime.
vex::rgba startColor
Color at spawn.
vex::rgba color
Current color.
float startingLife
Total lifetime in seconds.
vex::rgba endColor
Color at end of life.
glm::vec3 velocity
Current velocity.
float startSize
Size at spawn.
float endSize
Size at end of life.
float life
Remaining lifetime in seconds.
glm::vec3 position
Current world position.
Represents an RGBA color value. Used mainly for fancy rendering in editor.
Specific wrapper for Textures.