sgltk 0.6
Simple OpenGL Tool Kit
Loading...
Searching...
No Matches
sgltk::P_Camera Class Reference

Manages perspective cameras. More...

#include <camera.h>

Inheritance diagram for sgltk::P_Camera:
Collaboration diagram for sgltk::P_Camera:

Public Member Functions

 P_Camera (const sgltk::P_Camera &camera)
 P_Camera (glm::vec3 position, glm::vec3 direction, glm::vec3 up)
 P_Camera (glm::vec3 position, glm::vec3 direction, glm::vec3 up, float fovy, float width, float height, float near_plane, float far_plane)
void update_projection_matrix ()
 Recalculates the projection matrix.
std::vector< glm::vec3 > calculate_frustum_points ()
 Calculates the corner points of the camera's frustum.
std::vector< float > calculate_frustum_distance (glm::vec3 point)
 Calculates the distances of a point to all planes of the camera's frustum. Positive values indicate that the point and the frustum are on the opposite sides of the plane.
Public Member Functions inherited from sgltk::Camera
 Camera (glm::vec3 position, glm::vec3 direction, glm::vec3 up)
void update_view_matrix ()
 Recalculates the view matrix.
void move_up (float delta)
 Move the camera along the up vector.
void move_right (float delta)
 Move the camera along the right vector.
void move_forward (float delta)
 Move the camera along the forward vector.
void move_by (float x, float y, float z)
 Move the camera by the vector (x, y, z)
void move_by (glm::vec3 vector)
 Move the camera by the vector.
void yaw (float angle)
 Rotate the camera using the up vector as the axis.
void roll (float angle)
 Rotate the camera using the forward vector as the axis.
void pitch (float angle)
 Rotate the camera using the right vector as the axis.

Additional Inherited Members

Public Attributes inherited from sgltk::Camera
glm::mat4 view_matrix
 The view matrix.
glm::mat4 projection_matrix
 The perspective projection matrix.
float width
 Viewport width.
float height
 Viewport height.
float fovy
 The vertical field of view angle of the camera.
float far_plane
 The far plane of the camera frustum.
float near_plane
 The near plane of the camera frustum.
glm::vec3 position
 The camera position.
glm::vec3 direction
 The direction the camera is pointing.
glm::vec3 up
 The up vector of the camera.
glm::vec3 right
 The right vector of the camera.

Detailed Description

Manages perspective cameras.

class P_Camera

Definition at line 127 of file camera.h.

Constructor & Destructor Documentation

◆ P_Camera() [1/4]

P_Camera::P_Camera ( )

Definition at line 5 of file camera_p.cpp.

◆ P_Camera() [2/4]

P_Camera::P_Camera ( const sgltk::P_Camera & camera)
Parameters
cameraThe camera to copy

Definition at line 12 of file camera_p.cpp.

◆ P_Camera() [3/4]

P_Camera::P_Camera ( glm::vec3 position,
glm::vec3 direction,
glm::vec3 up )
Parameters
positionThe camera position
directionThe view direction
upThe up vector

Definition at line 23 of file camera_p.cpp.

◆ P_Camera() [4/4]

P_Camera::P_Camera ( glm::vec3 position,
glm::vec3 direction,
glm::vec3 up,
float fovy,
float width,
float height,
float near_plane,
float far_plane )
Parameters
positionThe camera position
directionThe view direction
upThe up vector
fovyThe field of view in radians
widthThe width of the viewport
heightThe height of the viewport
near_planeThe near plane
far_planeThe far plane

Definition at line 31 of file camera_p.cpp.

◆ ~P_Camera()

P_Camera::~P_Camera ( )

Definition at line 49 of file camera_p.cpp.

Member Function Documentation

◆ calculate_frustum_distance()

std::vector< float > P_Camera::calculate_frustum_distance ( glm::vec3 point)

Calculates the distances of a point to all planes of the camera's frustum. Positive values indicate that the point and the frustum are on the opposite sides of the plane.

Parameters
pointThe point to calculate the distances to.
Returns
Returns a vector containing the distances of the point to the planes of the frustum. 0 - far 1 - near 2 - left 3 - right 4 - top 5 - bottom

Definition at line 83 of file camera_p.cpp.

◆ calculate_frustum_points()

std::vector< glm::vec3 > P_Camera::calculate_frustum_points ( )

Calculates the corner points of the camera's frustum.

Returns
Returns a vector containing the world coordinates of the frustum points. 0 - near-bottom-left 1 - near-bottom-right 2 - near-top-right 3 - near-top-left 4 - far-bottom-left 5 - far-bottom-right 6 - far-top-right 7 - far-top-left

Definition at line 59 of file camera_p.cpp.

◆ update_projection_matrix()

void P_Camera::update_projection_matrix ( )
virtual

Recalculates the projection matrix.

Implements sgltk::Camera.

Definition at line 52 of file camera_p.cpp.


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