mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:29:50 +00:00
Add support for bird's eye camera view
A new hotkey "hotkey.camera.togglebirdseyeview" allows to switch between regular view and bird's eye (top-down) view. When bird's eye view gets toggled on, the camera moves above the scene; When bird's eye view gets toggled off, the camera moves back to the default vertical rotation angle; When bird's eye view is on, vertical rotation is disallowed.
This commit is contained in:
committed by
Ralph Sennhauser
parent
617e438fad
commit
cb2717faba
@@ -248,6 +248,7 @@ reset = "R" ; Reset camera rotation to default
|
||||
follow = "" ; Follow the first unit in the selection
|
||||
rallypointfocus = "" ; Focus the camera on the rally point of the selected building
|
||||
lastattackfocus = "Space" ; Focus the camera on the last notified attack
|
||||
togglebirdseyeview = "" ; Toggle bird's eye view
|
||||
zoom.in = Plus, NumPlus ; Zoom camera in (continuous control)
|
||||
zoom.out = Minus, NumMinus ; Zoom camera out (continuous control)
|
||||
zoom.wheel.in = WheelUp ; Zoom camera in (stepped control)
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
{ "nick": "mattlott", "name": "Matt Lott" },
|
||||
{ "nick": "maveric", "name": "Anton Protko" },
|
||||
{ "nick": "mbusy", "name": "Maxime Busy" },
|
||||
{ "nick": "Mentula" },
|
||||
{ "nick": "Micnasty", "name": "Travis Gorkin" },
|
||||
{ "name": "Mikołaj \"Bajter\" Korcz" },
|
||||
{ "nick": "mimo" },
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
"name": "Focus on last attack notification",
|
||||
"desc": "Focus the camera on the position of the last attack notification."
|
||||
},
|
||||
"camera.togglebirdseyeview": {
|
||||
"name": "Toggle bird's eye view",
|
||||
"desc": "Toggle between regular and bird's eye (top-down) views."
|
||||
},
|
||||
"camera.zoom.in": {
|
||||
"name": "Zoom in",
|
||||
"desc": "Zoom camera in."
|
||||
|
||||
@@ -54,6 +54,7 @@ CCameraController::CCameraController(CCamera& camera)
|
||||
m_ConstrainCamera(true),
|
||||
m_FollowEntity(INVALID_ENTITY),
|
||||
m_FollowFirstPerson(false),
|
||||
m_BirdsEyeView(false),
|
||||
|
||||
// Dummy values (these will be filled in by the config file)
|
||||
m_ViewScrollSpeed(0),
|
||||
@@ -179,9 +180,9 @@ void CCameraController::Update(const float deltaRealTime)
|
||||
m_RotateY.AddSmoothly(m_ViewRotateYSpeed * deltaRealTime);
|
||||
if (HotkeyIsPressed("camera.rotate.ccw"))
|
||||
m_RotateY.AddSmoothly(-m_ViewRotateYSpeed * deltaRealTime);
|
||||
if (HotkeyIsPressed("camera.rotate.up"))
|
||||
if (HotkeyIsPressed("camera.rotate.up") && !m_BirdsEyeView)
|
||||
m_RotateX.AddSmoothly(-m_ViewRotateXSpeed * deltaRealTime);
|
||||
if (HotkeyIsPressed("camera.rotate.down"))
|
||||
if (HotkeyIsPressed("camera.rotate.down") && !m_BirdsEyeView)
|
||||
m_RotateX.AddSmoothly(m_ViewRotateXSpeed * deltaRealTime);
|
||||
|
||||
float moveRightward = 0.f;
|
||||
@@ -297,7 +298,12 @@ void CCameraController::Update(const float deltaRealTime)
|
||||
}
|
||||
|
||||
if (m_ConstrainCamera)
|
||||
m_RotateX.ClampSmoothly(DEGTORAD(m_ViewRotateXMin), DEGTORAD(m_ViewRotateXMax));
|
||||
{
|
||||
if (m_BirdsEyeView)
|
||||
m_RotateX.ClampSmoothly(M_PI / 2, M_PI / 2);
|
||||
else
|
||||
m_RotateX.ClampSmoothly(DEGTORAD(m_ViewRotateXMin), DEGTORAD(m_ViewRotateXMax));
|
||||
}
|
||||
|
||||
FocusHeight(true);
|
||||
|
||||
@@ -462,6 +468,9 @@ void CCameraController::SetCamera(const CVector3D& pos, float rotX, float rotY,
|
||||
|
||||
// Break out of following mode so the camera really moves to the target
|
||||
m_FollowEntity = INVALID_ENTITY;
|
||||
|
||||
// Leave bird's eye view
|
||||
m_BirdsEyeView = false;
|
||||
}
|
||||
|
||||
void CCameraController::MoveCameraTarget(const CVector3D& target)
|
||||
@@ -508,6 +517,9 @@ void CCameraController::ResetCameraTarget(const CVector3D& target)
|
||||
|
||||
// Break out of following mode so the camera really moves to the target
|
||||
m_FollowEntity = INVALID_ENTITY;
|
||||
|
||||
// Leave bird's eye view
|
||||
m_BirdsEyeView = false;
|
||||
}
|
||||
|
||||
void CCameraController::FollowEntity(entity_id_t entity, bool firstPerson)
|
||||
@@ -542,6 +554,16 @@ void CCameraController::ResetCameraAngleZoom()
|
||||
// Reset orientations to default
|
||||
m_RotateX.SetValueSmoothly(DEGTORAD(m_ViewRotateXDefault));
|
||||
m_RotateY.SetValueSmoothly(DEGTORAD(m_ViewRotateYDefault));
|
||||
|
||||
// Leave bird's eye view
|
||||
m_BirdsEyeView = false;
|
||||
}
|
||||
|
||||
void CCameraController::ToggleBirdsEyeView()
|
||||
{
|
||||
m_BirdsEyeView = !m_BirdsEyeView;
|
||||
float angle = m_BirdsEyeView ? M_PI / 2 : DEGTORAD(m_ViewRotateXDefault);
|
||||
m_RotateX.SetValueSmoothly(angle);
|
||||
}
|
||||
|
||||
void CCameraController::SetupCameraMatrixSmooth(CMatrix3D* orientation)
|
||||
@@ -640,6 +662,11 @@ InReaction CCameraController::HandleEvent(const SDL_Event_* ev)
|
||||
ResetCameraAngleZoom();
|
||||
return IN_HANDLED;
|
||||
}
|
||||
else if (hotkey == "camera.togglebirdseyeview")
|
||||
{
|
||||
ToggleBirdsEyeView();
|
||||
return IN_HANDLED;
|
||||
}
|
||||
return IN_PASS;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
private:
|
||||
CVector3D GetSmoothPivot(CCamera &camera) const;
|
||||
void ResetCameraAngleZoom();
|
||||
void ToggleBirdsEyeView();
|
||||
void SetupCameraMatrixSmooth(CMatrix3D* orientation);
|
||||
void SetupCameraMatrixSmoothRot(CMatrix3D* orientation);
|
||||
void SetupCameraMatrixNonSmooth(CMatrix3D* orientation);
|
||||
@@ -86,6 +87,11 @@ private:
|
||||
*/
|
||||
bool m_FollowFirstPerson;
|
||||
|
||||
/**
|
||||
* Whether the camera is in bird's eye view mode.
|
||||
*/
|
||||
bool m_BirdsEyeView;
|
||||
|
||||
// Settings
|
||||
float m_ViewScrollSpeed;
|
||||
float m_ViewScrollSpeedModifier;
|
||||
|
||||
Reference in New Issue
Block a user