Struct 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: Vec3

The acceleration applied to all particles defined in the world coordinate system.

Implementations§

Source§

impl ParticleSystem

Source

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.

Source

pub fn transformation(&self) -> Mat4

Returns local to world transformation applied to the particle geometry before its position is updated as described in ParticleSystem.

Source

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.

Source

pub fn set_particles(&mut self, particles: &Particles)

Set the particles attributes.

Trait Implementations§

Source§

impl Geometry for ParticleSystem

Source§

fn id(&self) -> GeometryId

Returns a unique ID for each variation of the shader source returned from Geometry::vertex_shader_source. Read more
Source§

fn vertex_shader_source(&self) -> String

Returns the vertex shader source for this geometry given that the fragment shader needs the given vertex attributes.
Source§

fn draw( &self, viewer: &dyn Viewer, program: &Program, render_states: RenderStates, )

Draw this geometry.
Source§

fn aabb(&self) -> AxisAlignedBoundingBox

Returns the AxisAlignedBoundingBox for this geometry in the global coordinate system.
Source§

fn render_with_material( &self, material: &dyn Material, viewer: &dyn Viewer, lights: &[&dyn Light], )

Render the geometry with the given Material. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the 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<'_>>, )

Render the geometry with the given Effect. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the material does not require lights to be rendered.
Source§

fn animate(&mut self, time: f32)

For updating the animation of this geometry if it is animated, if not, this method does nothing. The time parameter should be some continious time, for example the time since start.
Source§

impl<'a> IntoIterator for &'a ParticleSystem

Source§

type Item = &'a dyn Geometry

The type of the elements being iterated over.
Source§

type IntoIter = Once<&'a dyn Geometry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,