| 
2
 | 
     1  | 
 * kd-tree
  | 
| 
3
 | 
     2  | 
  | 
| 
 | 
     3  | 
  | 
| 
 | 
     4  | 
container.h  -- Container
  | 
| 
 | 
     5  | 
kdtree.h  -- KdTree
  | 
| 
 | 
     6  | 
shapes.h  -- Triangle, Sphere
  | 
| 
 | 
     7  | 
scene.h   -- Ray, Light, Camera, Scene
  | 
| 
 | 
     8  | 
material.h -- Material, Texture
  | 
| 
 | 
     9  | 
matrix.h  -- Matrix
  | 
| 
 | 
    10  | 
vector.h  -- Vector3
  | 
| 
 | 
    11  | 
reader.h  -- Reader, WavefrontReader
  | 
| 
 | 
    12  | 
  | 
| 
 | 
    13  | 
KdTree monkey
  | 
| 
 | 
    14  | 
wf = new WavefrontReader()
  | 
| 
 | 
    15  | 
wf.setContainer(monkey)
  | 
| 
 | 
    16  | 
wf.read("monkey.obj")
 | 
| 
 | 
    17  | 
destroy wf
  | 
| 
 | 
    18  | 
  | 
| 
 | 
    19  | 
monkey.optimize()  -- i.e. build tree
  | 
| 
 | 
    20  | 
  | 
| 
 | 
    21  | 
Scene scene -- container with shapes, a camera and lights
  | 
| 
 | 
    22  | 
scene = new Scene()
  | 
| 
 | 
    23  | 
scene.setTop(monkey) -- top object in hierarchy
  | 
| 
 | 
    24  | 
scene.setCamera(new Camera(pos, dir, angle))
  | 
| 
 | 
    25  | 
scene.addLight(new PointLight(pos, color))
  | 
| 
 | 
    26  | 
rt.setScene(scene)
  | 
| 
 | 
    27  | 
rt.render(w,h)
  | 
| 
 | 
    28  | 
  | 
| 
 | 
    29  | 
  | 
| 
 | 
    30  | 
constructors have zero or one parameter by default -- the object to copy data from
  | 
| 
 | 
    31  | 
more parameters -- the data (ray origin and direction)
  |