JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::Draggable3DOrientation Class Reference

Stores a 3D orientation, which can be rotated by dragging with the mouse. More...

#include <juce_Draggable3DOrientation.h>

Collaboration diagram for juce::Draggable3DOrientation:

Public Types

using QuaternionType = Quaternion< float >
 
using VectorType = Vector3D< float >
 

Public Member Functions

 Draggable3DOrientation (const Quaternion< float > &quaternionToUse, float objectRadius=0.5f) noexcept
 Creates a Draggable3DOrientation from a user-supplied quaternion. More...
 
 Draggable3DOrientation (float objectRadius=0.5f) noexcept
 Creates a Draggable3DOrientation, initially set up to be aligned along the X axis. More...
 
QuaternionTypegetQuaternion () noexcept
 Provides direct access to the quaternion. More...
 
Matrix3D< floatgetRotationMatrix () const noexcept
 Returns the matrix that should be used to apply the current orientation. More...
 
template<typename Type >
void mouseDown (Point< Type > mousePos) noexcept
 Begins a mouse-drag operation. More...
 
template<typename Type >
void mouseDrag (Point< Type > mousePos) noexcept
 Continues a mouse-drag operation. More...
 
void reset (const VectorType &axis) noexcept
 Resets the orientation, specifying the axis to align it along. More...
 
void setRadius (float newRadius) noexcept
 Sets the size of the rotated object, as a proportion of the viewport's size. More...
 
void setViewport (Rectangle< int > newArea) noexcept
 Sets the viewport area within which mouse-drag positions will occur. More...
 

Private Member Functions

Point< floatmousePosToProportion (Point< float > mousePos) const noexcept
 
VectorType projectOnSphere (Point< float > pos) const noexcept
 
QuaternionType rotationFromMove (const VectorType &from, const VectorType &to) const noexcept
 

Private Attributes

Rectangle< intarea
 
Point< floatlastMouse
 
QuaternionType quaternion
 
float radius
 

Detailed Description

Stores a 3D orientation, which can be rotated by dragging with the mouse.

@tags{OpenGL}

Member Typedef Documentation

◆ QuaternionType

◆ VectorType

Constructor & Destructor Documentation

◆ Draggable3DOrientation() [1/2]

juce::Draggable3DOrientation::Draggable3DOrientation ( float  objectRadius = 0.5f)
inlinenoexcept

Creates a Draggable3DOrientation, initially set up to be aligned along the X axis.

◆ Draggable3DOrientation() [2/2]

juce::Draggable3DOrientation::Draggable3DOrientation ( const Quaternion< float > &  quaternionToUse,
float  objectRadius = 0.5f 
)
inlinenoexcept

Creates a Draggable3DOrientation from a user-supplied quaternion.

Member Function Documentation

◆ getQuaternion()

QuaternionType& juce::Draggable3DOrientation::getQuaternion ( )
inlinenoexcept

Provides direct access to the quaternion.

References quaternion.

◆ getRotationMatrix()

Matrix3D<float> juce::Draggable3DOrientation::getRotationMatrix ( ) const
inlinenoexcept

Returns the matrix that should be used to apply the current orientation.

See also
applyToOpenGLMatrix

References juce::Quaternion< Type >::getRotationMatrix(), and quaternion.

◆ mouseDown()

template<typename Type >
void juce::Draggable3DOrientation::mouseDown ( Point< Type >  mousePos)
inlinenoexcept

Begins a mouse-drag operation.

You must call this before any calls to mouseDrag(). The position that is supplied will be treated as being relative to the centre of the rectangle passed to setViewport().

References lastMouse, and mousePosToProportion().

◆ mouseDrag()

template<typename Type >
void juce::Draggable3DOrientation::mouseDrag ( Point< Type >  mousePos)
inlinenoexcept

Continues a mouse-drag operation.

After calling mouseDown() to begin a drag sequence, you can call this method to continue it.

References lastMouse, mousePosToProportion(), projectOnSphere(), quaternion, and rotationFromMove().

◆ mousePosToProportion()

◆ projectOnSphere()

VectorType juce::Draggable3DOrientation::projectOnSphere ( Point< float pos) const
inlineprivatenoexcept

References radius.

Referenced by mouseDrag().

◆ reset()

void juce::Draggable3DOrientation::reset ( const VectorType axis)
inlinenoexcept

Resets the orientation, specifying the axis to align it along.

References quaternion.

◆ rotationFromMove()

QuaternionType juce::Draggable3DOrientation::rotationFromMove ( const VectorType from,
const VectorType to 
) const
inlineprivatenoexcept

◆ setRadius()

void juce::Draggable3DOrientation::setRadius ( float  newRadius)
inlinenoexcept

Sets the size of the rotated object, as a proportion of the viewport's size.

See also
setViewport

References juce::gl::f, juce::jmax(), and radius.

◆ setViewport()

void juce::Draggable3DOrientation::setViewport ( Rectangle< int newArea)
inlinenoexcept

Sets the viewport area within which mouse-drag positions will occur.

You'll need to set this rectangle before calling mouseDown. The centre of the rectangle is assumed to be the centre of the object that will be rotated, and the size of the rectangle will be used to scale the object radius - see setRadius().

References area.

Member Data Documentation

◆ area

Rectangle<int> juce::Draggable3DOrientation::area
private

◆ lastMouse

Point<float> juce::Draggable3DOrientation::lastMouse
private

Referenced by mouseDown(), and mouseDrag().

◆ quaternion

QuaternionType juce::Draggable3DOrientation::quaternion
private

◆ radius

float juce::Draggable3DOrientation::radius
private

The documentation for this class was generated from the following file: