Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // for all pixels of window
- for (int y = height_half_neg; y < height_half; ++y) {
- for (int x = width_half_neg; x < width_half; ++x) {
- Pixel p(x+width_half, y+height_half);
- // pseudo-camera-model:
- // by setting the camera origin at z=+focal_length, projecting
- // the vector at z=-focal_length results in the image plane being at
- // [0,0,0]
- camera_ray = Ray( math3d::point(0.,0.,focal_length),
- math3d::vector(x,y,-focal_length));
- // compute color for pixel
- std::shared_ptr<CRDS> intersection = m_scene->getNearestIntersection(camera_ray);
- if (intersection->hit == 1)
- {
- Ray camera_ray_t = Ray(
- intersection->shape->getInverseTransformation()
- * camera_ray.origin,
- intersection->shape->getInverseTransformation()
- * camera_ray.dir
- );
- //camera_ray_t = camera_ray; // ???
- math3d::point intersection_point = math3d::point(
- camera_ray_t.origin[0]+intersection->t*camera_ray_t.dir[0],
- camera_ray_t.origin[1]+intersection->t*camera_ray_t.dir[1],
- camera_ray_t.origin[2]+intersection->t*camera_ray_t.dir[2]
- );
- intersection_point = intersection->shape->getTransformation()
- * intersection_point;
- // ???
- Color temp_color = intersection->shape->getColor(intersection_point, m_scene);
- p.color = temp_color;
- } else {
- p.color = Color(0., 0., 0.);
- }
- window.write(p); // write pixel to output window
- image.write(p); // write pixel to image writer
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement