24 virtual Ray gen_ray(
float u,
float v)
const = 0;
32 virtual void mouse_motion(
float x,
float y) = 0;
34 virtual void keyboard_motion(
float x,
float y,
float z) = 0;
43 dir = normalize(c - e);
44 right = normalize(cross(dir, u));
45 up = normalize(cross(right, dir));
47 w = std::tan(fov * pi / 360.0f);
54 return Ray(eye, normalize(dir + u * right + v * up));
58 auto d = normalize(p - eye);
59 return float3(dot(d, right) / (w * w), dot(d, up) / (h * h), dot(d, dir));
67 float d = std::sqrt(1.0f + u * u * w * w + v * v * h * h);
72 dir = rotate(dir, right, -y);
73 dir = rotate(dir, up, -x);
75 right = normalize(cross(dir, up));
76 up = normalize(cross(right, dir));
83 eye += dir * z + right * x + up * y;
void keyboard_motion(float x, float y, float z) override final
Updates the camera after keyboard input.
Definition: cameras.h:82
Ray gen_ray(float u, float v) const override final
Generates a ray for a point on the image plane, represented by (u, v) in [-1,1]^2.
Definition: cameras.h:53
float cos
Cosine between the local camera direction and the image plane normal.
Definition: cameras.h:10
float area
Local pixel area divided by total area.
Definition: cameras.h:12
float dist
Distance between the camera and the point on the image plane.
Definition: cameras.h:11
void mouse_motion(float x, float y) override final
Updates the camera after mouse input.
Definition: cameras.h:71
float3 project(const float3 &p) const override final
Projects a point onto the image plane and returns the corresponding (u, v, z) coordinates.
Definition: cameras.h:57
CameraGeometry geometry(float u, float v) const override final
Returns the geometry at a given point on the image plane.
Definition: cameras.h:66
Structure that holds the local geometry information on a camera lens.
Definition: cameras.h:9
Ray defined as org + t * dir, with t in [tmin, tmax].
Definition: intersect.h:11
float3 unproject(const float3 &) const override final
Unprojects a point on the image plane, represented by (u, v, z) with (u, v) in [-z, z]^2 and z in [0, inf[.
Definition: cameras.h:62
Base class for cameras.
Definition: cameras.h:20