diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-09-09 18:50:45 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-09-09 18:50:45 +0000 |
commit | 146c9e449443453f3932b60cd1bab47f688403e7 (patch) | |
tree | f7f18d29a7a7755515db377b5de9658899de66bb /demos/opengl/trackball.cpp | |
parent | d3a70b7facea2919b5ee0451d3c639dedb00ea30 (diff) |
various stuff in opengl demos such as a better model,
stable trackball for the fly navigation mode, and started
to put some GUI elements...
Diffstat (limited to 'demos/opengl/trackball.cpp')
-rw-r--r-- | demos/opengl/trackball.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/demos/opengl/trackball.cpp b/demos/opengl/trackball.cpp index f66243d0d..83e74a649 100644 --- a/demos/opengl/trackball.cpp +++ b/demos/opengl/trackball.cpp @@ -27,12 +27,12 @@ using namespace Eigen; -void Trackball::track(const Vector2i& newPoint2D) +void Trackball::track(const Vector2i& point2D) { if (mpCamera==0) return; Vector3f newPoint3D; - bool newPointOk = mapToSphere(newPoint2D, newPoint3D); + bool newPointOk = mapToSphere(point2D, newPoint3D); if (mLastPointOk && newPointOk) { @@ -40,12 +40,14 @@ void Trackball::track(const Vector2i& newPoint2D) float cos_angle = mLastPoint3D.dot(newPoint3D); if ( ei_abs(cos_angle) < 1.0 ) { - float angle = 2.0 * acos(cos_angle); - mpCamera->rotateAroundTarget(Quaternionf(AngleAxisf(angle, axis))); + float angle = acos(cos_angle); + if (mMode==Around) + mpCamera->rotateAroundTarget(Quaternionf(AngleAxisf(2.*angle, axis))); // *2 to speedup the rotation + else + mpCamera->localRotate(Quaternionf(AngleAxisf(-angle, axis))); } } - mLastPoint2D = newPoint2D; mLastPoint3D = newPoint3D; mLastPointOk = newPointOk; } |