Gin
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Camera3D Class Reference

A 3D camera that can be positioned and oriented in space. More...

#include <gin_camera3d.h>

Public Member Functions

 Camera3D ()=default
 
void setPosition (const Vec3f &pos)
 Sets the camera position.
 
void setPosition (float x, float y, float z)
 
Vec3f getPosition () const
 Gets the camera position.
 
void setTarget (const Vec3f &t)
 Sets the point the camera is looking at.
 
void setTarget (float x, float y, float z)
 
Vec3f getTarget () const
 Gets the target point.
 
void setUpVector (const Vec3f &u)
 Sets the up vector.
 
Vec3f getUpVector () const
 Gets the up vector.
 
void setPerspective (float fovYDegrees, float aspectRatio, float nearPlane, float farPlane)
 Sets up a perspective projection.
 
const Mat4fgetViewMatrix () const
 Gets the view matrix (world to camera space).
 
const Mat4fgetProjectionMatrix () const
 Gets the projection matrix.
 
Mat4f getViewProjectionMatrix () const
 Gets the combined view-projection matrix.
 
void orbit (float deltaYaw, float deltaPitch)
 Orbits the camera around the target point.
 
void zoom (float delta)
 Zooms the camera (moves towards/away from target).
 
void pan (float deltaX, float deltaY)
 Pans the camera (moves both position and target).
 

Detailed Description

A 3D camera that can be positioned and oriented in space.

Constructor & Destructor Documentation

◆ Camera3D()

Camera3D::Camera3D ( )
default

Member Function Documentation

◆ setPosition() [1/2]

void Camera3D::setPosition ( const Vec3f pos)

Sets the camera position.

◆ setPosition() [2/2]

void Camera3D::setPosition ( float  x,
float  y,
float  z 
)

◆ getPosition()

Vec3f Camera3D::getPosition ( ) const

Gets the camera position.

◆ setTarget() [1/2]

void Camera3D::setTarget ( const Vec3f t)

Sets the point the camera is looking at.

◆ setTarget() [2/2]

void Camera3D::setTarget ( float  x,
float  y,
float  z 
)

◆ getTarget()

Vec3f Camera3D::getTarget ( ) const

Gets the target point.

◆ setUpVector()

void Camera3D::setUpVector ( const Vec3f u)

Sets the up vector.

◆ getUpVector()

Vec3f Camera3D::getUpVector ( ) const

Gets the up vector.

◆ setPerspective()

void Camera3D::setPerspective ( float  fovYDegrees,
float  aspectRatio,
float  nearPlane,
float  farPlane 
)

Sets up a perspective projection.

Parameters
fovYDegreesField of view in degrees
aspectRatioWidth / height
nearPlaneNear clipping plane distance
farPlaneFar clipping plane distance

◆ getViewMatrix()

const Mat4f & Camera3D::getViewMatrix ( ) const

Gets the view matrix (world to camera space).

References Mat4< float >::lookAt().

Referenced by getViewProjectionMatrix().

◆ getProjectionMatrix()

const Mat4f & Camera3D::getProjectionMatrix ( ) const

Gets the projection matrix.

References Mat4< float >::perspective().

Referenced by getViewProjectionMatrix().

◆ getViewProjectionMatrix()

Mat4f Camera3D::getViewProjectionMatrix ( ) const

Gets the combined view-projection matrix.

References getProjectionMatrix(), and getViewMatrix().

◆ orbit()

void Camera3D::orbit ( float  deltaYaw,
float  deltaPitch 
)

Orbits the camera around the target point.

Parameters
deltaYawHorizontal rotation in radians
deltaPitchVertical rotation in radians

References Vec3< T >::length(), Point< T >::x, Vec3< T >::x, Point< T >::y, Vec3< T >::y, and Vec3< T >::z.

◆ zoom()

void Camera3D::zoom ( float  delta)

Zooms the camera (moves towards/away from target).

Parameters
deltaPositive zooms in, negative zooms out

References Vec3< T >::length(), and Vec3< T >::normalized().

◆ pan()

void Camera3D::pan ( float  deltaX,
float  deltaY 
)

Pans the camera (moves both position and target).

Parameters
deltaXHorizontal movement
deltaYVertical movement

References Vec3< T >::cross().


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