1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 13:23:52 +00:00

camera rotation via ctrl-left button drag

This commit is contained in:
Marc Zinnschlag 2014-02-25 14:24:35 +01:00
parent e987199949
commit e33bd4d508
2 changed files with 35 additions and 10 deletions

View file

@ -17,7 +17,7 @@ namespace CSVRender
, mCamera(NULL) , mCamera(NULL)
, mSceneMgr(NULL), mNavigationMode (NavigationMode_Free), mUpdate (false) , mSceneMgr(NULL), mNavigationMode (NavigationMode_Free), mUpdate (false)
, mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false) , mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
, mFast (false), mDragging (false) , mFast (false), mDragging (false), mMod1 (false)
, mMouseSensitivity (2), mFastFactor (4) /// \todo make these configurable , mMouseSensitivity (2), mFastFactor (4) /// \todo make these configurable
{ {
setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_PaintOnScreen);
@ -148,6 +148,7 @@ namespace CSVRender
case Qt::Key_A: mKeyLeft = true; break; case Qt::Key_A: mKeyLeft = true; break;
case Qt::Key_D: mKeyRight = true; break; case Qt::Key_D: mKeyRight = true; break;
case Qt::Key_Shift: mFast = true; break; case Qt::Key_Shift: mFast = true; break;
case Qt::Key_Control: mMod1 = true; break;
default: QWidget::keyPressEvent (event); default: QWidget::keyPressEvent (event);
} }
} }
@ -161,6 +162,7 @@ namespace CSVRender
case Qt::Key_A: mKeyLeft = false; break; case Qt::Key_A: mKeyLeft = false; break;
case Qt::Key_D: mKeyRight = false; break; case Qt::Key_D: mKeyRight = false; break;
case Qt::Key_Shift: mFast = false; break; case Qt::Key_Shift: mFast = false; break;
case Qt::Key_Control: mMod1 = false; break;
default: QWidget::keyReleaseEvent (event); default: QWidget::keyReleaseEvent (event);
} }
} }
@ -188,6 +190,26 @@ namespace CSVRender
QPoint diff = mOldPos-event->pos(); QPoint diff = mOldPos-event->pos();
mOldPos = event->pos(); mOldPos = event->pos();
if (mMod1)
{
// turn camera
if (diff.x())
{
mCamera->yaw (
Ogre::Degree ((getFastFactor() * diff.x())/mMouseSensitivity));
mUpdate = true;
}
if (diff.y())
{
mCamera->pitch (
Ogre::Degree ((getFastFactor() * diff.y())/mMouseSensitivity));
mUpdate = true;
}
}
else
{
// pan camera
if (diff.x()) if (diff.x())
{ {
Ogre::Vector3 direction = mCamera->getDerivedRight(); Ogre::Vector3 direction = mCamera->getDerivedRight();
@ -202,6 +224,7 @@ namespace CSVRender
mUpdate = true; mUpdate = true;
} }
} }
}
else else
{ {
mDragging = true; mDragging = true;
@ -223,6 +246,7 @@ namespace CSVRender
mKeyLeft = false; mKeyLeft = false;
mKeyRight = false; mKeyRight = false;
mFast = false; mFast = false;
mMod1 = false;
QWidget::focusOutEvent (event); QWidget::focusOutEvent (event);
} }

View file

@ -63,6 +63,7 @@ namespace CSVRender
int mKeyRight; int mKeyRight;
bool mFast; bool mFast;
bool mDragging; bool mDragging;
bool mMod1;
QPoint mOldPos; QPoint mOldPos;
int mMouseSensitivity; int mMouseSensitivity;
int mFastFactor; int mFastFactor;