SCIRun
5.0
|
#include <SciBall.h>
Public Member Functions | |
SciBall (const spire::V3 ¢er, float radius, const spire::M44 &screenToTCS=spire::M44()) | |
virtual | ~SciBall () |
void | beginDrag (const spire::V2 &mouseScreenCoords) |
void | drag (const spire::V2 &mouseScreenCoords) |
spire::M44 | getTransformation () const |
A reimplementation of Ken Shoemake's arcball camera. SCIRun 4's camera system is based off of Ken's code. The Code appears in Graphics Gems 4, III.1.
Unless specified otherwise, all calculations and variables stored in this class are relative to the target coordinate system (TCS) for which there is a transformation from screen space to TCS given by the screenToTCS constructor parameter.
If the screenToTCS parameter in the constructor is left as the identity matrix then all values are given in screen coordinates. Screen coordinates are (x [-1,1]) and (y [-1,1]) where (0,0) is the center of the screen.
Extend this class to include Mouse screen coords -> object space calculations. That way we can rotate around a particular object. May also want to visually represent the sphere when we perform this calculation.
Provide method of setting the default orientation of the object.
SciBall | ( | const spire::V3 & | center, |
float | radius, | ||
const spire::M44 & | screenToTCS = spire::M44() |
||
) |
center | Center of the arcball in TCS (screen coordinates if screenToTCS = identity). Generally this will always be (0,0,0). But you may move the center in and out of the screen plane to various effect. |
radius | Radius in TCS. For screen coordinates, a good default is 0.75. |
screenToTCS | Transformation from screen coordinates to TCS. 'center' and 'radius' are given in TCS. |
|
virtual |
void beginDrag | ( | const spire::V2 & | mouseScreenCoords | ) |
Initiate an arc ball drag given the mouse click in screen coordinates.
mouseScreenCoords | Mouse screen coordinates. |
void drag | ( | const spire::V2 & | mouseScreenCoords | ) |
Informs the arcball when the mouse has been dragged.
mouseScreenCoords | Mouse screen coordinates. |
spire::M44 getTransformation | ( | ) | const |
Retrieves the current transformation in TCS. Obtains full transformation of object in question. If the arc ball is being used to control camera rotation, then this will contain all concatenated camera transformations. The current state of the camera is stored in the quaternions mQDown and mQNow. mMatNow is calculated from mQNow.