Skip to content

Commit

Permalink
Added camera controls LOOK_LEFT+LOOK_RIGHT
Browse files Browse the repository at this point in the history
Renamed LOOKBACK to LOOK_BACK
Changed toggle order: instead of resetting to front view first and then toggling the direction, the direction is toggled immediatelly and only a second press resets view to front.

Note: LOOK_LEFT+LOOK_RIGHT have no default bindings because all numpad keys are taken.
  • Loading branch information
ohlidalp committed Jan 28, 2023
1 parent 4fe0a96 commit aa798d9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
17 changes: 12 additions & 5 deletions source/main/gfx/camera/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,19 +813,26 @@ bool CameraManager::CameraBehaviorStaticMouseMoved(const OIS::MouseEvent& _arg)
return false;
}

void CameraManager::CameraBehaviorOrbitUpdate()
void CameraManager::CameraBehaviorOrbitToggleAngle(events ev, Ogre::Degree angle)
{
if (RoR::App::GetInputEngine()->getEventBoolValueBounce(EV_CAMERA_LOOKBACK))
if (RoR::App::GetInputEngine()->getEventBoolValueBounce(ev))
{
if (m_cam_rot_x > Degree(0))
if (m_cam_rot_x != angle)
{
m_cam_rot_x = Degree(0);
m_cam_rot_x = angle;
}
else
{
m_cam_rot_x = Degree(180);
m_cam_rot_x = Degree(0);
}
}
}

void CameraManager::CameraBehaviorOrbitUpdate()
{
this->CameraBehaviorOrbitToggleAngle(EV_CAMERA_LOOK_BACK, Degree(180));
this->CameraBehaviorOrbitToggleAngle(EV_CAMERA_LOOK_LEFT, Degree(270));
this->CameraBehaviorOrbitToggleAngle(EV_CAMERA_LOOK_RIGHT, Degree(90));

m_cam_rot_x += (RoR::App::GetInputEngine()->getEventValue(EV_CAMERA_ROTATE_RIGHT) - RoR::App::GetInputEngine()->getEventValue(EV_CAMERA_ROTATE_LEFT)) * m_cct_rot_scale;
m_cam_rot_y += (RoR::App::GetInputEngine()->getEventValue(EV_CAMERA_ROTATE_UP) - RoR::App::GetInputEngine()->getEventValue(EV_CAMERA_ROTATE_DOWN)) * m_cct_rot_scale;
Expand Down
2 changes: 2 additions & 0 deletions source/main/gfx/camera/CameraManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#pragma once

#include "Application.h"
#include "InputEngine.h"

#include <OIS.h>
#include <Ogre.h>
Expand Down Expand Up @@ -101,6 +102,7 @@ class CameraManager
void CameraBehaviorOrbitReset();
bool CameraBehaviorOrbitMouseMoved(const OIS::MouseEvent& _arg);
void CameraBehaviorOrbitUpdate();
void CameraBehaviorOrbitToggleAngle(RoR::events ev, Ogre::Degree angle);

Ogre::Camera* m_camera;
Ogre::SceneNode* m_camera_node;
Expand Down
4 changes: 3 additions & 1 deletion source/main/scripting/bindings/InputEngineAngelscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ void registerEventTypeEnum(asIScriptEngine* engine)
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_DOWN", EV_CAMERA_DOWN ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_FREE_MODE", EV_CAMERA_FREE_MODE ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_FREE_MODE_FIX", EV_CAMERA_FREE_MODE_FIX ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_LOOKBACK", EV_CAMERA_LOOKBACK ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_LOOK_BACK", EV_CAMERA_LOOK_BACK ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_LOOK_LEFT", EV_CAMERA_LOOK_LEFT ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_LOOK_RIGHT", EV_CAMERA_LOOK_RIGHT ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_RESET", EV_CAMERA_RESET ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_ROTATE_DOWN", EV_CAMERA_ROTATE_DOWN ); ROR_ASSERT(result >= 0);
result = engine->RegisterEnumValue("inputEvents", "EV_CAMERA_ROTATE_LEFT", EV_CAMERA_ROTATE_LEFT ); ROR_ASSERT(result >= 0);
Expand Down
4 changes: 3 additions & 1 deletion source/main/utils/InputEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ InputEvent eventInfo[] = {

// Camera
{"CAMERA_CHANGE", EV_CAMERA_CHANGE, "Keyboard EXPL+C", _LC("InputEvent", "change camera mode")},
{"CAMERA_LOOKBACK", EV_CAMERA_LOOKBACK, "Keyboard NUMPAD1", _LC("InputEvent", "look back (toggles between normal and lookback)")},
{"CAMERA_LOOK_BACK", EV_CAMERA_LOOK_BACK, "Keyboard NUMPAD1", _LC("InputEvent", "look back (toggles between normal and lookback)")},
{"CAMERA_LOOK_LEFT", EV_CAMERA_LOOK_LEFT, "", _LC("InputEvent", "look left (toggles between normal and lookleft)")},
{"CAMERA_LOOK_RIGHT", EV_CAMERA_LOOK_RIGHT, "", _LC("InputEvent", "look right (toggles between normal and lookright)")},
{"CAMERA_RESET", EV_CAMERA_RESET, "Keyboard NUMPAD5", _LC("InputEvent", "reset the camera position")},
{"CAMERA_ROTATE_DOWN", EV_CAMERA_ROTATE_DOWN, "Keyboard NUMPAD2", _LC("InputEvent", "rotate camera down")},
{"CAMERA_ROTATE_LEFT", EV_CAMERA_ROTATE_LEFT, "Keyboard NUMPAD4", _LC("InputEvent", "rotate camera left")},
Expand Down
6 changes: 4 additions & 2 deletions source/main/utils/InputEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ enum events
EV_CAMERA_DOWN,
EV_CAMERA_FREE_MODE,
EV_CAMERA_FREE_MODE_FIX,
EV_CAMERA_LOOKBACK, //!< look back (toggles between normal and lookback)
EV_CAMERA_RESET, //!< reset the camera position
EV_CAMERA_LOOK_BACK, //!< look back (toggles between normal and lookback)
EV_CAMERA_LOOK_LEFT, //!< look left (toggles between normal and lookleft)
EV_CAMERA_LOOK_RIGHT, //!< look right (toggles between normal and lookright)
EV_CAMERA_RESET, //!< reset the camera position/rotation
EV_CAMERA_ROTATE_DOWN, //!< rotate camera down
EV_CAMERA_ROTATE_LEFT, //!< rotate camera left
EV_CAMERA_ROTATE_RIGHT, //!< rotate camera right
Expand Down

0 comments on commit aa798d9

Please sign in to comment.