|
AGL
0
3D graphics library
|
Camera class for the scene. More...
Public Member Functions | |
| Camera (const glm::vec3 &pos=glm::vec3(3, 4, 5), const glm::vec3 &lookAt=glm::vec3(0), const glm::vec3 &up=glm::vec3(0, 1, 0)) | |
| Creates a camera. More... | |
| void | setView (const glm::mat4 &mat) |
| Set the view matrix. More... | |
| void | rotate (float rad=0, const glm::vec3 &axis=glm::vec3(0), bool around=true) |
| Rotate the camera. More... | |
| void | rotate (const glm::quat &rot=glm::quat(1, 0, 0, 0), bool around=true) |
| Rotate the camera with the quaternion. More... | |
| void | rotateX (float rad=0, bool around=true, bool safe=true) |
| Rotate around the x-axis. More... | |
| void | rotateY (float rad=0, bool around=true) |
| Rotate around the y-axis. More... | |
| void | rotateZ (float rad=0, bool around=true) |
| Rotate around the z-axis. More... | |
| void | translate (const glm::vec3 &d=glm::vec3(0)) |
| Translate (move, shift) the camera. More... | |
| void | translate (float dx=0, float dy=0, float dz=0) |
| Translate (move, shift) the camera. More... | |
Camera setters | |
These methods are used to set the parameters of the camera, and the view matrix. They modify the internal view matrix. | |
| void | setPos (const glm::vec3 &pos=glm::vec3(3, 4, 5)) |
| Sets the position of the camera. More... | |
| void | setPos (float x=3, float y=4, float z=5) |
| Sets the position of the camera. More... | |
| void | lookAt (const glm::vec3 &target=glm::vec3(0)) |
| Set the point the camera will look at. More... | |
| void | lookAt (float x=0, float y=0, float z=0) |
| Set the point the camera will look at. More... | |
| void | setUp (const glm::vec3 &up=glm::vec3(0, 1, 0)) |
| Set the up-vector. More... | |
| void | setUp (float x=0, float y=1, float z=0) |
| Set the up-vector. More... | |
View transformations | |
| void | viewTranslate (const glm::vec3 &d=glm::vec3(0)) |
| Translate the view matrix. More... | |
| void | viewTranslate (float dx=0, float dy=0, float dz=0) |
| Translate the view matrix. More... | |
| void | viewRotate (float rad=0, const glm::vec3 &axis=glm::vec3(0)) |
| Rotate the view matrix. More... | |
| void | viewScale (const glm::vec3 &s=glm::vec3(1)) |
| Scale the view matrix. More... | |
| void | viewScale (float sx=1, float sy=1, float sz=1) |
| Scale the view matrix. More... | |
| void | viewTransform (const glm::mat4 &m) |
| Transform the view matrix. More... | |
Public Attributes | |
| glm::mat4 | view |
| The view matrix. More... | |
| glm::vec3 | _pos |
| The position of the camera. More... | |
| glm::vec3 | _lookAt |
| The point the camera looks at. More... | |
| glm::vec3 | _up |
| The up vector for the camera. More... | |
Camera class for the scene.
Camera controls the positioning of the camera for the scene. It controls the rotation of the camera, up-vectors, positioning, etc. This class handles the V part of the MVP matrix.
| Camera | ( | const glm::vec3 & | pos = glm::vec3(3, 4, 5), |
| const glm::vec3 & | lookAt = glm::vec3(0), |
||
| const glm::vec3 & | up = glm::vec3(0, 1, 0) |
||
| ) |
Creates a camera.
| pos | The position of the camera. |
| lookAt | The point the camera looks at. |
| up | The up vector for the camera. |
| void lookAt | ( | const glm::vec3 & | target = glm::vec3(0) | ) |
Set the point the camera will look at.
| target | The point as a vector. |
This point will be the center of the scene.
| void lookAt | ( | float | x = 0, |
| float | y = 0, |
||
| float | z = 0 |
||
| ) |
Set the point the camera will look at.
| x | The x position. |
| y | The y position. |
| z | The z position. |
| void rotate | ( | float | rad = 0, |
| const glm::vec3 & | axis = glm::vec3(0), |
||
| bool | around = true |
||
| ) |
Rotate the camera.
| rad | Angle to rotate by, in radians. |
| axis | Axis of rotation. |
| around | Rotate around center? |
Rotates the camera by rad radians around the axis. If around is true, the camera rotates while keeping the _lookAt at center, ie. the _pos changes; the camera rotates around the scene. If around is false, the camera rotates while keeping the _pos at center, ie. the _lookAt changes; the camera itself rotates.
| void rotate | ( | const glm::quat & | rot = glm::quat(1, 0, 0, 0), |
| bool | around = true |
||
| ) |
Rotate the camera with the quaternion.
| rot | Quaternion for rotation. |
| around | See rotate. |
| void rotateX | ( | float | rad = 0, |
| bool | around = true, |
||
| bool | safe = true |
||
| ) |
Rotate around the x-axis.
| rad | Angle to rotate by, in radians. |
| around | See rotate. |
| safe | Rotations beyond 90 degree along the x-axis might cause the render to flip abruptly. Setting this to true tries to prevent that. However, it isn't guaranteed that this will work. |
| void rotateY | ( | float | rad = 0, |
| bool | around = true |
||
| ) |
Rotate around the y-axis.
| rad | Angle to rotate by, in radians. |
| around | See rotate. |
| void rotateZ | ( | float | rad = 0, |
| bool | around = true |
||
| ) |
Rotate around the z-axis.
| rad | Angle to rotate by, in radians. |
| around | See rotate. |
| void setPos | ( | const glm::vec3 & | pos = glm::vec3(3, 4, 5) | ) |
Sets the position of the camera.
| pos | The position as a vector. |
| void setPos | ( | float | x = 3, |
| float | y = 4, |
||
| float | z = 5 |
||
| ) |
Sets the position of the camera.
| x | The x position. |
| y | The y position. |
| z | The z position. |
| void setUp | ( | const glm::vec3 & | up = glm::vec3(0, 1, 0) | ) |
Set the up-vector.
| up | The up vector. |
| void setUp | ( | float | x = 0, |
| float | y = 1, |
||
| float | z = 0 |
||
| ) |
Set the up-vector.
| x | The x component of the vector. |
| y | The y component of the vector. |
| z | The z component of the vector. |
| void setView | ( | const glm::mat4 & | mat | ) |
| void translate | ( | const glm::vec3 & | d = glm::vec3(0) | ) |
Translate (move, shift) the camera.
| d | Vector to translate by. |
| void translate | ( | float | dx = 0, |
| float | dy = 0, |
||
| float | dz = 0 |
||
| ) |
Translate (move, shift) the camera.
| dx | Amount to translate along the x-axis. |
| dy | Amount to translate along the y-axis. |
| dz | Amount to translate along the z-axis. |
| void viewRotate | ( | float | rad = 0, |
| const glm::vec3 & | axis = glm::vec3(0) |
||
| ) |
Rotate the view matrix.
| rad | Angle to rotate by, in radians. |
| axis | Axis of rotation. |
| void viewScale | ( | const glm::vec3 & | s = glm::vec3(1) | ) |
Scale the view matrix.
| s | Vector to scale by. |
| void viewScale | ( | float | sx = 1, |
| float | sy = 1, |
||
| float | sz = 1 |
||
| ) |
Scale the view matrix.
| sx | Amount to scale along the x-axis. |
| sy | Amount to scale along the y-axis. |
| sz | Amount to scale along the z-axis. |
| void viewTransform | ( | const glm::mat4 & | m | ) |
Transform the view matrix.
| m | Matrix to transform by. |
| void viewTranslate | ( | const glm::vec3 & | d = glm::vec3(0) | ) |
Translate the view matrix.
| d | Vector to translate by. |
| void viewTranslate | ( | float | dx = 0, |
| float | dy = 0, |
||
| float | dz = 0 |
||
| ) |
Translate the view matrix.
| dx | Amount to translate along the x-axis. |
| dy | Amount to translate along the y-axis. |
| dz | Amount to translate along the z-axis. |
| glm::vec3 _lookAt |
The point the camera looks at.
| glm::vec3 _pos |
The position of the camera.
| glm::vec3 _up |
The up vector for the camera.
| glm::mat4 view |
The view matrix.