diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-10-25 11:22:16 +0000 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-10-25 19:09:23 +0000 |
commit | 12461331112e06dc9bae36e03b2fa96a3784f103 (patch) | |
tree | 15e127ef48c38467d7b80bd595c1ea26ebda8588 /src/core/core-components/qcamera.cpp | |
parent | 83c32b94872a82a6af8057f16c81326353e69c8f (diff) |
Add first person camera controller mode and make it the default
For most scenes this is what people want in preference to the free-look
mode. Keeping a consistent up vector is more natural for most people.
This is a temporary hack until we get the InputManager completed and
we have a proper abstraction for controllers. After all, who says the
inputs should control the camera. They should be able to control any
Entity with a Transform. This also requires the Transform refactoring
to be completed before we can tie both sides together.
Change-Id: If8f02c66febcdee31c13ee46b6651a0e923e8d09
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/core-components/qcamera.cpp')
-rw-r--r-- | src/core/core-components/qcamera.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/core-components/qcamera.cpp b/src/core/core-components/qcamera.cpp index 0746b408b..53d22f1e5 100644 --- a/src/core/core-components/qcamera.cpp +++ b/src/core/core-components/qcamera.cpp @@ -196,6 +196,11 @@ QQuaternion QCamera::rollRotation(float angle) const return QQuaternion::fromAxisAndAngle(viewVector, -angle); } +QQuaternion QCamera::rotation(float angle, const QVector3D &axis) const +{ + return QQuaternion::fromAxisAndAngle(axis, angle); +} + void QCamera::tilt(float angle) { QQuaternion q = tiltRotation(angle); @@ -208,6 +213,12 @@ void QCamera::pan(float angle) rotate(q); } +void QCamera::pan(float angle, const QVector3D &axis) +{ + QQuaternion q = rotation(-angle, axis); + rotate(q); +} + void QCamera::roll(float angle) { QQuaternion q = rollRotation(-angle); @@ -226,6 +237,12 @@ void QCamera::panAboutViewCenter(float angle) rotateAboutViewCenter(q); } +void QCamera::panAboutViewCenter(float angle, const QVector3D &axis) +{ + QQuaternion q = rotation(angle, axis); + rotateAboutViewCenter(q); +} + void QCamera::rollAboutViewCenter(float angle) { QQuaternion q = rollRotation(angle); |