68 pthread_mutex_t sample_queue_mutex, sampler_mutex; |
68 pthread_mutex_t sample_queue_mutex, sampler_mutex; |
69 pthread_cond_t sample_queue_cond, worker_ready_cond; |
69 pthread_cond_t sample_queue_cond, worker_ready_cond; |
70 |
70 |
71 static void *raytrace_worker(void *d); |
71 static void *raytrace_worker(void *d); |
72 public: |
72 public: |
73 Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0), |
73 Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0., 0., 0.), |
74 ao_samples(0), num_threads(2), max_depth(3) |
74 ao_samples(0), num_threads(2), max_depth(3) |
75 { |
75 { |
76 pthread_mutex_init(&sample_queue_mutex, NULL); |
76 pthread_mutex_init(&sample_queue_mutex, NULL); |
77 pthread_mutex_init(&sampler_mutex, NULL); |
77 pthread_mutex_init(&sampler_mutex, NULL); |
78 pthread_cond_init (&sample_queue_cond, NULL); |
78 pthread_cond_init (&sample_queue_cond, NULL); |
86 pthread_cond_destroy (&worker_ready_cond); |
86 pthread_cond_destroy (&worker_ready_cond); |
87 } |
87 } |
88 |
88 |
89 void render(); |
89 void render(); |
90 Colour raytrace(Ray &ray, int depth, Shape *origin_shape); |
90 Colour raytrace(Ray &ray, int depth, Shape *origin_shape); |
91 void addshape(Shape *shape) { top->addShape(shape); }; |
91 void addShape(Shape *shape) { top->addShape(shape); }; |
92 void addlight(Light *light); |
92 void addLight(Light *light) { lights.push_back(light); }; |
93 void setSampler(Sampler *sampl) { sampler = sampl; }; |
93 void setSampler(Sampler *sampl) { sampler = sampl; }; |
94 void setCamera(Camera *cam) { camera = cam; }; |
94 void setCamera(Camera *cam) { camera = cam; }; |
95 void setTop(Container *atop) { top = atop; }; |
95 void setTop(Container *atop) { top = atop; }; |
96 Container *getTop() { return top; }; |
96 Container *getTop() { return top; }; |
97 |
97 |
|
98 void setBgColour(const Colour &bg) { bg_colour = bg; }; |
98 void setMaxDepth(int newdepth) { max_depth = newdepth; }; |
99 void setMaxDepth(int newdepth) { max_depth = newdepth; }; |
99 |
100 |
100 void ambientocclusion(int samples, Float distance, Float angle); |
101 void ambientocclusion(int samples, Float distance, Float angle); |
101 void setThreads(int num) { num_threads = num; }; |
102 void setThreads(int num) { num_threads = num; }; |
102 }; |
103 }; |