Utility class for adding simple momentum to 2D or 3D UI elements.
More...
#include <LeapUtil.h>
Utility class for adding simple momentum to 2D or 3D UI elements.
Definition at line 428 of file LeapUtil.h.
LeapUtil::ScrollMomentum::ScrollMomentum |
( |
| ) |
|
|
inline |
const Leap::Vector& LeapUtil::ScrollMomentum::getDirection |
( |
| ) |
const |
|
inline |
The direction of movement. Direction should never be set to the zero vector. The default value is Y+ vector (0, 1, 0)
Definition at line 451 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::getDrag |
( |
| ) |
const |
|
inline |
The coefficient of drag to use for slowing movement over time. Drag is always a positive value. The default value is 0.4
Definition at line 491 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::getDragPower |
( |
| ) |
const |
|
inline |
Drag power controls how drag is calculated from speed. Drag force is (speed/scrollSize)^dragPower A drag power of 1 would be linear falloff. The default value is 2.0 (square falloff)
Definition at line 498 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::getFixedTimeStep |
( |
| ) |
const |
|
inline |
A fixed time step is used to ensure consistent behavior. The deltaTime passed to update is processed in increments of the fixed time step. Any unhandled time is cached for processing on the next call to update. The default value is 1/60th of a second.
Definition at line 485 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::getMinSpeed |
( |
| ) |
const |
|
inline |
When absolute value of speed falls to or below MinSpeed speed is set to 0. This is to prevent asymptotically approaching the limit of floating point resolution and getting jitter or undesirable effects. The default value is 0.125
Definition at line 478 of file LeapUtil.h.
const Leap::Vector& LeapUtil::ScrollMomentum::getPosition |
( |
| ) |
const |
|
inline |
The current scroll position. Calling SetPosition assigns an initial position value. Calls to update will change position based on velocity (speed * direction) The default value is the zero vector (0, 0, 0)
Definition at line 445 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::getScrollSize |
( |
| ) |
const |
|
inline |
ScrollSize is used to tune the rate at which drag starts to taper its effect on speed. Because drag is proportional to speed^dragPower it slows objects moving at speeds greater than 1 quickly and tapers for speeds below 1. The drag calculations are done using speed/ScrollSize as the value to square. ScrollSize is always > 0. The default value is 512
Definition at line 462 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::getSpeed |
( |
| ) |
const |
|
inline |
Current speed of movement. Speed is not defined in strict terms of any particular unit. A value in pixels/second or mm/sec will work well for speed. Calling SetSpeed assigns an initial speed value. Calls to update will change speed as drag slows down movement. Speed can be positive or negative.
Definition at line 471 of file LeapUtil.h.
const Leap::Vector LeapUtil::ScrollMomentum::getVelocity |
( |
| ) |
const |
|
inline |
Current velocity (scaled direction vector) - changes over time as drag slows movement. Convenience method - just multiplies direction by current speed.
Definition at line 503 of file LeapUtil.h.
void LeapUtil::ScrollMomentum::setDirection |
( |
const Leap::Vector & |
vDirection | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setDrag |
( |
float |
fDrag | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setDragPower |
( |
float |
fDragPower | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setFixedTimeStep |
( |
float |
fFixedTimeStep | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setMinSpeed |
( |
float |
fMinSpeed | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setPosition |
( |
const Leap::Vector & |
vPosition | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setScrollSize |
( |
float |
fScrollSize | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setSpeed |
( |
float |
fSpeed | ) |
|
|
inline |
void LeapUtil::ScrollMomentum::setVelocity |
( |
const Leap::Vector & |
vDirection, |
|
|
float |
fSpeed |
|
) |
| |
|
inline |
Convenience method for setting a direction and initial speed in one call. see SetDirection() and SetSpeed()
Definition at line 507 of file LeapUtil.h.
void LeapUtil::ScrollMomentum::update |
( |
float |
fDeltaTimeSeconds | ) |
|
|
inline |
Update handles time stepping. Update modifies velocity by drag and position by velocity. Time is processed fixed size chunks. If _deltaTimeSeconds is larger than that chunk, update will iterate through the time in increments of the fixed time step. If it is smaller, the delta time is accumulated over successive calls to update until one time step has passed and then it is processed.
Definition at line 519 of file LeapUtil.h.
float LeapUtil::ScrollMomentum::m_fDrag |
|
protected |
float LeapUtil::ScrollMomentum::m_fDragPower |
|
protected |
float LeapUtil::ScrollMomentum::m_fFixedTimeStep |
|
protected |
float LeapUtil::ScrollMomentum::m_fMinSpeed |
|
protected |
float LeapUtil::ScrollMomentum::m_fPendingDeltaTime |
|
protected |
float LeapUtil::ScrollMomentum::m_fScrollSize |
|
protected |
float LeapUtil::ScrollMomentum::m_fSpeed |
|
protected |
The documentation for this class was generated from the following file: