Arc Ball
Arc ball 3D transformation
|
#include <ArcBall.hpp>
Public Member Functions | |
ArcBall (const glm::vec3 ¢er, glm::float_t radius, const glm::mat4 &screenToTCS=glm::mat4()) | |
void | beginDrag (const glm::vec2 &mouseScreenCoords) |
void | drag (const glm::vec2 &mouseScreenCoords) |
glm::mat4 | 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.
ArcBall | ( | const glm::vec3 & | center, |
glm::float_t | radius, | ||
const glm::mat4 & | screenToTCS = glm::mat4() |
||
) |
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. |
void beginDrag | ( | const glm::vec2 & | mouseScreenCoords | ) |
Initiate an arc ball drag given the mouse click in screen coordinates.
mouseScreenCoords | Mouse screen coordinates. |
void drag | ( | const glm::vec2 & | mouseScreenCoords | ) |
Informs the arcball when the mouse has been dragged.
mouseScreenCoords | Mouse screen coordinates. |
glm::mat4 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.