V-Gears 0
Free Final Fantasy VII engine.
CameraManager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreCamera.h>
19#include <OgreSingleton.h>
20#include "Event.h"
21#include "Manager.h"
22
26class CameraManager : public Manager, public Ogre::Singleton<CameraManager>{
27
28 public:
29
37
41 virtual ~CameraManager();
42
50 void Input(const VGears::Event& event) override;
51
60 void Input(const VGears::Event& event , Ogre::Real time_since_last_frame);
61
67 void OnResize() override;
68
72 void UpdateDebug() override;
73
77 void ClearField() override;
78
82 void ClearBattle() override;
83
87 void ClearWorld() override;
88
97 void SetCameraFree(const bool enable);
98
106 void Set2DCamera(
107 const Ogre::Vector3 position, const Ogre::Quaternion orientation,
108 const Ogre::Radian fov
109 );
110
121 void StartBattleCamera(const Ogre::Vector3 position, const Ogre::Vector3 orientation);
122
128 void EndBattleCamera();
129
138 void Set2DScroll(const Ogre::Vector2& position);
139
145 const Ogre::Vector2& Get2DScroll() const;
146
156 const Ogre::Vector3 ProjectPointToScreen(const Ogre::Vector3& point);
157
163 Ogre::Camera* GetCurrentCamera();
164
170 Ogre::Viewport* getViewport();
171
179 void EnableWireFrame(bool enable);
180
194 void ScriptSetCamera(
195 const int x, const int y, const int z, const int d_x, const int d_y, const int d_z
196 );
197
198 private:
199
205 void InitCommands();
206
210 void UpdateField() override;
211
215 void UpdateBattle() override;
216
220 void UpdateWorld() override;
221
225 Ogre::Camera *camera_;
226
230 Ogre::Viewport *viewport_;
231
235 Ogre::Vector3 position_initial_;
236
240 Ogre::Quaternion orientation_initial_;
241
245 Ogre::Vector3 position_backup_;
246
250 Ogre::Quaternion orientation_backup_;
251
259
264
268 Ogre::Vector3 d2_position_;
269
273 Ogre::Quaternion d2_orientation_;
274
278 Ogre::Radian d2_fov_;
279
283 Ogre::Vector2 d2_scroll_;
284};
285
float * position
Used to keep track of the skeleton and it's bones positions.
Definition: DrawSkeleton.cpp:33
The camera manager.
Definition: CameraManager.h:26
Ogre::Quaternion orientation_backup_
A backup of the field or world camera orientation for when the battle camera is active.
Definition: CameraManager.h:250
void UpdateDebug() override
Updates debug information.
Definition: CameraManager.cpp:121
bool camera_free_rotate_
Flag to indicate the free camera has rotated.
Definition: CameraManager.h:263
Ogre::Vector3 d2_position_
Camera position.
Definition: CameraManager.h:268
Ogre::Quaternion d2_orientation_
Camera orientation.
Definition: CameraManager.h:273
void ClearBattle() override
Clears all battle information in the camera manager.
Definition: CameraManager.cpp:125
void ClearWorld() override
Clears all world map information in the camera manager.
Definition: CameraManager.cpp:127
void UpdateField() override
Updates while the camera is in the field.
Definition: CameraManager.cpp:300
void OnResize() override
Trigered when the viewport is resized.
Definition: CameraManager.cpp:115
void ClearField() override
Clears all field information in the camera manager.
Definition: CameraManager.cpp:123
void UpdateBattle() override
Updates while the camera is in battle.
Definition: CameraManager.cpp:302
Ogre::Vector2 d2_scroll_
The camera scroll.
Definition: CameraManager.h:283
const Ogre::Vector3 ProjectPointToScreen(const Ogre::Vector3 &point)
Calculates the position of a point in screen.
Definition: CameraManager.cpp:258
const Ogre::Vector2 & Get2DScroll() const
Retrieves the camera position.
Definition: CameraManager.cpp:256
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.
Definition: CameraManager.cpp:284
void StartBattleCamera(const Ogre::Vector3 position, const Ogre::Vector3 orientation)
Starts the battle camera.
Definition: CameraManager.cpp:174
Ogre::Camera * GetCurrentCamera()
Retrieves the camera.
Definition: CameraManager.cpp:270
void InitCommands()
Initializes the camera parameters.
Definition: CameraManagerCommands.h:38
virtual ~CameraManager()
Destructor.
Definition: CameraManager.cpp:68
Ogre::Viewport * viewport_
The viewport.
Definition: CameraManager.h:230
void UpdateWorld() override
Updates while the camera is in the world map.
Definition: CameraManager.cpp:304
CameraManager()
Constructor.
Definition: CameraManager.cpp:35
void Set2DScroll(const Ogre::Vector2 &position)
Sets the camera scroll.
Definition: CameraManager.cpp:238
void Set2DCamera(const Ogre::Vector3 position, const Ogre::Quaternion orientation, const Ogre::Radian fov)
Sets the camera properties.
Definition: CameraManager.cpp:157
Ogre::Viewport * getViewport()
Retrieves the viewport.
Definition: CameraManager.cpp:272
Ogre::Vector3 position_backup_
A backup of the field or world camera position for when the battle camera is activated.
Definition: CameraManager.h:245
Ogre::Quaternion orientation_initial_
The initial orientation of the camera, saved when created.
Definition: CameraManager.h:240
Ogre::Vector3 position_initial_
The initial position of the camera, saved when created.
Definition: CameraManager.h:235
void EnableWireFrame(bool enable)
Enables or disables the camera wireframe.
Definition: CameraManager.cpp:274
void SetCameraFree(const bool enable)
Enables or disables the free camera.
Definition: CameraManager.cpp:129
Ogre::Camera * camera_
The camera.
Definition: CameraManager.h:225
bool camera_free_
Flag to indicate a free camera.
Definition: CameraManager.h:258
void EndBattleCamera()
Ends the battle camera.
Definition: CameraManager.cpp:221
Ogre::Radian d2_fov_
The field of view.
Definition: CameraManager.h:278
void Input(const VGears::Event &event) override
Handles camera actions.
Definition: CameraManager.cpp:70
A base manager.
Definition: Manager.h:24
An input event.
Definition: Event.h:84