equal
deleted
inserted
replaced
55 inline Shape *Raytracer::nearest_intersection(const Shape *origin_shape, const Ray &ray, |
55 inline Shape *Raytracer::nearest_intersection(const Shape *origin_shape, const Ray &ray, |
56 float &nearest_distance) |
56 float &nearest_distance) |
57 { |
57 { |
58 Shape *nearest_shape = NULL; |
58 Shape *nearest_shape = NULL; |
59 ShapeList::iterator shape; |
59 ShapeList::iterator shape; |
60 for (shape = shapes.begin(); shape != shapes.end(); shape++) |
60 for (shape = top->shapes.begin(); shape != top->shapes.end(); shape++) |
61 if (*shape != origin_shape && (*shape)->intersect(ray, nearest_distance)) |
61 if (*shape != origin_shape && (*shape)->intersect(ray, nearest_distance)) |
62 nearest_shape = *shape; |
62 nearest_shape = *shape; |
63 return nearest_shape; |
63 return nearest_shape; |
64 } |
64 } |
65 |
65 |
219 float startx = -1.0 * 4, starty = (float)h/w * 4; |
219 float startx = -1.0 * 4, starty = (float)h/w * 4; |
220 float dx = -2*startx/w, dy = -2*starty/h; |
220 float dx = -2*startx/w, dy = -2*starty/h; |
221 float vy; |
221 float vy; |
222 RenderrowData *d; |
222 RenderrowData *d; |
223 |
223 |
|
224 printf("* building kd-tree\n"); |
|
225 //cout << endl; |
|
226 static_cast<KdTree*>(top)->optimize(); |
|
227 //static_cast<KdTree*>(top)->save(cout); |
|
228 //cout << endl; |
|
229 |
224 //srand(time(NULL)); |
230 //srand(time(NULL)); |
225 |
231 |
226 // eye - viewing point |
232 // eye - viewing point |
227 Vector3 eye(0, 0, -5); |
233 Vector3 eye(0, 0, -5); |
228 |
234 |
281 #endif |
287 #endif |
282 |
288 |
283 return data; |
289 return data; |
284 } |
290 } |
285 |
291 |
286 void Raytracer::addshape(Shape *shape) |
|
287 { |
|
288 shapes.push_back(shape); |
|
289 } |
|
290 |
|
291 void Raytracer::addlight(Light *light) |
292 void Raytracer::addlight(Light *light) |
292 { |
293 { |
293 lights.push_back(light); |
294 lights.push_back(light); |
294 } |
295 } |
295 |
296 |