CGPdocs

camera_orbit

Camera orbiting around a center of rotation.

Derives from: camera_generic_base

module 10_camera_modelsource: camera_orbit.hpp
The camera sits at distance_to_center from center_of_rotation and looks toward it; the mouse and keys of camera_controller_orbit change these fields.
The camera sits at distance_to_center from center_of_rotation and looks toward it; the mouse and keys of camera_controller_orbit change these fields. Tap to enlarge.

Fields and methods

Members of the struct camera_orbit. Most of what you do with a CGP type goes through the free functions listed below.

Fields

rotation_transform orientation_cameraOrientation of the camera frame (identity by default, the camera then looks toward -z).
vec3 center_of_rotationPoint the camera orbits around and looks at, (0,0,0) by default.
float distance_to_centerDistance between the camera position and center_of_rotation, 5 by default.

Methods

Builds an orbit camera with identity orientation, center at the origin and distance_to_center = 5, so that the camera sits at (0,0,5) looking toward -z. src
Returns the camera position, center_of_rotation + orientation_camera * (0,0,distance_to_center). src
Returns orientation_camera. src
Rotates the camera around center_of_rotation from the mouse displacement p0 -> p1 given in relative screen coordinates [-1,1] (arcball/trackball rotation; no effect if the displacement is below 1e-4). src
Applies an incremental rotation, expressed in the current camera frame, of angles roll (around the view direction), pitch (around the right axis) and yaw (around the up axis), in radians, around center_of_rotation. src
Multiplies distance_to_center by (1 + magnitude), clamped to at least 0.01; the center is unchanged. src
Translates center_of_rotation (and thus the camera) by tr.x * right() + tr.y * up(). src
Translates center_of_rotation (and thus the camera) by magnitude * front(). src
Places the camera at eye looking toward center with the given up vector, setting center_of_rotation = center and distance_to_center = norm(eye-center). src
Inherited from camera_generic_base (6 members)

Methods

Returns the camera frame built from orientation() and position(). src
Returns the 4x4 view matrix (world to camera), the inverse of the camera frame matrix. src
Returns the 4x4 matrix of the camera frame (camera to world), the inverse of matrix_view(). src
Returns the viewing direction, the opposite of the third column (local z axis) of orientation(). src
Returns the up direction of the camera, the second column (local y axis) of orientation(). src
Returns the right direction of the camera, the first column (local x axis) of orientation(). src

Functions taking a camera_orbit

Compute 3

Documented on another page

  • picking_mesh_vertex_as_sphereCasts the camera ray through the screen position and returns the closest vertex whose sphere of radius picking_distance it hits, with the hit point, the vertex normal and the vertex index (active is false if none).on vec2
  • picking_plane_orthogonal_to_cameraIntersects the camera ray through the screen position (relative coordinates) with the plane through plane_position orthogonal to the front direction of the camera.on vec2
  • picking_spheresCast a ray through a screen position (normalized device coordinates) and return the closest hit among spheres of common radius, with its index, position and normal.on vec2

Functions returning a camera_orbit

None.

Operators

None.

CGP - Computer Graphics Programming.