CUGL 3.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cugl::graphics::Particle3 Class Reference

#include <CUParticleSystem.h>

Public Member Functions

 Particle3 ()
 

Public Attributes

Vec3 position
 
Vec3 velocity
 
Color4 color
 
float size
 
float life
 
float distance
 
float delay
 
void * userdata
 

Detailed Description

This class is the class representing a particle in a simulation.

Ideally, we would have allowed users to define their own particle classes, and templatized ParticleSystem. However, this creates a lot of design issues. Templating has issues with proliferation (e.g. forcing any general purpose class that uses a particle system to be templated as well). The alternative is to use subclassing to limit the template to the method and not the entire class. But this causes issues with allocation and heap fragmentation (because the particle system would need to be a pointer of pointers).

The solution used by this class is delegation. This class is essentially a struct with no methods of its own. It has several base attributes, but also includes a void pointer for user-defined data.

The user manipulates these particles with three function pointers passed to ParticleSystem: ParticleAllocator, ParticleDeallocator, and ParticleUpdater. See the descriptions for these function types. Both ParticleAllocator and ParticleUpdater are required. ParticleDeallocator is only required if ParticleAllocator modifies the userdata attribute of this class.

Constructor & Destructor Documentation

◆ Particle3()

cugl::graphics::Particle3::Particle3 ( )
inline

Creates an default particle.

This particle is uninitialized and unused. The particle system will initialize it before use.

Member Data Documentation

◆ color

Color4 cugl::graphics::Particle3::color

The particle color

◆ delay

float cugl::graphics::Particle3::delay

The delay in seconds until this particle is emitted

◆ distance

float cugl::graphics::Particle3::distance

The squared distance to the camera. If dead, this value is -1.0f

◆ life

float cugl::graphics::Particle3::life

The remaining life of the particle. If <0 this particle is dead and unused.

◆ position

Vec3 cugl::graphics::Particle3::position

The particle position

◆ size

float cugl::graphics::Particle3::size

The particle size (scale to apply to template)

◆ userdata

void* cugl::graphics::Particle3::userdata

Optional user-data for more complex simulations.

This value can be allocated by ParticleAllocator. But if that happens, the ParticleDeallocator should clean up afterwards to prevent any memory leaks.

◆ velocity

Vec3 cugl::graphics::Particle3::velocity

The particle velocity


The documentation for this class was generated from the following file: