Struct three_d::renderer::geometry::ParticleSystem
source · 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: Vec3The 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, required_attributes: FragmentAttributes) -> u16
fn id(&self, required_attributes: FragmentAttributes) -> u16
Geometry::vertex_shader_source. Read moresource§fn vertex_shader_source(
&self,
required_attributes: FragmentAttributes
) -> String
fn vertex_shader_source( &self, required_attributes: FragmentAttributes ) -> String
source§fn draw(
&self,
camera: &Camera,
program: &Program,
render_states: RenderStates,
attributes: FragmentAttributes
)
fn draw( &self, camera: &Camera, program: &Program, render_states: RenderStates, attributes: FragmentAttributes )
source§fn aabb(&self) -> AxisAlignedBoundingBox
fn aabb(&self) -> AxisAlignedBoundingBox
source§fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
)
fn render_with_material( &self, material: &dyn Material, camera: &Camera, lights: &[&dyn Light] )
lights argument, if the material does not require lights to be rendered.source§fn render_with_effect(
&self,
material: &dyn Effect,
camera: &Camera,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
)
fn render_with_effect( &self, material: &dyn Effect, camera: &Camera, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> )
lights argument, if the material does not require lights to be rendered.