From d999e8196bb49454fb06d4d7b6ab342162913cb5 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Wed, 21 Jul 2021 15:15:59 -0700 Subject: [PATCH] eoc9: add ceiling. --- rtchallenge/examples/eoc9.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/rtchallenge/examples/eoc9.rs b/rtchallenge/examples/eoc9.rs index 553c07e..e767a54 100644 --- a/rtchallenge/examples/eoc9.rs +++ b/rtchallenge/examples/eoc9.rs @@ -34,13 +34,13 @@ fn main() -> Result<()> { let width = 2560; let height = 1440; - let light_position = Tuple::point(-10., 10., -10.); + let light_position = Tuple::point(-5., 5., -5.); let light_color = WHITE; let light1 = PointLight::new(light_position, light_color); - let light_position = Tuple::point(10., 10., -10.); + let light_position = Tuple::point(5., 5., -5.); let light_color = Color::new(0.2, 0.2, 0.6); let light2 = PointLight::new(light_position, light_color); - let light_position = Tuple::point(0., 2., -10.); + let light_position = Tuple::point(0., 2., -5.); let light_color = Color::new(0.2, 0.2, 0.1); let light3 = PointLight::new(light_position, light_color); @@ -58,9 +58,16 @@ fn main() -> Result<()> { specular: 0., ..Material::default() }; + let mut ceiling = Shape::plane(); + ceiling.set_transform(Matrix4x4::translation(0., 6., 0.) * Matrix4x4::rotation_x(PI)); + ceiling.material = Material { + color: Color::new(0.6, 0.6, 0.8), + specular: 0.2, + ..Material::default() + }; let mut middle = Shape::sphere(); - middle.set_transform(Matrix4x4::translation(-0.5, 1., 0.5)); + middle.set_transform(Matrix4x4::translation(-0.5, 0.5, 0.5)); middle.material = Material { color: Color::new(0.1, 1., 0.5), diffuse: 0.7, @@ -90,7 +97,7 @@ fn main() -> Result<()> { let mut world = World::default(); world.lights = vec![light1, light2, light3]; - world.objects = vec![floor, middle, right, left]; + world.objects = vec![floor, ceiling, middle, right, left]; let image = camera.render(&world);