Difficulty |
3 |
Reading material |
def scene_at(now)
{
var camera = Cameras.perspective( [ "eye": pos(0,0,10),
"look_at": pos(0,0,0) ] )
var material = Materials.uniform( [ "ambient": Colors.white() * 0.1,
"diffuse": Colors.white() * 0.8,
"specular": Colors.white(),
"specular_exponent": 100,
"reflectivity": 0,
"transparency": 0,
"refractive_index": 0 ] )
var angle = Animations.animate(degrees(0), degrees(360), seconds(5))[now]
var csg1 = translate(vec(0,3,0), csg_union( [ translate(vec(0,0,-0.5), sphere()), translate(vec(0,0,0.5), sphere()) ] ))
var csg2 = csg_intersection( translate(vec(0,0,-0.5), sphere()), translate(vec(0,0,0.5), sphere()) )
var csg3 = translate(vec(0,-3,0), csg_difference( translate(vec(0,0,-0.5), sphere()), translate(vec(0,0,0.5), sphere()) ))
var root = decorate(material, union([
rotate_around_y(angle, csg1),
rotate_around_y(angle, csg2),
rotate_around_y(angle, csg3)
]))
var lights = [ Lights.omnidirectional( pos(0,0,5), Colors.white() ) ]
create_scene(camera, root, lights)
}
var raytracer = Raytracers.v6()
var renderer = Renderers.standard( [ "width": 500,
"height": 500,
"sampler": Samplers.multijittered(2),
"ray_tracer": raytracer ] )
pipeline( scene_animation(scene_at, seconds(5)),
[ Pipeline.animation(30),
Pipeline.renderer(renderer),
Pipeline.studio() ] )
Shapes can be constructed by combining simpler shapes in different ways:
Union |
|
Difference |
|
Intersection |
The code for union is already given. Use it as a template to define the two other operations. Note however that while the union operation is defined as taking a list of children, intersection and difference can limit themselves to exactly two children.
1. Intersection
|
2. Difference
|
3. Evaluation
TODO