Class Camera

Class Documentation

class Camera

Controls the camera view and projection.

Public Functions

Camera()
impl::CameraData matrices(double aspect) const

Calculate camera matrices.

Parameters:

aspect[in] – aspect ratio of the viewport

Returns:

projection, view matrices and target location.

void reset()

Reset the camera view and fov.

void birds_eye_view()

Set camera view as looking from the top as a bird (Birds Eye View).

void roll(float degrees)

Roll the camera with respect to its current roll angle.

Parameters:

degrees[in] – offset to the current roll angle

void set_roll(float degrees)

Set roll in degrees.

Parameters:

degrees[in] – roll angle

float get_roll() const

Get the roll in degrees.

Returns:

roll in degrees

void yaw(float degrees)

Orbit the camera left or right about the camera target.

Parameters:

degrees[in] – offset to the current yaw angle

void set_yaw(float degrees)

Set yaw in degrees.

Parameters:

degrees[in] – yaw angle

float get_yaw() const

Get the yaw in degrees.

Returns:

yaw in degrees

void pitch(float degrees)

Pitch the camera up or down.

Parameters:

degrees[in] – offset to the current pitch angle

void set_pitch(float degrees)

Set pitch in degrees.

Parameters:

degrees[in] – pitch angle

float get_pitch() const

Get the camera pitch in degrees.

Returns:

pitch in degrees

void dolly(double amount)

Move the camera towards or away from the target.

Parameters:

amount[in] – offset to the current camera distance from the target

void set_dolly(double log_distance)

Set dolly (i.e.

log distance) from the target to the camera.

Parameters:

log_distance[in] – log of the distance from the target

double get_dolly() const

Get the log distance from the target to the camera.

Returns:

log_distance

void dolly_xy(double x, double y)

Move the camera in the XY plane of the camera view.

Coordinates are normalized so that 1 is the length of the diagonal of the view plane at the target. This is useful for implementing controls that work intuitively regardless of the camera distance.

Parameters:
  • x[in] – horizontal offset

  • y[in] – vertical offset

void set_view_offset(const vec3d &view_offset)

Set view offset.

Parameters:

view_offset[in] – view offset of the camera

vec3d get_view_offset() const

Get view offset.

Returns:

view offset of the camera

void set_fov(float degrees)

Set the diagonal field of view.

Parameters:

degrees[in] – the diagonal field of view, in degrees

float get_fov() const

Get field of fiew of a camera in degrees.

Returns:

fov in degrees

void set_orthographic(bool state)

Use an orthographic or perspective projection.

Parameters:

state[in] – true for orthographic, false for perspective

bool is_orthographic() const

Get orthographic state.

Returns:

true if orthographic, false if perspective

void set_proj_offset(float x, float y)

Set the 2d position of camera target in the viewport.

Parameters:
  • x[in] – horizontal position in in normalized coordinates [-1, 1]

  • y[in] – vertical position in in normalized coordinates [-1, 1]

vec2d get_proj_offset() const

Get the 2d position of camera target in the viewport.

Returns:

(x, y) position of a camera target in the viewport

void set_target(const mat4d &target)

Directly set camera target object pose.

Parameters:

target[in] – target where camera is looking at

mat4d get_target() const

Get the pose of a camera target.

Returns:

target camera pose