pub struct ParticleSystem {
pub acceleration: Vec3,
/* private fields */
}
Expand description
Particle system that can be used to simulate effects such as fireworks, fire, smoke or water particles.
All particles are initialised with Particles::start_positions and Particles::start_velocities and a global ParticleSystem::acceleration. Then, when time passes, their position is updated based on
new_position = start_position + start_velocity * time + 0.5 * acceleration * time * time
The particles will only move if the ParticleSystem::animate is called every frame.
Fields§
§acceleration: Vec3
The acceleration applied to all particles defined in the world coordinate system.
Implementations§
Source§impl ParticleSystem
impl ParticleSystem
Sourcepub fn new(
context: &Context,
particles: &Particles,
acceleration: Vec3,
cpu_mesh: &CpuMesh,
) -> Self
pub fn new( context: &Context, particles: &Particles, acceleration: Vec3, cpu_mesh: &CpuMesh, ) -> Self
Creates a new particle system with the given geometry and the given attributes for each particle. The acceleration is applied to all particles defined in the world coordinate system.
Sourcepub fn transformation(&self) -> Mat4
pub fn transformation(&self) -> Mat4
Returns local to world transformation applied to the particle geometry before its position is updated as described in ParticleSystem.
Sourcepub fn set_transformation(&mut self, transformation: Mat4)
pub fn set_transformation(&mut self, transformation: Mat4)
Set the local to world transformation applied to the particle geometry before its position is updated as described in ParticleSystem.
Sourcepub fn set_particles(&mut self, particles: &Particles)
pub fn set_particles(&mut self, particles: &Particles)
Set the particles attributes.
Trait Implementations§
Source§impl Geometry for ParticleSystem
impl Geometry for ParticleSystem
Source§fn id(&self) -> GeometryId
fn id(&self) -> GeometryId
Geometry::vertex_shader_source
. Read moreSource§fn vertex_shader_source(&self) -> String
fn vertex_shader_source(&self) -> String
Source§fn draw(
&self,
viewer: &dyn Viewer,
program: &Program,
render_states: RenderStates,
)
fn draw( &self, viewer: &dyn Viewer, program: &Program, render_states: RenderStates, )
Source§fn aabb(&self) -> AxisAlignedBoundingBox
fn aabb(&self) -> AxisAlignedBoundingBox
Source§fn render_with_material(
&self,
material: &dyn Material,
viewer: &dyn Viewer,
lights: &[&dyn Light],
)
fn render_with_material( &self, material: &dyn Material, viewer: &dyn Viewer, lights: &[&dyn Light], )
lights
argument, if the material does not require lights to be rendered.Source§fn render_with_effect(
&self,
material: &dyn Effect,
viewer: &dyn Viewer,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>,
)
fn render_with_effect( &self, material: &dyn Effect, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )
lights
argument, if the material does not require lights to be rendered.