mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:53:51 +00:00
moving the camera with A and D keys
This commit is contained in:
parent
af50575259
commit
b6ae521aa5
2 changed files with 26 additions and 3 deletions
|
@ -16,7 +16,8 @@ namespace CSVRender
|
||||||
, mWindow(NULL)
|
, mWindow(NULL)
|
||||||
, mCamera(NULL)
|
, mCamera(NULL)
|
||||||
, mSceneMgr(NULL), mNavigationMode (NavigationMode_Free), mUpdate (false)
|
, mSceneMgr(NULL), mNavigationMode (NavigationMode_Free), mUpdate (false)
|
||||||
, mKeyForward (false), mKeyBackward (false), mFast (false)
|
, mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
|
||||||
|
, mFast (false)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_PaintOnScreen);
|
setAttribute(Qt::WA_PaintOnScreen);
|
||||||
setAttribute(Qt::WA_NoSystemBackground);
|
setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
@ -143,6 +144,8 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
case Qt::Key_W: mKeyForward = true; break;
|
case Qt::Key_W: mKeyForward = true; break;
|
||||||
case Qt::Key_S: mKeyBackward = true; break;
|
case Qt::Key_S: mKeyBackward = true; break;
|
||||||
|
case Qt::Key_A: mKeyLeft = true; break;
|
||||||
|
case Qt::Key_D: mKeyRight = true; break;
|
||||||
case Qt::Key_Shift: mFast = true; break;
|
case Qt::Key_Shift: mFast = true; break;
|
||||||
default: QWidget::keyPressEvent (event);
|
default: QWidget::keyPressEvent (event);
|
||||||
}
|
}
|
||||||
|
@ -154,6 +157,8 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
case Qt::Key_W: mKeyForward = false; break;
|
case Qt::Key_W: mKeyForward = false; break;
|
||||||
case Qt::Key_S: mKeyBackward = false; break;
|
case Qt::Key_S: mKeyBackward = false; break;
|
||||||
|
case Qt::Key_A: mKeyLeft = false; break;
|
||||||
|
case Qt::Key_D: mKeyRight = false; break;
|
||||||
case Qt::Key_Shift: mFast = false; break;
|
case Qt::Key_Shift: mFast = false; break;
|
||||||
default: QWidget::keyReleaseEvent (event);
|
default: QWidget::keyReleaseEvent (event);
|
||||||
}
|
}
|
||||||
|
@ -163,6 +168,8 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
mKeyForward = false;
|
mKeyForward = false;
|
||||||
mKeyBackward = false;
|
mKeyBackward = false;
|
||||||
|
mKeyLeft = false;
|
||||||
|
mKeyRight = false;
|
||||||
mFast = false;
|
mFast = false;
|
||||||
|
|
||||||
QWidget::focusOutEvent (event);
|
QWidget::focusOutEvent (event);
|
||||||
|
@ -170,20 +177,34 @@ namespace CSVRender
|
||||||
|
|
||||||
void SceneWidget::update()
|
void SceneWidget::update()
|
||||||
{
|
{
|
||||||
|
int factor = mFast ? 4 : 1;
|
||||||
|
|
||||||
if (mKeyForward && !mKeyBackward)
|
if (mKeyForward && !mKeyBackward)
|
||||||
{
|
{
|
||||||
int factor = mFast ? 4 : 1;
|
|
||||||
mCamera->move (factor * mCamera->getDirection());
|
mCamera->move (factor * mCamera->getDirection());
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mKeyForward && mKeyBackward)
|
if (!mKeyForward && mKeyBackward)
|
||||||
{
|
{
|
||||||
int factor = mFast ? 4 : 1;
|
|
||||||
mCamera->move (factor * -mCamera->getDirection());
|
mCamera->move (factor * -mCamera->getDirection());
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mKeyLeft && !mKeyRight)
|
||||||
|
{
|
||||||
|
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
||||||
|
mCamera->move (factor * -direction);
|
||||||
|
mUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mKeyLeft && mKeyRight)
|
||||||
|
{
|
||||||
|
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
||||||
|
mCamera->move (factor * direction);
|
||||||
|
mUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mUpdate)
|
if (mUpdate)
|
||||||
{
|
{
|
||||||
mUpdate = false;
|
mUpdate = false;
|
||||||
|
|
|
@ -49,6 +49,8 @@ namespace CSVRender
|
||||||
bool mUpdate;
|
bool mUpdate;
|
||||||
int mKeyForward;
|
int mKeyForward;
|
||||||
int mKeyBackward;
|
int mKeyBackward;
|
||||||
|
int mKeyLeft;
|
||||||
|
int mKeyRight;
|
||||||
bool mFast;
|
bool mFast;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in a new issue