V-Gears 0
Free Final Fantasy VII engine.
CameraManager Class Reference

The camera manager. More...

#include <CameraManager.h>

Inheritance diagram for CameraManager:
Collaboration diagram for CameraManager:

Public Member Functions

 CameraManager ()
 Constructor. More...
 
virtual ~CameraManager ()
 Destructor. More...
 
void Input (const VGears::Event &event) override
 Handles camera actions. More...
 
void Input (const VGears::Event &event, Ogre::Real time_since_last_frame)
 Handles camera actions. More...
 
void OnResize () override
 Trigered when the viewport is resized. More...
 
void UpdateDebug () override
 Updates debug information. More...
 
void ClearField () override
 Clears all field information in the camera manager. More...
 
void ClearBattle () override
 Clears all battle information in the camera manager. More...
 
void ClearWorld () override
 Clears all world map information in the camera manager. More...
 
void SetCameraFree (const bool enable)
 Enables or disables the free camera. More...
 
void Set2DCamera (const Ogre::Vector3 position, const Ogre::Quaternion orientation, const Ogre::Radian fov)
 Sets the camera properties. More...
 
void StartBattleCamera (const Ogre::Vector3 position, const Ogre::Vector3 orientation)
 Starts the battle camera. More...
 
void EndBattleCamera ()
 Ends the battle camera. More...
 
void Set2DScroll (const Ogre::Vector2 &position)
 Sets the camera scroll. More...
 
const Ogre::Vector2 & Get2DScroll () const
 Retrieves the camera position. More...
 
const Ogre::Vector3 ProjectPointToScreen (const Ogre::Vector3 &point)
 Calculates the position of a point in screen. More...
 
Ogre::Camera * GetCurrentCamera ()
 Retrieves the camera. More...
 
Ogre::Viewport * getViewport ()
 Retrieves the viewport. More...
 
void EnableWireFrame (bool enable)
 Enables or disables the camera wireframe. More...
 
void ScriptSetCamera (const int x, const int y, const int z, const int d_x, const int d_y, const int d_z)
 Sets the camera position and orientation. More...
 
- Public Member Functions inherited from Manager
 Manager ()
 Constructor. More...
 
virtual ~Manager ()
 Destructor. More...
 
Module GetModule () const
 Retrieves the currently selected module. More...
 
bool IsModule (const Module module) const
 Checks the currently selected module. More...
 
bool IsFieldModule () const
 Checks if the currently selected module is the field module. More...
 
bool IsBattleModule () const
 Checks if the currently selected module is the battle module. More...
 
bool IsWorldModule () const
 Checks if the currently selected module is the world module. More...
 
void SetModule (const Module module)
 Sets the current module for the entity manager. More...
 
void SetFieldModule ()
 Sets the current module to the field mode. More...
 
void SetBattleModule ()
 Sets the current module to the battle mode. More...
 
void SetWorldModule ()
 Sets the current module to the world map mode. More...
 
void SetPreviousModule ()
 Sets the module that was loaded before a battle. More...
 
virtual void Input (const VGears::Event &event)=0
 Handles an input event. More...
 
void Update ()
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void UpdateDebug ()=0
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void OnResize ()=0
 Handles resizing events. More...
 
void Clear ()
 Clears the manager. More...
 
void Clear (const Module module)
 Clears the manager. More...
 
virtual void ClearField ()=0
 Clear all field information in the manager. More...
 
virtual void ClearBattle ()=0
 Clear all battle information in the manager. More...
 
virtual void ClearWorld ()=0
 Clear all world map information in the manager. More...
 
void ClearAll ()
 Clears the manager. More...
 
void ScriptSetPaused (const bool paused)
 Handles game pausing. More...
 

Private Member Functions

void InitCommands ()
 Initializes the camera parameters. More...
 
void UpdateField () override
 Updates while the camera is in the field. More...
 
void UpdateBattle () override
 Updates while the camera is in battle. More...
 
void UpdateWorld () override
 Updates while the camera is in the world map. More...
 

Private Attributes

Ogre::Camera * camera_
 The camera. More...
 
Ogre::Viewport * viewport_
 The viewport. More...
 
Ogre::Vector3 position_initial_
 The initial position of the camera, saved when created. More...
 
