Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

nvutil::Trackball Class Reference

Trackball class for simulating a virtual trackball. More...

#include <Trackball.h>

List of all members.

Public Member Functions

 Trackball (void)
 Default constructor.
virtual ~Trackball (void)
 Default destructor.
void apply (const nvmath::Vec2f &p0, const nvmath::Vec2f &p1, nvmath::Vec3f &axis, float &rad)
 Start trackball calculation.
void setSize (float size)
 Set trackball size.
float getSize (void)
 Determine current size of the trackball.

Protected Member Functions

float projectOntoTBSphere (const nvmath::Vec2f &p)
 Project the x,y mouse position onto a sphere.

Protected Attributes

float m_tbsize
 Trackball size (default is 0.8f)


Detailed Description

Trackball class for simulating a virtual trackball.

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.


Constructor & Destructor Documentation

nvutil::Trackball::Trackball void   ) 
 

Default constructor.

virtual nvutil::Trackball::~Trackball void   )  [virtual]
 

Default destructor.


Member Function Documentation

void nvutil::Trackball::apply const nvmath::Vec2f p0,
const nvmath::Vec2f p1,
nvmath::Vec3f axis,
float &  rad
 

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)

Note:
This is a deformed trackball-- is a trackball in the center, but is deformed into a hyperbolic sheet of rotation away from the center.
Parameters:
p0  Last mouse position - components must be scaled to [-1,1]
p1  Current mouse position - components must be scaled to [-1,1]
axis  Resulting axis
rad  Resulting angle

void nvutil::Trackball::setSize float  size  )  [inline]
 

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.

Parameters:
size  Trackball size

float nvutil::Trackball::getSize void   )  [inline]
 

Determine current size of the trackball.

Returns:
Trackball size

float nvutil::Trackball::projectOntoTBSphere const nvmath::Vec2f p  )  [protected]
 

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.


Member Data Documentation

float nvutil::Trackball::m_tbsize [protected]
 

Trackball size (default is 0.8f)


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:21:15 2005 for NVSGSDK by NVIDIA