parent
fcde73c1ef
commit
3cb4dcb330
After Width: | Height: | Size: 722 KiB |
@ -0,0 +1,42 @@ |
||||
local mirror = obj.withmaterial( |
||||
obj.negation( |
||||
obj.sphere(vec3.O, 8) |
||||
), |
||||
material.newfromdiagonal( |
||||
colorvec.new(0, 0, 0, 0), |
||||
colorvec.new(1, 1, 1, 1), |
||||
surfacetype.REFLECTIVE |
||||
) |
||||
) |
||||
|
||||
local objects = { |
||||
obj.withmaterial( |
||||
obj.torus(vec3.new(1, 0, -3), 2, 1), |
||||
material.newfromdiagonal( |
||||
colorvec.new(1, .5, .2, 0), |
||||
colorvec.new(1, 1, 1, 1), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
), |
||||
obj.withmaterial( |
||||
obj.sphere(vec3.new(3, 2, 0), 1), |
||||
material.newfromdiagonal( |
||||
colorvec.new(0, 0, 0, 0), |
||||
colorvec.new(.2, .5, 1, 0), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
), |
||||
obj.withmaterial( |
||||
obj.cuboid(vec3.new(-3, -1, 2), vec3.new(1, 1, 1)), |
||||
material.newfromdiagonal( |
||||
colorvec.new(0, 0, 0, 0), |
||||
colorvec.new(.2, 1, .5, 0), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
) |
||||
} |
||||
|
||||
return obj.union( |
||||
util.union(objects), |
||||
mirror |
||||
) |
@ -0,0 +1,33 @@ |
||||
use crate::object::Obj; |
||||
use crate::structs::Vec3; |
||||
use crate::material::Material; |
||||
use crate::light::Light; |
||||
|
||||
#[derive(Debug, Clone, PartialEq)] |
||||
pub struct Negation<T: Obj> { |
||||
obj: T |
||||
} |
||||
|
||||
impl<T: Obj> Negation<T> { |
||||
pub fn new(obj: T) -> Negation<T> { |
||||
Negation { obj } |
||||
} |
||||
} |
||||
|
||||
impl<T: Obj> Obj for Negation<T> { |
||||
fn distance_to(&self, point: Vec3) -> f64 { |
||||
-self.obj.distance_to(point) |
||||
} |
||||
fn normal_at(&self, point: Vec3) -> Vec3 { |
||||
-self.obj.normal_at(point) |
||||
} |
||||
fn material_at(&self, point: Vec3) -> Material { |
||||
self.obj.material_at(point) |
||||
} |
||||
fn get_lights(&self) -> Vec<Light> { |
||||
self.obj.get_lights() |
||||
} |
||||
fn node_count(&self) -> u32 { |
||||
self.obj.node_count() + 1 |
||||
} |
||||
} |
Loading…
Reference in new issue