Ogre::Quaternion orientation_initial_
 The initial orientation of the camera, saved when created. More...
 
Ogre::Vector3 position_backup_
 A backup of the field or world camera position for when the battle camera is activated. More...
 
Ogre::Quaternion orientation_backup_
 A backup of the field or world camera orientation for when the battle camera is active. More...
 
bool camera_free_
 Flag to indicate a free camera. More...
 
bool camera_free_rotate_
 Flag to indicate the free camera has rotated. More...
 
Ogre::Vector3 d2_position_
 Camera position. More...
 
Ogre::Quaternion d2_orientation_
 Camera orientation. More...
 
Ogre::Radian d2_fov_
 The field of view. More...
 
Ogre::Vector2 d2_scroll_
 The camera scroll. More...
 

Additional Inherited Members

- Public Types inherited from Manager
enum  Module { FIELD = 0 , BATTLE = 1 , WORLD = 2 }
 The modules the entity manager can handle. More...
 
- Protected Member Functions inherited from Manager
virtual void UpdateField ()=0
 Updates the field entities in the manager. More...
 
virtual void UpdateBattle ()=0
 Updates the battle entities in the manager. More...
 
virtual void UpdateWorld ()=0
 Updates the world map entities in the manager. More...
 
void Update (Module module)
 Updates the entities of one module in the manager. More...
 
- Protected Attributes inherited from Manager
Module module_
 The currently selected module. More...
 
Module prev_module_
 The previous module. More...
 
bool paused_
 Indicates if the game is paused. More...
 

Detailed Description

The camera manager.

Constructor & Destructor Documentation

◆ CameraManager()

CameraManager::CameraManager ( )

Constructor.

Initializes the camera with default parameters attached to the root scene manager.

◆ ~CameraManager()

CameraManager::~CameraManager ( )
virtual

Destructor.

Member Function Documentation

◆ ClearBattle()

void CameraManager::ClearBattle ( )
overridevirtual

Clears all battle information in the camera manager.

Implements Manager.

◆ ClearField()

void CameraManager::ClearField ( )
overridevirtual

Clears all field information in the camera manager.

Implements Manager.

◆ ClearWorld()

void CameraManager::ClearWorld ( )
overridevirtual

Clears all world map information in the camera manager.

Implements Manager.

◆ EnableWireFrame()

void CameraManager::EnableWireFrame ( bool  enable)

Enables or disables the camera wireframe.

In wireframe mode, faces will not be rendered, only edges

Parameters
[in]enableTrue to enable wireframe mode, false to disable.

◆ EndBattleCamera()

void CameraManager::EndBattleCamera ( )

Ends the battle camera.

Returns the camera to the state it was when {

See also
StartBattleCamera} was called.

◆ Get2DScroll()

const Ogre::Vector2 & CameraManager::Get2DScroll ( ) const

Retrieves the camera position.

Returns
The camera current position, relative to absolute origin.

◆ GetCurrentCamera()

Ogre::Camera * CameraManager::GetCurrentCamera ( )

Retrieves the camera.

Returns
The current camera.

◆ getViewport()

Ogre::Viewport * CameraManager::getViewport ( )

Retrieves the viewport.

Returns
The camera viewport.

◆ InitCommands()

void CameraManager::InitCommands ( )
private

Initializes the camera parameters.

Must be called on construction.

◆ Input() [1/2]

void CameraManager::Input ( const VGears::Event event)
overridevirtual

Handles camera actions.

Handles the scene manager camera actions based on events.

Parameters
[in]eventEvent that triggers the camera action.

Implements Manager.

◆ Input() [2/2]

void CameraManager::Input ( const VGears::Event event,
Ogre::Real  time_since_last_frame 
)

Handles camera actions.

Handles the scene manager camera actions based on events.

Parameters
[in]eventEvent that triggers the camera action.
[in]time_since_last_frameFor speed calculation.

◆ OnResize()

void CameraManager::OnResize ( )
overridevirtual

Trigered when the viewport is resized.

Resets the aspect ratio.

Implements Manager.

◆ ProjectPointToScreen()

const Ogre::Vector3 CameraManager::ProjectPointToScreen ( const Ogre::Vector3 &  point)

