Struct three_d::renderer::geometry::ParticleSystem
source · pub struct ParticleSystem {
pub acceleration: Vec3,
pub time: f32,
/* 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::time variable is updated every frame.
Fields§
§acceleration: Vec3The acceleration applied to all particles defined in the world coordinate system. Default is gravity.
time: f32A time variable that should be updated each frame.
Implementations§
source§impl ParticleSystem
impl ParticleSystem
sourcepub fn new(context: &Context, particles: &Particles, cpu_mesh: &CpuMesh) -> Self
pub fn new(context: &Context, particles: &Particles, cpu_mesh: &CpuMesh) -> Self
Creates a new particle system with the given geometry and the given attributes for each particle.
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 texture_transform(&self) -> &Mat3
pub fn texture_transform(&self) -> &Mat3
Get the texture transform applied to the uv coordinates of all of the particles.
sourcepub fn set_texture_transform(&mut self, texture_transform: Mat3)
pub fn set_texture_transform(&mut self, texture_transform: Mat3)
Set the texture transform applied to the uv coordinates of all of the particles. This is applied before the texture transform for each particle.
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 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_post_material(
&self,
material: &dyn PostMaterial,
camera: &Camera,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
)
fn render_with_post_material( &self, material: &dyn PostMaterial, 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.