summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRosyid Haryadi <rosyid_haryadi@protonmail.com>2025-03-03 00:15:55 +0700
committerRosyid Haryadi <rosyid_haryadi@protonmail.com>2025-03-03 00:15:55 +0700
commitab0b3f165788c5d79b2d159aeefda8c8947b68ae (patch)
treefc19c8105c401685f7668ed663050366338a2d27 /src/main.rs
parent7301f5af4fc7cb7bc13a9d559183f2f095de47d0 (diff)
refactor material
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index fa6c194..cc5d6b6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,8 +7,8 @@ mod interval;
mod material;
use crate::calculus::calculus::Point3;
-use crate::common::*;
use crate::camera::Camera;
+use crate::common::*;
use crate::material::{Material, MaterialType};
use crate::object::{HittableList, Sphere};
use crate::view::{render_viewer, View};
@@ -17,17 +17,22 @@ fn main() {
let mut display_buffer: DisplayBuffer = [[Pixel::default(); IMG_WIDTH]; IMG_HEIGHT];
let mut world = HittableList::new();
+ let ground = Material::new(Color::from_name(ColorName::Maroon), MaterialType::Diffuse);
+ let blue = Material::new(Color::new(0.1, 0.2, 0.5), MaterialType::Diffuse);
+ let steel = Material::new(Color::from_name(ColorName::Silver), MaterialType::Metal(0.1));
+ let gold = Material::new(Color::from_name(ColorName::Yellow), MaterialType::Metal(0.0));
+
world.push(
- Sphere::new(Point3::new(0.0, -100.5, -1.0), 100.0, MaterialType::Diffuse, Color::new(0.8, 0.8, 0.0), 0.0)
+ Sphere::new(Point3::new(0.0, -100.5, -1.0), 100.0, ground)
);
world.push(
- Sphere::new(Point3::new(0.0, 0.0, -1.2), 0.5, MaterialType::Diffuse, Color::new(0.1, 0.2, 0.5), 0.0)
+ Sphere::new(Point3::new(0.0, 0.0, -1.2), 0.5, blue)
);
world.push(
- Sphere::new(Point3::new(-1.0, 0.0, -1.0), 0.5, MaterialType::Metal, Color::new(0.8, 0.8, 0.8), 0.1)
+ Sphere::new(Point3::new(-1.0, 0.0, -1.0), 0.5, steel)
);
world.push(
- Sphere::new(Point3::new(1.0, 0.0, -1.0), 0.5, MaterialType::Metal, Color::new(0.8, 0.6, 0.2), 0.0)
+ Sphere::new(Point3::new(1.0, 0.0, -1.0), 0.5, gold)
);
let camera = Camera::new();