-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransforms.h
36 lines (31 loc) · 1.21 KB
/
Transforms.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Transform header file to define the interface.
// The class is all static for simplicity
// You need to implement left, up and lookAt
// Rotate is a helper function
// Include the helper glm library, including matrix transform extensions
#ifndef GLM_FORCE_RADIANS
#define GLM_FORCE_RADIANS
#endif
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
// glm provides vector, matrix classes like glsl
// Typedefs to make code more readable
typedef glm::mat3 mat3 ;
typedef glm::mat4 mat4 ;
typedef glm::vec3 vec3 ;
typedef glm::vec4 vec4 ;
const float pi = 3.14159265 ; // For portability across platforms
class Transforms
{
public:
Transforms();
virtual ~Transforms();
static void left(float degrees, vec3& eye, vec3& up);
static void up(float degrees, vec3& eye, vec3& up);
static mat4 lookAt(const vec3& eye, const vec3 ¢er, const vec3& up);
static mat4 perspective(float fovy, float aspect, float zNear, float zFar);
static mat3 rotate(const vec3& axis, const float degrees) ;
static mat4 scale(const float &sx, const float &sy, const float &sz) ;
static mat4 translate(const float &tx, const float &ty, const float &tz);
static vec3 upvector(const vec3 &up, const vec3 &zvec) ;
};