Slippers Engine
 
Loading...
Searching...
No Matches
CameraManager Class Reference

Responsible for the current Camera and Camera2D. For functions go to Scene. More...

#include <CameraManager.h>

Collaboration diagram for CameraManager:
Collaboration graph

Private Member Functions

Camera * GetCurrCam ()
 Retrieval of current camera.
 
Camera * GetCam2D ()
 Retrieval of current 2D camera.
 
void SetCurrCam (Camera *newCam)
 Swaps main Camera.
 
void MoveCam (Vect up, Vect lookAt, Vect pos)
 Moves main camera and changes orientation.
 
void UpdateCam ()
 Responsible for updating the main camera.
 

Detailed Description

Responsible for the current Camera and Camera2D. For functions go to Scene.

This class is responsible for the creation of a default Camera and Camera2D as well as holding functions for updating, moving, getting and changing the camera. To access these functions go to Scene.

Member Function Documentation

◆ GetCam2D()

Camera * CameraManager::GetCam2D ( )
private

Retrieval of current 2D camera.

This function retrieves the 2D camera, for uses such as rendering sprites.

Returns
Camera*

◆ GetCurrCam()

Camera * CameraManager::GetCurrCam ( )
private

Retrieval of current camera.

This function retrieves the current active camera, for uses such as rendering models.

Returns
Camera*

◆ MoveCam()

void CameraManager::MoveCam ( Vect up,
Vect lookAt,
Vect pos )
private

Moves main camera and changes orientation.

This function is set up to allow users to change where the camera is located as well as what the camera is facing. This does not automatically call UpdateCam().

Parameters
up
lookAt
pos

◆ SetCurrCam()

void CameraManager::SetCurrCam ( Camera * newCam)
private

Swaps main Camera.

Allows for the current active camera to be swapped with a user generated camera. Users are now responsible for deletion of the new camera.

Warning
NearClipPlane, FarClipPlane, and FOV must be set to do screen picking

Example:

Camera* tmpCam = new Camera(Camera::Type::PERSPECTIVE_3D);
tmpCam->setViewport(0, 0, Game::GetWidth(), Game::GetHeight());
tmpCam->setPerspective(35.0f, float(Game::GetWidth()) / float(Game::GetHeight()), 1.0f, 5000.0f);
// Orient Camera
Vect up3DCam(0.0f, 1.0f, 0.0f);
Vect pos3DCam(50.0f, 50.0f, 150.0f);
Vect lookAt3DCam(0.0f, 0.0f, 0.0f);
SceneManager::GetCurrScene()->MoveCam(up3DCam, lookAt3DCam, pos3DCam);
//THESE MUST BE SET FOR SCREEN PICKING
SceneManager::GetCurrScene()->setNearClipPlane(1.0f);
SceneManager::GetCurrScene()->setFarClipPlane(5000.0f);
SceneManager::GetCurrScene()->setFOV(35.0f);
static int GetHeight()
Returns window's height in pixels.
Definition Game.h:161
static int GetWidth()
Returns window's width in pixels.
Definition Game.h:167
void MoveCam(Vect up, Vect lookAt, Vect pos)
Moves Current Camera. For more information go to CameraManager.
Definition Scene.cpp:102
void SetCurrCam(Camera *newCam)
Changes Current Camera. For more information go to CameraManager.
Definition Scene.cpp:98
void UpdateCam()
Updates Current Camera. For more information go to CameraManager.
Definition Scene.cpp:106
static Scene * GetCurrScene()
Returns pointer to current scene.
Definition SceneManager.h:51
Parameters
newCam

◆ UpdateCam()

void CameraManager::UpdateCam ( )
private

Responsible for updating the main camera.

Allows changes made by MoveCam() to take effect within the scene.