Camera class

A virtual (pinhole) camera.

The camera is responsible for generating primary rays. It is positioned using a Transform and points along the -z axis of the local coordinate system. It has an image plane positioned a z = -dist with size (width, height).

We currently only support pinhole perspective cameras. This class could be made into a virtual base class to support other types of cameras (e.g. an orthographic camera, or omni-directional camera).

The camera setup looks something like this, where the up vector points out of the screen:

        top view                         side view
           ^                    up
           |                     ^
           |                     |             _,-'
         width                   |         _,-'   |
      +----|----+     +          |     _,-'       | h
       \   |   /    d |        e | _,-'           | e
        \  |  /     i |        y +'---------------+-i----->
         \ | /      s |        e  '-,_   dist     | g
          \|/       t |               '-,_        | h
           +          +                   '-,_    | t
          eye                                 '-,_|

Constructors, destructors, conversion operators

Camera(const json& j = json())
Construct a camera from json parameters.

Public functions

auto resolution() const -> Vec2i
Return the camera's image resolution.
auto generate_ray(const Vec2f& pixel) const -> Ray3f
Generate a ray going through image-plane location pixel.

Function documentation

Ray3f Camera::generate_ray(const Vec2f& pixel) const

Generate a ray going through image-plane location pixel.

Parameters
pixel The pixel position within the image.
Returns The Ray data structure filled with the appropriate position and direction.

pixel ranges from (0,0) to (m_resolution.x, m_resolution.y) along the x- and y-axis of the rendered image, respectively.