CGVIS Utils
Loading...
Searching...
No Matches
Camera Class Reference

#include <Camera.h>

Public Member Functions

 Camera (Vec3 position, float moveSpeed=0.015f, float mouseSens=0.15f, Vec3 worldUp=Vec3(0.0f, 1.0f, 0.0f))
 Construct a camera at position with speeds/sensitivity and an up axis.
void updatePosition ()
 Integrate position one step based on active movement flags.
Mat4 viewMatrix ()
 Compute the view (camera) matrix.
Movement toggles (set on key press/release)
void moveFront (bool b)
 Toggle forward motion along the view direction.
void moveBack (bool b)
 Toggle backward motion along the view direction.
void moveRight (bool b)
 Toggle motion to the right (strafe).
void moveLeft (bool b)
 Toggle motion to the left (strafe).
Mouse look
void enableMouse ()
 Enable mouse-look processing in mouseMove().
void disableMouse ()
 Disable mouse-look and reset the internal cursor cache.
void mouseMove (float xPosition, float yPosition)
 Update yaw/pitch from a new cursor position.

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( Vec3 position,
float moveSpeed = 0.015f,
float mouseSens = 0.15f,
Vec3 worldUp = Vec3(0.0f, 1.0f, 0.0f) )
inline

Construct a camera at position with speeds/sensitivity and an up axis.

Parameters
positionInitial world position.
moveSpeedLinear speed per update (world units per frame).
mouseSensMouse sensitivity in degrees per pixel.
worldUpWorld up vector used to build the orthonormal basis.

Member Function Documentation

◆ disableMouse()

void Camera::disableMouse ( )
inline

Disable mouse-look and reset the internal cursor cache.

Resets the cached mouse position so the next mouseMove() call establishes a new reference without producing a jump.

◆ enableMouse()

void Camera::enableMouse ( )
inline

Enable mouse-look processing in mouseMove().

◆ mouseMove()

void Camera::mouseMove ( float xPosition,
float yPosition )
inline

Update yaw/pitch from a new cursor position.

Parameters
xPositionNew cursor X in window coordinates (pixels).
yPositionNew cursor Y in window coordinates (pixels).

When enabled, computes pixel deltas since the previous call, scales them by mouseSens, applies them to yaw/pitch, clamps pitch to [-89,89], and rebuilds the basis. The first call after enabling only seeds the cache.

◆ moveBack()

void Camera::moveBack ( bool b)
inline

Toggle backward motion along the view direction.

◆ moveFront()

void Camera::moveFront ( bool b)
inline

Toggle forward motion along the view direction.

◆ moveLeft()

void Camera::moveLeft ( bool b)
inline

Toggle motion to the left (strafe).

◆ moveRight()

void Camera::moveRight ( bool b)
inline

Toggle motion to the right (strafe).

◆ updatePosition()

void Camera::updatePosition ( )
inline

Integrate position one step based on active movement flags.

Applies moveSpeed along direction and right depending on which toggles are set. Call this once per frame.

◆ viewMatrix()

Mat4 Camera::viewMatrix ( )
inline

Compute the view (camera) matrix.

Returns
Right-handed look-at matrix from position toward forward direction.
Here is the call graph for this function:

The documentation for this class was generated from the following file: