Guest User

camera.h

a guest
Jun 27th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <GLFW\glfw3.h>
  4. #include <glm\glm.hpp>
  5. #include <glm\gtc\matrix_transform.hpp>
  6. #include <glm\gtc\type_ptr.hpp>
  7.  
  8. class camera
  9. {
  10. public:
  11.     glm::vec3 cameraPos;
  12.     glm::vec3 cameraFront;
  13.     glm::vec3 cameraUp;
  14.     float speed;
  15.     float yaw;
  16.     float pitch;
  17.  
  18.     camera(glm::vec3 _pos, glm::vec3 _front, glm::vec3 _up, float _speed)
  19.     {
  20.         cameraPos = _pos;
  21.         cameraFront = _front;
  22.         cameraUp = _up;
  23.         speed = _speed;
  24.     }
  25.  
  26.     glm::mat4 lookAt()
  27.     {
  28.         return glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp);
  29.     }
  30.  
  31.     void update()
  32.     {
  33.         glm::vec3 front;
  34.         front.x = cos(glm::radians(pitch)) * cos(glm::radians(yaw));
  35.         front.y = sin(glm::radians(pitch));
  36.         front.z = cos(glm::radians(pitch)) * sin(glm::radians(yaw));
  37.         cameraFront = glm::normalize(front);
  38.     }
  39. };
Advertisement
Add Comment
Please, Sign In to add comment