diff --git a/README.md b/README.md index ddad1ef..dbf1a2e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ I'm learning Rust while working my way through Jamis Buck's
Chapter 16: Constructive Solid Geometry -![csg](https://raw.githubusercontent.com/fremag/ray_tracer_rust/main/img/csg.png) +![csg](https://raw.githubusercontent.com/fremag/ray_tracer_rust/main/img/csg_scene.png)
diff --git a/img/csg.png b/img/csg.png deleted file mode 100644 index 59096ac..0000000 Binary files a/img/csg.png and /dev/null differ diff --git a/img/csg_scene.png b/img/csg_scene.png new file mode 100644 index 0000000..738d8d9 Binary files /dev/null and b/img/csg_scene.png differ diff --git a/ray-tracer-cli/src/main.rs b/ray-tracer-cli/src/main.rs index 4eb6762..222a8d4 100644 --- a/ray-tracer-cli/src/main.rs +++ b/ray-tracer-cli/src/main.rs @@ -30,7 +30,7 @@ fn main() { } println!("Start..."); - render(&CsgScene{},400, 400, "./img/csg.png"); + render(&CsgScene{},400, 400, "./img/csg_scene.png"); println!("Done.") } diff --git a/ray-tracer-cli/src/scenes/csg_scene.rs b/ray-tracer-cli/src/scenes/csg_scene.rs index e769968..6f71c52 100644 --- a/ray-tracer-cli/src/scenes/csg_scene.rs +++ b/ray-tracer-cli/src/scenes/csg_scene.rs @@ -1,7 +1,7 @@ use ray_tracer_lib::camera::Camera; use ray_tracer_lib::colors::Color; use ray_tracer_lib::core::math::{PI}; -use ray_tracer_lib::core::transform::{scaling, view_transform}; +use ray_tracer_lib::core::transform::{rotation_y, scaling, translation, view_transform}; use ray_tracer_lib::core::tuple::{point, vector}; use ray_tracer_lib::lights::point_light::PointLight; use ray_tracer_lib::material::Material; @@ -42,8 +42,9 @@ impl Scene for CsgScene { cube2.set_material(mat2.clone()); let csg = Csg::new(CsgOperation::Difference, cyl1, cube2); - - world.objects.push(Object::new_csg(csg)); + let mut obj_csg = Object::new_csg(csg); + obj_csg.set_transformation(&translation(0.0, 1.0, 0.0) * &rotation_y(90.0)); + world.objects.push(obj_csg); world }