Add empty cornell box with light and flipped normals.

This commit is contained in:
2018-09-23 22:00:52 -07:00
parent 73002df31e
commit f1fcbe7449
6 changed files with 153 additions and 3 deletions

30
rtiow/src/flip_normals.rs Normal file
View File

@@ -0,0 +1,30 @@
use aabb::AABB;
use hitable::Hit;
use hitable::HitRecord;
use ray::Ray;
pub struct FlipNormals {
hitable: Box<Hit>,
}
impl FlipNormals {
pub fn new(hitable: Box<Hit>) -> FlipNormals {
FlipNormals { hitable }
}
}
impl Hit for FlipNormals {
fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option<HitRecord> {
if let Some(rec) = self.hitable.hit(r, t_min, t_max) {
return Some(HitRecord {
normal: -rec.normal,
..rec
});
};
None
}
fn bounding_box(&self, t_min: f32, t_max: f32) -> Option<AABB> {
self.hitable.bounding_box(t_min, t_max)
}
}