Skip to content

Commit

Permalink
finish chapter seven
Browse files Browse the repository at this point in the history
  • Loading branch information
pcasaretto committed Mar 25, 2024
1 parent 6052af1 commit 21f02bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/color.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ops::{Add, Mul, Sub};

#[derive(Debug, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Color {
pub red: f64,
pub green: f64,
Expand Down
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ fn main() {
.rotation_x(PI / 2.0)
.rotation_y(-PI / 4.0)
.translation(0.0, 0.0, 5.0);
left_wall.material = floor_material;

let mut right_wall = ray::Sphere::init();
right_wall.transform = matrix::Matrix::identity(4)
.scaling(10.0, 0.01, 10.0)
.rotation_x(PI / 2.0)
.rotation_y(PI / 4.0)
.translation(0.0, 0.0, 5.0);
right_wall.material = floor_material;

let mut middle = ray::Sphere::init();
middle.transform = matrix::Matrix::identity(4).translation(-0.5, 1.0, 0.5);
Expand All @@ -48,7 +50,7 @@ fn main() {
let mut left = ray::Sphere::init();
left.transform = matrix::Matrix::identity(4)
.scaling(0.33, 0.33, 0.33)
.translation(1.5, 0.33, -0.75);
.translation(-1.5, 0.33, -0.75);
let mut left_material = material::Material::default();
left_material.color = color::Color::new(1.0, 0.8, 0.1);
left_material.diffuse = 0.7;
Expand All @@ -64,8 +66,14 @@ fn main() {
},
position: point!(-10, 10, -10),
});
world.objects.push(floor);
world.objects.push(left_wall);
world.objects.push(right_wall);
world.objects.push(middle);
world.objects.push(right);
world.objects.push(left);

let mut camera = camera::Camera::new(100, 50, FRAC_PI_3);
let mut camera = camera::Camera::new(500, 250, FRAC_PI_3);
camera.transform =
matrix::view_transform(point!(0, 1.5, -5), point!(0, 1, 0), vector!(0, 1, 0));

Expand Down
2 changes: 1 addition & 1 deletion src/material.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::color::*;

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Material {
pub color: Color,
pub ambient: f64,
Expand Down

0 comments on commit 21f02bb

Please # to comment.