sphore 0.0.1
SPH openGL rendering engine
|
Code for managing a camera. More...
Go to the source code of this file.
Typedefs | |
typedef struct _camera | camera_t |
Public access to the internal camera storage mechanism (_camera). | |
Functions | |
camera_t * | camera_create (void) |
Creates a new camera object. | |
void | camera_destroy (camera_t *cam) |
Cleans up a camera object. | |
void | camera_reset (camera_t *cam) |
Resets the position and rotation of the camera to default. | |
void | camera_translate (camera_t *cam, float x, float y, float z) |
Translate the camera. | |
void | camera_rotate (camera_t *cam, float theta, float x, float y, float z) |
Rotates the camera. | |
const float * | camera_get_matrix (camera_t *cam) |
Returns the matrix representation of the camera. | |
void | camera_set_position (camera_t *cam, float x, float y, float z) |
Sets the camera's position in absolute coordinants. | |
float * | camera_get_inverse_rotation_matrix (camera_t *cam) |
Returns a new matrix representing the inverse of the camera rotation. |
Code for managing a camera.
Public access to the internal camera storage mechanism (_camera).
Memory managment should be done with camera_create and camera_destroy.
camera_t* camera_create | ( | void | ) |
Creates a new camera object.
The camera should be cleaned up with camera_destroy. The camera is set to the default position.
void camera_destroy | ( | camera_t * | cam | ) |
Cleans up a camera object.
Frees the memory used by a camera object.
[in] | cam | The camera to destroy. |
float* camera_get_inverse_rotation_matrix | ( | camera_t * | cam | ) |
Returns a new matrix representing the inverse of the camera rotation.
This array must be subsequently be freed!
[in] | cam | The camera to get the inverse from. |
const float* camera_get_matrix | ( | camera_t * | cam | ) |
Returns the matrix representation of the camera.
[in] | cam | The camera to get the matrix for. |
void camera_reset | ( | camera_t * | cam | ) |
Resets the position and rotation of the camera to default.
The default position is at the origin, looking in the negative z direction.
[in] | cam | The camera to reset. |
void camera_rotate | ( | camera_t * | cam, |
float | theta, | ||
float | x, | ||
float | y, | ||
float | z | ||
) |
Rotates the camera.
Rotates the camera around the specified axis.
[in] | cam | The camera to rotate. |
[in] | theta | The angle to rotate through (in radians). |
[in] | x | The component of the axis of rotation in the x direction. |
[in] | y | The component of the axis of rotation in the y direction. |
[in] | z | The component of the axis of rotation in the z direction. |
void camera_set_position | ( | camera_t * | cam, |
float | x, | ||
float | y, | ||
float | z | ||
) |
Sets the camera's position in absolute coordinants.
[in] | cam | The camera to set the position of. |
[in] | x | The x coordinant of the new position. |
[in] | y | The y coordinant of the new position. |
[in] | z | The z coordinant of the new position. |
void camera_translate | ( | camera_t * | cam, |
float | x, | ||
float | y, | ||
float | z | ||
) |
Translate the camera.
Moves the camera to (x, y, z), in the frame of reference of the camera.
[in] | cam | The camera to move. |
[in] | x | The x-coordinant to move to. |
[in] | y | The y-coordinant to move to. |
[in] | z | The z-coordinant to move to. |