|
1 /* |
|
2 * C++ RayTracer |
|
3 * file: raytracer.h |
|
4 * |
|
5 * Radek Brich, 2006 |
|
6 */ |
|
7 |
|
8 #ifndef RAYTRACER_H |
|
9 #define RAYTRACER_H |
|
10 |
|
11 #include <vector> |
|
12 |
|
13 #include "common.h" |
|
14 #include "kdtree.h" |
|
15 #include "scene.h" |
|
16 |
|
17 using namespace std; |
|
18 |
|
19 class Raytracer; |
|
20 struct RenderrowData { |
|
21 Raytracer *rt; |
|
22 int w; |
|
23 Vector3 eye, dfix, dx, dy; |
|
24 Float *iter; |
|
25 }; |
|
26 |
|
27 class Raytracer |
|
28 { |
|
29 Container *top; |
|
30 Camera *camera; |
|
31 vector<Light*> lights; |
|
32 Colour bg_colour; |
|
33 int ao_samples; |
|
34 Float ao_distance, ao_angle; |
|
35 int num_threads; |
|
36 int subsample; |
|
37 int max_depth; |
|
38 |
|
39 Vector3 SphereDistribute(int i, int n, Float extent, Vector3 &normal); |
|
40 public: |
|
41 Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0), |
|
42 ao_samples(0), num_threads(4), subsample(8), max_depth(4) {}; |
|
43 void render(int w, int h, Float *buffer); |
|
44 Colour raytrace(Ray &ray, int depth, Shape *origin_shape); |
|
45 void addshape(Shape *shape) { top->addShape(shape); }; |
|
46 void addlight(Light *light); |
|
47 void setCamera(Camera *cam) { camera = cam; }; |
|
48 void setTop(Container *atop) { top = atop; }; |
|
49 Container *getTop() { return top; }; |
|
50 int getSubsample() { return subsample; }; |
|
51 void setMaxDepth(int newdepth) { max_depth = newdepth; }; |
|
52 |
|
53 void ambientocclusion(int samples, Float distance, Float angle); |
|
54 void setThreads(int num) { num_threads = num; }; |
|
55 }; |
|
56 |
|
57 #endif |