#include <Trackball.h>
Public Methods | |
Trackball (void) | |
Default constructor. More... | |
virtual | ~Trackball (void) |
Default destructor. More... | |
void | apply (const nvmath::Vec2f &p0, const nvmath::Vec2f &p1, nvmath::Vec3f &axis, float &rad) |
Start trackball calculation. More... | |
void | setSize (float size) |
Set trackball size. More... | |
float | getSize (void) |
Determine current size of the trackball. More... | |
Protected Methods | |
float | projectOntoTBSphere (const nvmath::Vec2f &p) |
Project the x,y mouse position onto a sphere. More... | |
Protected Attributes | |
float | m_tbsize |
Trackball size (default is 0.8f). More... |
This class simulates a virtual trackball using the last and current mouse position. It simply projects the stuff onto a sphere or hyperbolic sheet and calculates the axis and angle that is needed to rotate the trackball from the last to the current position.
|
Default constructor.
|
|
Default destructor.
|
|
Start trackball calculation. Calculate the axis and the angle (radians) by the given mouse coordinates. Project the points onto the virtual trackball, then figure out the axis of rotation, which is the cross product of p0 p1 and O p0 (O is the center of the ball, 0,0,0)
|
|
Set trackball size. Define the size of the trackball. Default size is 0.8f. This size should really be based on the distance from the center of rotation to the point on the object underneath the mouse. That point would then track the mouse as closely as possible.
|
|
Determine current size of the trackball.
|
|
Project the x,y mouse position onto a sphere. Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet if we are away from the center of the sphere. |
|
Trackball size (default is 0.8f).
|