Molecular Vis
Improving perception of molecular visualization
|
A class for an arc-ball camera. More...
#include <Camera.h>
Public Member Functions | |
Camera (float fov, float aspect, float near, float far) | |
glm::mat4 | getInverseProjectionViewMatrix () |
glm::mat4 | getProjectionViewMatrix () |
glm::mat4 | getViewMatrix () |
glm::vec3 | getPosition () |
glm::vec3 | getDirection () |
void | update (int x, int y, float zoom, bool dragging, bool strafing) |
A class for an arc-ball camera.
This class defines a camera and calculates the needed transformations, projections and vectors derived from the camera. The camera is an arc ball camera.
Camera::Camera | ( | float | fov, |
float | aspect, | ||
float | near, | ||
float | far | ||
) |
Creates a camera with given parameter, which define the projection matrix.
fov | Field of view of projection in degrees. |
aspect | Aspect ratio of projection. |
near | Near plane z. |
far | Far plane z. |
glm::vec3 Camera::getDirection | ( | ) |
Return the normalized view axis direction.
glm::mat4 Camera::getInverseProjectionViewMatrix | ( | ) |
Gets the inverse of the projection view matrix. Transforms from screen space to world space.
glm::vec3 Camera::getPosition | ( | ) |
Gets the position of the camera.
mat4 Camera::getProjectionViewMatrix | ( | ) |
Gets the the projection view matrix. Transforms from world space to screen space.
glm::mat4 Camera::getViewMatrix | ( | ) |
Gets the the view matrix. Transforms from world space to camera space.
void Camera::update | ( | int | x, |
int | y, | ||
float | zoom, | ||
bool | dragging, | ||
bool | strafing | ||
) |
Updates the camera position and direction. Has to be updated often as relative movement is used, therefor if the camera wasn't updated for some time the position and direction can jump by a lot.
x | x coordinate of mouse in pixel |
y | y coordinates of mouse in pixel |
zoom | zoom radius, corresponds to the distance from the focus point to the camera. |
dragging | if the movement should change the orientation (dragging the camera around on a ball) |
strafing | if the camera position should be moved in the tangential plane on the sphere where the camera is placed. (strafing movement) |