From c1d1ef054966f3c1d953f05f94a9bfa389392b96 Mon Sep 17 00:00:00 2001 From: scott-c Date: Tue, 14 Jul 2020 23:08:05 +0800 Subject: [PATCH] allow for col particles --- common/src/comp/inventory/item/tool.rs | 1 + common/src/comp/visual.rs | 26 +++++++++++++++++++------- voxygen/src/scene/particle.rs | 7 ++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index e86dc1a34b..86746daf2f 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -289,6 +289,7 @@ impl Tool { ), initial_scale: (0.1, 0.3), initial_velocity: (vek::Vec3::zero(), vek::Vec3::one()), + initial_col: (vek::Rgb::zero(), vek::Rgb::one()), }], projectile_gravity: None, }, diff --git a/common/src/comp/visual.rs b/common/src/comp/visual.rs index fd3904dc0a..0159c2945e 100644 --- a/common/src/comp/visual.rs +++ b/common/src/comp/visual.rs @@ -56,7 +56,20 @@ pub enum ParticleEmitterMode { pub struct ParticleEmitters(pub Vec); impl Default for ParticleEmitters { - fn default() -> Self { Self(vec![ParticleEmitter::default()]) } + fn default() -> Self { + Self(vec![ParticleEmitter::default(), ParticleEmitter { + mode: ParticleEmitterMode::Sprinkler, + // model_key: "voxygen.voxel.not_found", + count: (7, 10), + frequency: Duration::from_millis(100), + initial_lifespan: Duration::from_secs(500), + initial_offset: (Vec3::broadcast(-0.2), Vec3::broadcast(0.2)), + initial_orientation: (Vec3::broadcast(0.0), Vec3::broadcast(1.0)), + initial_scale: (1.0, 2.0), + initial_velocity: (Vec3::new(0.0, 0.0, 1.0), Vec3::new(0.01, 0.01, 3.0)), + initial_col: (Rgb::new(0.999, 0.0, 0.0), Rgb::new(1.0, 1.0, 0.001)), + }]) + } } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -75,6 +88,7 @@ pub struct ParticleEmitter { pub initial_scale: (f32, f32), // fn() -> Vec3, pub initial_orientation: (Vec3, Vec3), // fn() -> Vec3, pub initial_velocity: (Vec3, Vec3), // fn() -> Vec3, + pub initial_col: (Rgb, Rgb), // fn() -> Vec3, } impl Default for ParticleEmitter { @@ -85,13 +99,11 @@ impl Default for ParticleEmitter { count: (2, 5), frequency: Duration::from_millis(100), initial_lifespan: Duration::from_secs(20), - initial_offset: (vek::Vec3::broadcast(-0.1), vek::Vec3::broadcast(0.1)), - initial_orientation: (vek::Vec3::broadcast(0.0), vek::Vec3::broadcast(1.0)), + initial_offset: (Vec3::broadcast(-0.1), Vec3::broadcast(0.1)), + initial_orientation: (Vec3::broadcast(0.0), Vec3::broadcast(1.0)), initial_scale: (0.1, 2.0), - initial_velocity: ( - vek::Vec3::new(0.0, 0.0, 0.2), - vek::Vec3::new(0.01, 0.01, 1.0), - ), + initial_velocity: (Vec3::new(0.0, 0.0, 0.2), Vec3::new(0.01, 0.01, 1.0)), + initial_col: (Rgb::new(0.999, 0.999, 0.999), Rgb::new(1.0, 1.0, 1.0)), } } } diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 3ed56be91a..96af3493a7 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -197,6 +197,7 @@ impl ParticleMgr { Vec3::new(1.0, 0.0, 0.0), Vec3::new(10.0, 0.01, 0.01), /* TODO: cone // melee_data.max_angle */ ), + initial_col: (Rgb::zero(), Rgb::one()), }; let cpu_insts = @@ -272,7 +273,11 @@ fn into_particle_instances( rng.gen_range(particle_emitter.initial_offset.0.z, particle_emitter.initial_offset.1.z), ), ), - Rgb::broadcast(1.0), // instance color + Rgb::new( + rng.gen_range(particle_emitter.initial_col.0.r, particle_emitter.initial_col.1.r), + rng.gen_range(particle_emitter.initial_col.0.g, particle_emitter.initial_col.1.g), + rng.gen_range(particle_emitter.initial_col.0.b, particle_emitter.initial_col.1.b), + ), // instance color vel2 // relative + Vec3::new( rng.gen_range(particle_emitter.initial_velocity.0.x, particle_emitter.initial_velocity.1.x),