From d88d322dc557375fa08c545291c964b0b779bc00 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 7 Sep 2013 20:18:40 +0100 Subject: [PATCH] Added a couple of methods to Draggable3DOrientation --- .../opengl/juce_Draggable3DOrientation.h | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h b/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h index b4cc564492..c407539588 100644 --- a/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h +++ b/modules/juce_opengl/opengl/juce_Draggable3DOrientation.h @@ -34,6 +34,7 @@ class Draggable3DOrientation { public: typedef Vector3D VectorType; + typedef Quaternion QuaternionType; /** Creates a Draggable3DOrientation, initially set up to be aligned along the X axis. */ Draggable3DOrientation (float objectRadius = 0.5f) noexcept @@ -42,6 +43,14 @@ public: { } + /** Creates a Draggable3DOrientation from a user-supplied quaternion. */ + Draggable3DOrientation (const Quaternion& quaternionToUse, + float objectRadius = 0.5f) noexcept + : radius (jmax (0.1f, objectRadius)), + quaternion (quaternionToUse) + { + } + /** Resets the orientation, specifying the axis to align it along. */ void reset (const VectorType& axis) noexcept { @@ -71,7 +80,7 @@ public: will be treated as being relative to the centre of the rectangle passed to setViewport(). */ template - void mouseDown (const Point& mousePos) noexcept + void mouseDown (Point mousePos) noexcept { lastMouse = mousePosToProportion (mousePos.toFloat()); } @@ -81,7 +90,7 @@ public: to continue it. */ template - void mouseDrag (const Point& mousePos) noexcept + void mouseDrag (Point mousePos) noexcept { const VectorType oldPos (projectOnSphere (lastMouse)); lastMouse = mousePosToProportion (mousePos.toFloat()); @@ -98,6 +107,12 @@ public: return quaternion.getRotationMatrix(); } + /** Provides direct access to the quaternion. */ + QuaternionType& getQuaternion() noexcept + { + return quaternion; + } + #if JUCE_USE_OPENGL_FIXED_FUNCTION /** Applies this rotation to the active OpenGL context's matrix. */ void applyToOpenGLMatrix() const noexcept @@ -107,7 +122,6 @@ public: #endif private: - typedef Quaternion QuaternionType; Rectangle area; float radius; QuaternionType quaternion;