# Support '[', ']' keys for camera rotation in scenario editor
This was SVN commit r7460.
This commit is contained in:
parent
4570a6af72
commit
b6a9e0e9b7
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -84,6 +84,8 @@ private:
|
||||
case WXK_RIGHT: dir = eScrollConstantDir::RIGHT; break;
|
||||
case WXK_UP: dir = eScrollConstantDir::FORWARDS; break;
|
||||
case WXK_DOWN: dir = eScrollConstantDir::BACKWARDS; break;
|
||||
case ']': dir = eScrollConstantDir::CLOCKWISE; break;
|
||||
case '[': dir = eScrollConstantDir::ANTICLOCKWISE; break;
|
||||
case WXK_SHIFT: case WXK_CONTROL: dir = -1; break;
|
||||
default: return false;
|
||||
}
|
||||
@ -96,6 +98,8 @@ private:
|
||||
if (wxGetKeyState(WXK_RIGHT)) POST_MESSAGE(ScrollConstant, (eRenderView::GAME, eScrollConstantDir::RIGHT, speed));
|
||||
if (wxGetKeyState(WXK_UP)) POST_MESSAGE(ScrollConstant, (eRenderView::GAME, eScrollConstantDir::FORWARDS, speed));
|
||||
if (wxGetKeyState(WXK_DOWN)) POST_MESSAGE(ScrollConstant, (eRenderView::GAME, eScrollConstantDir::BACKWARDS, speed));
|
||||
if (wxGetKeyState((wxKeyCode)']')) POST_MESSAGE(ScrollConstant, (eRenderView::GAME, eScrollConstantDir::CLOCKWISE, speed));
|
||||
if (wxGetKeyState((wxKeyCode)'[')) POST_MESSAGE(ScrollConstant, (eRenderView::GAME, eScrollConstantDir::ANTICLOCKWISE, speed));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ struct GameLoopState
|
||||
|
||||
struct Input
|
||||
{
|
||||
float scrollSpeed[4]; // [fwd, bwd, left, right]. 0.0f for disabled.
|
||||
float scrollSpeed[6]; // [fwd, bwd, left, right, cw-rotation, ccw-rotation]. 0.0f for disabled.
|
||||
float zoomDelta;
|
||||
} input;
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ MESSAGEHANDLER(ScrollConstant)
|
||||
if (g_Game->GetView()->GetCinema()->IsPlaying())
|
||||
return;
|
||||
|
||||
if (msg->dir < 0 || msg->dir > 3)
|
||||
if (msg->dir < 0 || msg->dir > 5)
|
||||
{
|
||||
debug_warn(L"ScrollConstant: invalid direction");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -22,8 +22,25 @@
|
||||
#include "ps/Game.h"
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "maths/Quaternion.h"
|
||||
|
||||
static float g_ViewZoomSmoothness = 0.02f; // TODO: configurable, like GameView
|
||||
static float g_ViewZoomSmoothness = 0.02f;
|
||||
static float g_ViewRotateScale = 0.02f;
|
||||
|
||||
static void Rotate(CCamera& camera, float speed)
|
||||
{
|
||||
CVector3D upwards(0.0f, 1.0f, 0.0f);
|
||||
CVector3D origin = camera.m_Orientation.GetTranslation();
|
||||
CVector3D pivot = camera.GetFocus();
|
||||
CVector3D delta = origin - pivot;
|
||||
|
||||
CQuaternion r;
|
||||
r.FromAxisAngle(upwards, speed);
|
||||
delta = r.Rotate(delta);
|
||||
camera.m_Orientation.Translate(-origin);
|
||||
camera.m_Orientation.Rotate(r);
|
||||
camera.m_Orientation.Translate(pivot + delta);
|
||||
}
|
||||
|
||||
bool InputProcessor::ProcessInput(GameLoopState* state)
|
||||
{
|
||||
@ -72,6 +89,18 @@ bool InputProcessor::ProcessInput(GameLoopState* state)
|
||||
moved = true;
|
||||
}
|
||||
|
||||
if (state->input.scrollSpeed[4] != 0.0f)
|
||||
{
|
||||
Rotate(*camera, input.scrollSpeed[4] * state->frameLength * g_ViewRotateScale);
|
||||
moved = true;
|
||||
}
|
||||
|
||||
if (state->input.scrollSpeed[5] != 0.0f)
|
||||
{
|
||||
Rotate(*camera, -input.scrollSpeed[5] * state->frameLength * g_ViewRotateScale);
|
||||
moved = true;
|
||||
}
|
||||
|
||||
if (state->input.zoomDelta != 0.0f)
|
||||
{
|
||||
float zoom_proportion = powf(g_ViewZoomSmoothness, state->frameLength);
|
||||
|
@ -248,8 +248,8 @@ QUERY(Exit,,); // no inputs nor outputs
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct eScrollConstantDir { enum { FORWARDS, BACKWARDS, LEFT, RIGHT }; };
|
||||
MESSAGE(ScrollConstant,
|
||||
struct eScrollConstantDir { enum { FORWARDS, BACKWARDS, LEFT, RIGHT, CLOCKWISE, ANTICLOCKWISE }; };
|
||||
MESSAGE(ScrollConstant, // set a constant scrolling(/rotation) rate
|
||||
((int, view)) // eRenderView
|
||||
((int, dir)) // eScrollConstantDir
|
||||
((float, speed)) // set speed 0.0f to stop scrolling
|
||||
|
Loading…
Reference in New Issue
Block a user