25 }; |
25 }; |
26 //static void *renderrow(void *data); |
26 //static void *renderrow(void *data); |
27 |
27 |
28 class Raytracer |
28 class Raytracer |
29 { |
29 { |
30 ShapeList shapes; |
30 Container *top; |
31 vector<Light*> lights; |
31 vector<Light*> lights; |
32 Colour bg_colour; |
32 Colour bg_colour; |
33 int ao_samples; |
33 int ao_samples; |
34 float ao_distance, ao_angle; |
34 float ao_distance, ao_angle; |
35 |
35 |
36 Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal); |
36 Vector3 SphereDistribute(int i, int n, float extent, Vector3 &normal); |
37 inline Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray, |
37 inline Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray, |
38 float &nearest_distance); |
38 float &nearest_distance); |
39 public: |
39 public: |
40 Raytracer(): shapes(), lights(), bg_colour(0.0, 0.0, 0.0), ao_samples(0) {}; |
40 Raytracer(): lights(), bg_colour(0.0, 0.0, 0.0), ao_samples(0) { top = new KdTree(); }; |
41 ~Raytracer() {}; |
41 ~Raytracer() {}; |
42 float *render(int w, int h); |
42 float *render(int w, int h); |
43 Colour raytrace(Ray &ray, int depth, Shape *origin_shape); |
43 Colour raytrace(Ray &ray, int depth, Shape *origin_shape); |
44 void addshape(Shape *shape); |
44 void addshape(Shape *shape) { top->addShape(shape); }; |
45 void addlight(Light *light); |
45 void addlight(Light *light); |
46 |
46 |
47 void ambientocclusion(int samples, float distance, float angle); |
47 void ambientocclusion(int samples, float distance, float angle); |
48 }; |
48 }; |
49 |
49 |