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

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

§time: f32

A time variable that should be updated each frame.

Implementations§

source§

impl ParticleSystem

source

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.

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 texture_transform(&self) -> &Mat3

Get the texture transform applied to the uv coordinates of all of the particles.

source

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.

source

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

Set the particles attributes.

Trait Implementations§

source§

impl Geometry for ParticleSystem

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, camera: &Camera, 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_post_material( &self, material: &dyn PostMaterial, camera: &Camera, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> )

Render the geometry with the given PostMaterial. 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§

impl<'a> IntoIterator for &'a ParticleSystem

§

type Item = &'a (dyn Geometry + 'a)

The type of the elements being iterated over.
§

type IntoIter = Once<&'a (dyn Geometry + 'a)>

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more