RigsofRods
Soft-body Physics Simulation
CameraManager.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2017-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #pragma once
23 
24 #include "Application.h"
25 
26 #include <OIS.h>
27 #include <Ogre.h>
28 
29 namespace RoR {
30 
33 
36 
38 {
39 public:
40 
41  CameraManager();
43 
45  {
56  };
57 
58  void UpdateInputEvents(float dt);
59 
60  bool hasActiveBehavior();
61 
63  Ogre::SceneNode* GetCameraNode() { return m_camera_node; }
64  Ogre::Camera* GetCamera() { return m_camera; }
65 
66  void NotifyContextChange();
67  void NotifyVehicleChanged(ActorPtr new_vehicle);
68 
72 
73  bool handleMouseMoved();
74  bool handleMousePressed();
75 
76  void ResetAllBehaviors();
77  void ReCreateCameraNode();
78 
79  void switchToNextBehavior();
81 
82 protected:
83 
84  void switchBehavior(CameraBehaviors new_behavior);
85  void SwitchBehaviorOnVehicleChange(CameraBehaviors new_behavior, ActorPtr new_vehicle);
86  void ToggleCameraBehavior(CameraBehaviors new_behavior);
87  void ActivateNewBehavior(CameraBehaviors new_behavior, bool reset);
88  void UpdateCurrentBehavior();
89  void ResetCurrentBehavior();
104  void CreateCameraNode();
105 
106  Ogre::Camera* m_camera;
107  Ogre::SceneNode* m_camera_node;
108 
112  // Old `CameraContext`
113  ActorPtr m_cct_player_actor; // TODO: duplicates `GameContext::m_player_actor`
114  Ogre::Degree m_cct_rot_scale;
115  Ogre::Real m_cct_dt;
116  Ogre::Real m_cct_trans_scale;
117  float m_cct_sim_speed; // TODO: duplicates `ActorManager::m_simulation_speed`
118  // Old `CameraBehaviorOrbit` attributes
119  Ogre::Radian m_cam_rot_x;
120  Ogre::Radian m_cam_rot_y;
122  Ogre::Radian m_cam_target_pitch;
123  float m_cam_dist;
126  float m_cam_ratio;
127  Ogre::Vector3 m_cam_look_at;
129  Ogre::Vector3 m_cam_look_at_last;
130  Ogre::Vector3 m_cam_look_at_smooth;
132  // Static cam attributes
136  Ogre::Vector3 m_staticcam_look_at;
137  Ogre::Vector3 m_staticcam_position;
139  // Character cam attributes
141  // Spline cam attributes
142  Ogre::ManualObject* m_splinecam_mo;
143  Ogre::SimpleSpline* m_splinecam_spline;
148  std::deque<node_t*> m_splinecam_spline_nodes;
150 };
151 
154 
155 } // namespace RoR
RoR::CameraManager::UpdateInputEvents
void UpdateInputEvents(float dt)
Definition: CameraManager.cpp:242
RoR::CameraManager::CAMERA_BEHAVIOR_INVALID
@ CAMERA_BEHAVIOR_INVALID
Definition: CameraManager.h:55
RoR::CameraManager::hasActiveBehavior
bool hasActiveBehavior()
Definition: CameraManager.cpp:524
RoR::CameraManager::UpdateCameraBehaviorVehicle
void UpdateCameraBehaviorVehicle()
Definition: CameraManager.cpp:1067
RoR::CameraManager::m_cam_target_direction
Ogre::Radian m_cam_target_direction
Definition: CameraManager.h:121
RoR::CameraManager::m_cam_look_at_smooth_last
Ogre::Vector3 m_cam_look_at_smooth_last
Definition: CameraManager.h:131
RoR::CameraManager::m_staticcam_update_timer
Ogre::Timer m_staticcam_update_timer
Definition: CameraManager.h:138
RoR::CameraManager
Definition: CameraManager.h:37
RoR::CameraManager::m_cam_dist_min
float m_cam_dist_min
Definition: CameraManager.h:124
RoR::CameraManager::UpdateCameraBehaviorFree
void UpdateCameraBehaviorFree()
Definition: CameraManager.cpp:984
RoR::CameraManager::m_cam_look_at_last
Ogre::Vector3 m_cam_look_at_last
Definition: CameraManager.h:129
RoR::CameraManager::CameraBehaviorOrbitMouseMoved
bool CameraBehaviorOrbitMouseMoved()
Definition: CameraManager.cpp:947
RoR::CameraManager::m_current_behavior
CameraBehaviors m_current_behavior
Definition: CameraManager.h:109
RoR::CameraManager::m_staticcam_look_at
Ogre::Vector3 m_staticcam_look_at
Definition: CameraManager.h:136
RoR::CameraManager::CAMERA_BEHAVIOR_FREE
@ CAMERA_BEHAVIOR_FREE
Definition: CameraManager.h:52
RoR::CameraManager::NotifyVehicleChanged
void NotifyVehicleChanged(ActorPtr new_vehicle)
Definition: CameraManager.cpp:633
RoR::CameraManager::CAMERA_BEHAVIOR_ISOMETRIC
@ CAMERA_BEHAVIOR_ISOMETRIC
Definition: CameraManager.h:54
RoR::CameraManager::DeactivateCurrentBehavior
void DeactivateCurrentBehavior()
Definition: CameraManager.cpp:468
RoR::CameraManager::CameraBehaviors
CameraBehaviors
Definition: CameraManager.h:44
RoR::CameraManager::ActivateNewBehavior
void ActivateNewBehavior(CameraBehaviors new_behavior, bool reset)
Definition: CameraManager.cpp:375
RoR::CameraManager::UpdateCurrentBehavior
void UpdateCurrentBehavior()
Definition: CameraManager.cpp:186
RoR::CameraManager::CAMERA_BEHAVIOR_END
@ CAMERA_BEHAVIOR_END
Definition: CameraManager.h:51
RoR::CameraManager::m_cct_player_actor
ActorPtr m_cct_player_actor
Definition: CameraManager.h:113
RoR::CameraManager::GetCameraNode
Ogre::SceneNode * GetCameraNode()
Definition: CameraManager.h:63
RoR::CameraManager::UpdateCameraBehaviorFixed
void UpdateCameraBehaviorFixed()
Definition: CameraManager.cpp:1058
RoR::CameraManager::m_cam_dist_max
float m_cam_dist_max
Definition: CameraManager.h:125
RefCountingObjectPtr< Actor >
RoR::CameraManager::m_cam_before_toggled
CameraBehaviors m_cam_before_toggled
Toggled modes (FREE, FREEFIX) remember original state.
Definition: CameraManager.h:110
RoR::CameraManager::m_splinecam_spline_pos
Ogre::Real m_splinecam_spline_pos
Definition: CameraManager.h:145
RoR::CameraManager::m_cam_look_at
Ogre::Vector3 m_cam_look_at
Definition: CameraManager.h:127
RoR::CameraManager::CameraBehaviorOrbitUpdate
void CameraBehaviorOrbitUpdate()
Definition: CameraManager.cpp:822
RoR::CameraManager::m_staticcam_fov_exponent
float m_staticcam_fov_exponent
Definition: CameraManager.h:134
RoR::CameraManager::NotifyContextChange
void NotifyContextChange()
Definition: CameraManager.cpp:617
RoR::CameraManager::m_splinecam_spline_nodes
std::deque< node_t * > m_splinecam_spline_nodes
Definition: CameraManager.h:148
RoR::CameraManager::m_cct_trans_scale
Ogre::Real m_cct_trans_scale
Definition: CameraManager.h:116
RoR::CameraManager::GetCurrentBehavior
CameraBehaviors GetCurrentBehavior() const
Definition: CameraManager.h:62
RoR::CameraManager::CAMERA_BEHAVIOR_STATIC
@ CAMERA_BEHAVIOR_STATIC
Definition: CameraManager.h:47
RoR::CameraManager::m_staticcam_force_update
bool m_staticcam_force_update
Definition: CameraManager.h:133
RoR::CameraManager::GetCamera
Ogre::Camera * GetCamera()
Definition: CameraManager.h:64
RoR::CameraManager::~CameraManager
~CameraManager()
Definition: CameraManager.cpp:126
RoR::CameraManager::ReCreateCameraNode
void ReCreateCameraNode()
Needed since we call Ogre::SceneManager::ClearScene() after end of sim. session.
Definition: CameraManager.cpp:142
RoR::CameraManager::m_cct_dt
Ogre::Real m_cct_dt
Definition: CameraManager.h:115
RoR::CameraManager::m_staticcam_position
Ogre::Vector3 m_staticcam_position
Definition: CameraManager.h:137
RoR::CameraManager::CameraBehaviorVehicleMousePressed
bool CameraBehaviorVehicleMousePressed()
Definition: CameraManager.cpp:1096
RoR::CameraManager::CAMERA_BEHAVIOR_VEHICLE_SPLINE
@ CAMERA_BEHAVIOR_VEHICLE_SPLINE
Definition: CameraManager.h:49
RoR::CameraManager::CAMERA_BEHAVIOR_CHARACTER
@ CAMERA_BEHAVIOR_CHARACTER
Definition: CameraManager.h:46
RoR::CameraManager::m_splinecam_num_linked_beams
unsigned int m_splinecam_num_linked_beams
Definition: CameraManager.h:149
RoR::CameraManager::ResetAllBehaviors
void ResetAllBehaviors()
Definition: CameraManager.cpp:529
RoR::CameraManager::m_splinecam_spline
Ogre::SimpleSpline * m_splinecam_spline
Definition: CameraManager.h:143
RoR::CameraManager::CAMERA_BEHAVIOR_VEHICLE
@ CAMERA_BEHAVIOR_VEHICLE
Definition: CameraManager.h:48
Application.h
Central state/object manager and communications hub.
RoR::CameraManager::CAMERA_BEHAVIOR_FIXED
@ CAMERA_BEHAVIOR_FIXED
Definition: CameraManager.h:53
RoR::CameraManager::CameraBehaviorStaticMouseMoved
bool CameraBehaviorStaticMouseMoved()
Definition: CameraManager.cpp:804
RoR::CameraManager::m_camera
Ogre::Camera * m_camera
Definition: CameraManager.h:106
RoR::CameraManager::CameraBehaviorVehicleReset
void CameraBehaviorVehicleReset()
Definition: CameraManager.cpp:1088
RoR::CameraManager::ResetCurrentBehavior
void ResetCurrentBehavior()
Definition: CameraManager.cpp:326
RoR::CameraManager::m_splinecam_mo
Ogre::ManualObject * m_splinecam_mo
Definition: CameraManager.h:142
RoR::CameraManager::m_cam_rot_y
Ogre::Radian m_cam_rot_y
Definition: CameraManager.h:120
RoR::CameraManager::CameraManager
CameraManager()
Definition: CameraManager.cpp:83
RoR::CameraManager::m_charactercam_is_3rdperson
bool m_charactercam_is_3rdperson
Definition: CameraManager.h:140
RoR::CameraManager::m_cct_sim_speed
float m_cct_sim_speed
Definition: CameraManager.h:117
RoR::CameraManager::m_camera_node
Ogre::SceneNode * m_camera_node
Definition: CameraManager.h:107
RoR::CameraManager::handleMouseMoved
bool handleMouseMoved()
Definition: CameraManager.cpp:534
RoR::CameraManager::CameraBehaviorVehicleSplineMouseMoved
bool CameraBehaviorVehicleSplineMouseMoved()
Definition: CameraManager.cpp:1194
RoR::CameraManager::switchBehavior
void switchBehavior(CameraBehaviors new_behavior)
Definition: CameraManager.cpp:485
RoR::CameraManager::m_cam_limit_movement
bool m_cam_limit_movement
Definition: CameraManager.h:128
RoR::CameraManager::m_cam_ratio
float m_cam_ratio
Definition: CameraManager.h:126
RoR::CameraManager::m_staticcam_previous_fov
Ogre::Radian m_staticcam_previous_fov
Definition: CameraManager.h:135
RoR::CameraManager::CameraBehaviorVehicleSplineUpdate
void CameraBehaviorVehicleSplineUpdate()
Definition: CameraManager.cpp:1137
RoR::CameraManager::m_cam_target_pitch
Ogre::Radian m_cam_target_pitch
Definition: CameraManager.h:122
RoR::CameraManager::SwitchBehaviorOnVehicleChange
void SwitchBehaviorOnVehicleChange(CameraBehaviors new_behavior, ActorPtr new_vehicle)
Definition: CameraManager.cpp:510
RoR::CameraManager::m_cam_rot_x
Ogre::Radian m_cam_rot_x
Definition: CameraManager.h:119
RoR::CameraManager::ToggleCameraBehavior
void ToggleCameraBehavior(CameraBehaviors new_behavior)
Only accepts FREE and FREEFIX modes.
Definition: CameraManager.cpp:672
RoR::CameraManager::m_cam_look_at_smooth
Ogre::Vector3 m_cam_look_at_smooth
Definition: CameraManager.h:130
RoR::CameraManager::CameraBehaviorVehicleSplineUpdateSpline
void CameraBehaviorVehicleSplineUpdateSpline()
Definition: CameraManager.cpp:1358
RoR::CameraManager::UpdateCameraBehaviorStatic
void UpdateCameraBehaviorStatic()
Definition: CameraManager.cpp:703
RoR::CameraManager::EvaluateSwitchBehavior
bool EvaluateSwitchBehavior()
Definition: CameraManager.cpp:148
RoR::CameraManager::m_cam_dist
float m_cam_dist
Definition: CameraManager.h:123
RoR::CameraManager::m_splinecam_spline_len
Ogre::Real m_splinecam_spline_len
Definition: CameraManager.h:144
RoR::CameraManager::CreateCameraNode
void CreateCameraNode()
Definition: CameraManager.cpp:134
RoR::CameraManager::m_prev_toggled_cam
CameraBehaviors m_prev_toggled_cam
Switching toggled modes (FREE, FREEFIX) keeps 1-slot history.
Definition: CameraManager.h:111
RoR::CameraManager::CameraBehaviorVehicleSplineCreateSpline
void CameraBehaviorVehicleSplineCreateSpline()
Definition: CameraManager.cpp:1261
RoR::CameraManager::CameraBehaviorVehicleSplineUpdateSplineDisplay
void CameraBehaviorVehicleSplineUpdateSplineDisplay()
Definition: CameraManager.cpp:1366
RoR::CameraManager::CameraBehaviorVehicleSplineReset
void CameraBehaviorVehicleSplineReset()
Definition: CameraManager.cpp:1252
RoR::CameraManager::CAMERA_BEHAVIOR_VEHICLE_CINECAM
@ CAMERA_BEHAVIOR_VEHICLE_CINECAM
Definition: CameraManager.h:50
RoR
Definition: AppContext.h:36
RoR::CameraManager::handleMousePressed
bool handleMousePressed()
Definition: CameraManager.cpp:591
RoR::CameraManager::m_splinecam_spline_closed
bool m_splinecam_spline_closed
Definition: CameraManager.h:146
RoR::CameraManager::m_splinecam_auto_tracking
bool m_splinecam_auto_tracking
Definition: CameraManager.h:147
RoR::CameraManager::m_cct_rot_scale
Ogre::Degree m_cct_rot_scale
Definition: CameraManager.h:114
RoR::CameraManager::switchToNextBehavior
void switchToNextBehavior()
Definition: CameraManager.cpp:320
RoR::CameraManager::CameraBehaviorOrbitReset
void CameraBehaviorOrbitReset()
Definition: CameraManager.cpp:974