SimpleGL  1.1.0
A framework for platform independent rendering
transform.cpp
Go to the documentation of this file.
1 
8 #include "SimpleGL/transform.hpp"
9 
10 #include <glm/gtc/matrix_transform.hpp>
11 
12 using namespace glm;
13 
14 namespace sgl {
15 
16  Model::Model(void) {
17  /* Nothing to do here */
18  }
19 
20  glm::mat4 Model::identity() {
21  return mat4();
22  }
23 
24  glm::mat4 Model::scale(float x, float y, float z) {
25  return Model::scale(vec3(x, y, z));
26  }
27 
28  glm::mat4 Model::scale(glm::vec3 vector) {
29  return Model::scale(mat4(), vector);
30  }
31 
32  glm::mat4 Model::scale(glm::mat4 matrix, float x, float y, float z) {
33  return Model::scale(matrix, vec3(x, y, z));
34  }
35 
36  glm::mat4 Model::scale(glm::mat4 matrix, glm::vec3 vector) {
37  return glm::scale(matrix, vector);
38  }
39 
40  glm::mat4 Model::translate(float x, float y, float z) {
41  return Model::translate(vec3(x, y, z));
42  }
43 
44  glm::mat4 Model::translate(glm::vec3 vector) {
45  return Model::translate(mat4(), vector);
46  }
47 
48  glm::mat4 Model::translate(glm::mat4 matrix, float x, float y, float z) {
49  return Model::translate(matrix, vec3(x, y, z));
50  }
51 
52  glm::mat4 Model::translate(glm::mat4 matrix, glm::vec3 vector) {
53  return glm::translate(matrix, vector);
54  }
55 
56  glm::mat4 Model::rotate(float angle, float x, float y, float z) {
57  return Model::rotate(angle, vec3(x, y, z));
58  }
59 
60  glm::mat4 Model::rotate(float angle, glm::vec3 vector) {
61  return Model::rotate(mat4(), angle, vector);
62  }
63 
64  glm::mat4 Model::rotate(glm::mat4 matrix, float angle, float x, float y, float z) {
65  return Model::rotate(matrix, angle, vec3(x, y, z));
66  }
67 
68  glm::mat4 Model::rotate(glm::mat4 matrix, float angle, glm::vec3 vector) {
69  /* angle needs to get calculated to radians */
70  return glm::rotate(matrix, glm::radians(angle), vector);
71  }
72 
73  View::View(void) {
74  /* Nothing to do here */
75  }
76 
77  glm::mat4 View::identity() {
78  return mat4();
79  }
80 
81  glm::mat4 View::lookAt(glm::vec3 eye, glm::vec3 center, glm::vec3 up) {
82  return glm::lookAt(eye, center, up);
83  }
84 
85  glm::mat4 View::lookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) {
86  return View::lookAt(vec3(eyeX, eyeY, eyeZ), vec3(centerX, centerY, centerZ), vec3(upX, upY, upZ));
87  }
88 
89  glm::mat4 View::lookAt(Camera camera) {
90  return View::lookAt(camera.position, camera.position + camera.front, camera.up);
91  }
92 
93  Projection::Projection(void) {
94  /* Nothing to do here */
95  }
96 
97  glm::mat4 Projection::identity() {
98  return mat4();
99  }
100 
101  glm::mat4 Projection::ortho(float left, float right, float bottom, float top, float zNear, float zFar) {
102  return glm::ortho(left, right, bottom, top, zNear, zFar);
103  }
104 
105  glm::mat4 Projection::frustum(float left, float right, float bottom, float top, float zNear, float zFar) {
106  return glm::frustum(left, right, bottom, top, zNear, zFar);
107  }
108 
109  glm::mat4 Projection::perspective(float fovy, float aspect, float zNear, float zFar) {
110  /* fovy needs to get calculated to radians */
111  return glm::perspective(glm::radians(fovy), aspect, zNear, zFar);
112  }
113 }
glm::vec3 front
The front side direction of the camera.
Definition: transform.hpp:29
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
This struct defines a camera.
Definition: transform.hpp:23
glm::vec3 position
The position of the camera.
Definition: transform.hpp:26
glm::vec3 up
The up vector if the camera.
Definition: transform.hpp:32