From 38c836d6c591b794e283e29dcb349ea740ceb529 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 11:50:48 +0100 Subject: [PATCH] Simpler cliffs, camera tilt --- voxygen/src/scene/camera.rs | 5 +++++ voxygen/src/scene/mod.rs | 4 +++- world/src/block/mod.rs | 31 +++++++++++++++++++++---------- world/src/block/tree.rs | 6 +++--- world/src/column/mod.rs | 8 +++++--- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/voxygen/src/scene/camera.rs b/voxygen/src/scene/camera.rs index 1f220e3639..40d5193a1e 100644 --- a/voxygen/src/scene/camera.rs +++ b/voxygen/src/scene/camera.rs @@ -106,6 +106,11 @@ impl Camera { self.tgt_dist = (self.tgt_dist + delta).max(0.0); } + /// Get the distance of the camera from the target + pub fn get_distance(&self) -> f32 { + self.tgt_dist + } + /// Set the distance of the camera from the target (i.e., zoom). pub fn set_distance(&mut self, dist: f32) { self.tgt_dist = dist; diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index f6f0980b06..c27f38ba1a 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -115,7 +115,9 @@ impl Scene { .map_or(Vec3::zero(), |pos| pos.0); // Alter camera position to match player. - self.camera.set_focus_pos(player_pos + Vec3::unit_z() * 2.1); + let tilt = self.camera.get_orientation().y; + let dist = self.camera.get_distance(); + self.camera.set_focus_pos(player_pos + Vec3::unit_z() * (2.1 - tilt.min(0.0) * dist * 0.5)); // Tick camera for interpolation. self.camera.update(client.state().get_time()); diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 7c3b531206..3d5f3c07e1 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -66,19 +66,25 @@ impl<'a> Sampler for BlockGen<'a> { .mul((chaos - 0.1).max(0.0)) .mul(90.0); - let cliff = (self.world.sim() - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(150.0, 150.0, 150.0))).into_array()) - as f32) - //.add(0.6) - .mul(130.0); + let cliff = (0.0 + + (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(350.0, 350.0, 800.0))).into_array()) + as f32) * 0.8 + + (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(100.0, 100.0, 100.0))).into_array()) + as f32) * 0.2) + .add(0.6) + .mul(64.0); let is_cliff = (self.world.sim() .gen_ctx .warp_nz - .get((wposf.div(Vec3::new(100.0, 100.0, 100.0))).into_array()) - as f32) > 0.0;//4; + .get((wposf.div(Vec3::new(300.0, 300.0, 800.0))).into_array()) + as f32) > 0.25;//4; let height = alt + warp + if is_cliff { cliff } else { 0.0 }; @@ -86,6 +92,7 @@ impl<'a> Sampler for BlockGen<'a> { let air = Block::empty(); let stone = Block::new(2, Rgb::new(200, 220, 255)); + let surface_stone = Block::new(1, Rgb::new(200, 220, 255)); let dirt = Block::new(1, Rgb::new(128, 90, 0)); let sand = Block::new(1, Rgb::new(180, 150, 50)); let water = Block::new(1, Rgb::new(100, 150, 255)); @@ -93,7 +100,11 @@ impl<'a> Sampler for BlockGen<'a> { let block = if (wposf.z as f32) < height - 4.0 { // Underground - Some(stone) + if (wposf.z as f32) > alt { + Some(surface_stone) + } else { + Some(stone) + } } else if (wposf.z as f32) < height { // Surface Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index ee6dfb3015..b3f61b4ee5 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use vek::*; lazy_static! { - pub static ref TREES: [Arc; 61] = [ + pub static ref TREES: [Arc; 9] = [ // green oaks assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 18, 14))) @@ -34,7 +34,7 @@ lazy_static! { .with_center(Vec3::new(26, 26, 14))) .unwrap(), // green pines - assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s + /*assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) .unwrap(), assets::load_map("world/tree/pine_green/2.vox", |s: Structure| s @@ -196,7 +196,7 @@ lazy_static! { .with_center(Vec3::new(7, 7, 10))) .unwrap(), // palm trees - /*assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s + assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s .with_center(Vec3::new(12, 12, 10))) .unwrap(), assets::load_map("world/tree/desert_palm/2.vox", |s: Structure| s diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 78146357da..48a5e815e9 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -45,13 +45,15 @@ impl<'a> Sampler for ColumnGen<'a> { let rock = (sim.gen_ctx.small_nz.get(Vec3::new(wposf.x, wposf.y, alt as f64).div(100.0).into_array()) as f32) .mul(rockiness) - .sub(0.35) + .sub(0.4) .max(0.0) - .mul(6.0); + .mul(8.0); let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); - let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) + let marble = (0.0 + + (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32).mul(0.75) + + (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32).mul(0.5)) .add(1.0) .mul(0.5);