diff --git a/README.md b/README.md index 9f01cec..f5777a3 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ This list may be changed or extended in the future. - [x] Sphere intersection test - [x] Sphere normal generation - [x] Color mapping on spheres +- [ ] Plane objects + - [ ] Plane struct + - [ ] Plane intersection test + - [ ] Color mapping on planes - [ ] Triangle objects - [ ] Triangle struct - [ ] Triangle intersection test @@ -36,4 +40,3 @@ This list may be changed or extended in the future. - [ ] Transparency - [ ] Simple transparency - [ ] Refraction - diff --git a/src/object/plane.rs b/src/object/plane.rs new file mode 100644 index 0000000..59ffae2 --- /dev/null +++ b/src/object/plane.rs @@ -0,0 +1,38 @@ +extern crate nalgebra as na; + +use na::*; +use na::geometry::Point3; + +use crate::types::*; + +pub struct Plane { + pub center: Point3, + pub normal: Unit>, + + pub texture: Box Color> +} + +impl Plane { + pub fn new(center: Point3, normal: Vector3, texture: F) -> Self + where F: Fn(f32, f32) -> Color + { + Plane { + center: center, + normal: Unit::new_normalize(normal), + texture: Box::new(texture) + } + } + + pub fn new_solid(center: Point3, normal: Vector3, color: Color) -> Self + { Plane::new(center, normal, move |_, _| color) } + + pub fn intersect(&self, ray: Ray) -> Option { + unimplemented!() + } + + pub fn getcolor(&self, point: Point3) -> Color { + unimplemented!() + } + + pub fn normal(&self, point: Point3) -> Unit> { self.normal } +} diff --git a/src/object/sphere.rs b/src/object/sphere.rs index ded1b75..42e19fe 100644 --- a/src/object/sphere.rs +++ b/src/object/sphere.rs @@ -25,7 +25,8 @@ impl Sphere { } } - pub fn new_solid(x: f32, y: f32, z: f32, radius: f32, color: Color) -> Self { Sphere::new(x, y, z, radius, Box::new(move |_, _| color)) } + pub fn new_solid(x: f32, y: f32, z: f32, radius: f32, color: Color) -> Self + { Sphere::new(x, y, z, radius, move |_, _| color) } // Determines if a ray intersects the circle. // If so, returns the distance to the intersection point.