allow for col particles

This commit is contained in:
scott-c 2020-07-14 23:08:05 +08:00
parent 803677f0fb
commit 3139e85dff
3 changed files with 26 additions and 8 deletions

View File

@ -289,6 +289,7 @@ impl Tool {
), ),
initial_scale: (0.1, 0.3), initial_scale: (0.1, 0.3),
initial_velocity: (vek::Vec3::zero(), vek::Vec3::one()), initial_velocity: (vek::Vec3::zero(), vek::Vec3::one()),
initial_col: (vek::Rgb::zero(), vek::Rgb::one()),
}], }],
projectile_gravity: None, projectile_gravity: None,
}, },

View File

@ -56,7 +56,20 @@ pub enum ParticleEmitterMode {
pub struct ParticleEmitters(pub Vec<ParticleEmitter>); pub struct ParticleEmitters(pub Vec<ParticleEmitter>);
impl Default for ParticleEmitters { 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)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -75,6 +88,7 @@ pub struct ParticleEmitter {
pub initial_scale: (f32, f32), // fn() -> Vec3<f32>, pub initial_scale: (f32, f32), // fn() -> Vec3<f32>,
pub initial_orientation: (Vec3<f32>, Vec3<f32>), // fn() -> Vec3<f32>, pub initial_orientation: (Vec3<f32>, Vec3<f32>), // fn() -> Vec3<f32>,
pub initial_velocity: (Vec3<f32>, Vec3<f32>), // fn() -> Vec3<f32>, pub initial_velocity: (Vec3<f32>, Vec3<f32>), // fn() -> Vec3<f32>,
pub initial_col: (Rgb<f32>, Rgb<f32>), // fn() -> Vec3<f32>,
} }
impl Default for ParticleEmitter { impl Default for ParticleEmitter {
@ -85,13 +99,11 @@ impl Default for ParticleEmitter {
count: (2, 5), count: (2, 5),
frequency: Duration::from_millis(100), frequency: Duration::from_millis(100),
initial_lifespan: Duration::from_secs(20), initial_lifespan: Duration::from_secs(20),
initial_offset: (vek::Vec3::broadcast(-0.1), vek::Vec3::broadcast(0.1)), initial_offset: (Vec3::broadcast(-0.1), Vec3::broadcast(0.1)),
initial_orientation: (vek::Vec3::broadcast(0.0), vek::Vec3::broadcast(1.0)), initial_orientation: (Vec3::broadcast(0.0), Vec3::broadcast(1.0)),
initial_scale: (0.1, 2.0), initial_scale: (0.1, 2.0),
initial_velocity: ( initial_velocity: (Vec3::new(0.0, 0.0, 0.2), Vec3::new(0.01, 0.01, 1.0)),
vek::Vec3::new(0.0, 0.0, 0.2), initial_col: (Rgb::new(0.999, 0.999, 0.999), Rgb::new(1.0, 1.0, 1.0)),
vek::Vec3::new(0.01, 0.01, 1.0),
),
} }
} }
} }

View File

@ -197,6 +197,7 @@ impl ParticleMgr {
Vec3::new(1.0, 0.0, 0.0), Vec3::new(1.0, 0.0, 0.0),
Vec3::new(10.0, 0.01, 0.01), /* TODO: cone // melee_data.max_angle */ Vec3::new(10.0, 0.01, 0.01), /* TODO: cone // melee_data.max_angle */
), ),
initial_col: (Rgb::zero(), Rgb::one()),
}; };
let cpu_insts = 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), 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 vel2 // relative
+ Vec3::new( + Vec3::new(
rng.gen_range(particle_emitter.initial_velocity.0.x, particle_emitter.initial_velocity.1.x), rng.gen_range(particle_emitter.initial_velocity.0.x, particle_emitter.initial_velocity.1.x),