use super::*;
use crate::{ Mat3, Point };
use crate::tracer::Color;
impl Scene {
const LIGHT_EPS: crate::Float = 0.01;
pub fn empty_box(
def_color: Color,
mat_left: Material,
mat_right: Material,
) -> Self {
let ground = -0.8;
let ceiling = -ground;
let right = 1.0;
let left = -right;
let front = -2.0;
let back = 0.0;
let l_dim = 0.1;
let mut scene = Self::default();
scene.add_light(Rectangle::new(
Mat3::from_cols(
Point::new(-l_dim, ceiling - Self::LIGHT_EPS, 0.6 * front + l_dim),
Point::new(-l_dim, ceiling - Self::LIGHT_EPS, 0.6 * front - l_dim),
Point::new(l_dim, ceiling - Self::LIGHT_EPS, 0.6 * front - l_dim),
),
Material::Light(Texture::Solid(20.0 * Color::WHITE))
));
scene.add(Rectangle::new(
Mat3::from_cols(
Point::new(left, ground, back),
Point::new(left, ground, front),
Point::new(left, ceiling, front),
),
mat_left,
));
scene.add(Rectangle::new(
Mat3::from_cols(
Point::new(right, ground, front),
Point::new(right, ground, back),
Point::new(right, ceiling, back),
),
mat_right,
));
scene.add(Rectangle::new(
Mat3::from_cols(
Point::new(left, ground, back),
Point::new(right, ground, back),
Point::new(right, ground, front),
),
Material::diffuse(Texture::Solid(def_color)),
));
scene.add(Rectangle::new(
Mat3::from_cols(
Point::new(left, ceiling, front),
Point::new(right, ceiling, front),
Point::new(right, ceiling, back),
),
Material::diffuse(Texture::Solid(def_color)),
));
scene.add(Rectangle::new(
Mat3::from_cols(
Point::new(left, ground, front),
Point::new(right, ground, front),
Point::new(right, ceiling, front),
),
Material::diffuse(Texture::Solid(def_color)),
));
scene
}
}