Calculates the position of a point in screen.

The calculation is done using A map position and the camera scroll.

Parameters
[in]pointPosition of the map to be translated to screen position.
Returns
Position of POINT in screen coordinates.

◆ ScriptSetCamera()

void CameraManager::ScriptSetCamera ( const int  x,
const int  y,
const int  z,
const int  d_x,
const int  d_y,
const int  d_z 
)

Sets the camera position and orientation.

It's only meand to be used for 3D cameras (battle, world map...), and using it while on a field can have unexpected results.

Parameters
[in]xX coordinate for the camera position.
[in]yY coordinate for the camera position.
[in]zZ coordinate for the camera position.
[in]d_xX coordinate of the point the camera looks at.
[in]d_yY coordinate of the point the camera looks at.
[in]d_zZ coordinate of the point the camera looks at.

◆ Set2DCamera()

void CameraManager::Set2DCamera ( const Ogre::Vector3  position,
const Ogre::Quaternion  orientation,
const Ogre::Radian  fov 
)

Sets the camera properties.

Parameters
[in]positionCamera coordinates.
[in]orientationCamera rotation, in quaternion format.
[in]fovField of view, in radians.

◆ Set2DScroll()

void CameraManager::Set2DScroll ( const Ogre::Vector2 &  position)

Sets the camera scroll.

Moves the camera to the desired position. If the camera is in free mode, it sets the position, but it won't actually move the camera.

Parameters
[in]positionPosition to scroll the camera to.

◆ SetCameraFree()

void CameraManager::SetCameraFree ( const bool  enable)

Enables or disables the free camera.

A free camera moves depending on player input, not according to a script. For example, a camera following the PC is a free camera.

Parameters
[in]enableTrue to enable free camera, false to disable it.

◆ StartBattleCamera()

void CameraManager::StartBattleCamera ( const Ogre::Vector3  position,
const Ogre::Vector3  orientation 
)

Starts the battle camera.

Saves the position and orientation of the current camera to return once the battle is over.

Parameters
[in]positionInitial position of the battle camera.
[in]orientationInitial orientation of the battle camera. It indicates the point the camera will look at.

◆ UpdateBattle()

void CameraManager::UpdateBattle ( )
overrideprivatevirtual

Updates while the camera is in battle.

Implements Manager.

◆ UpdateDebug()

void CameraManager::UpdateDebug ( )
overridevirtual

Updates debug information.

Implements Manager.

◆ UpdateField()

void CameraManager::UpdateField ( )
overrideprivatevirtual

Updates while the camera is in the field.

Implements Manager.

◆ UpdateWorld()

void CameraManager::UpdateWorld ( )
overrideprivatevirtual

Updates while the camera is in the world map.

Implements Manager.

Member Data Documentation

◆ camera_

Ogre::Camera* CameraManager::camera_
private

The camera.

◆ camera_free_

bool CameraManager::camera_free_
private

Flag to indicate a free camera.

A free camera moves depending on player input, not according to a script. For example, a camera following the PC is a free camera.

◆ camera_free_rotate_

bool CameraManager::camera_free_rotate_
private

Flag to indicate the free camera has rotated.

◆ d2_fov_

Ogre::Radian CameraManager::d2_fov_
private

The field of view.

◆ d2_orientation_

Ogre::Quaternion CameraManager::d2_orientation_
private

Camera orientation.

◆ d2_position_

Ogre::Vector3 CameraManager::d2_position_
private

Camera position.

◆ d2_scroll_

Ogre::Vector2 CameraManager::d2_scroll_
private

The camera scroll.

◆ orientation_backup_

Ogre::Quaternion CameraManager::orientation_backup_
private

A backup of the field or world camera orientation for when the battle camera is active.

◆ orientation_initial_

Ogre::Quaternion CameraManager::orientation_initial_
private

The initial orientation of the camera, saved when created.

◆ position_backup_

Ogre::Vector3 CameraManager::position_backup_
private

A backup of the field or world camera position for when the battle camera is activated.

◆ position_initial_

Ogre::Vector3 CameraManager::position_initial_
private

The initial position of the camera, saved when created.

◆ viewport_

Ogre::Viewport* CameraManager::viewport_
private

The viewport.


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