Skip to content

Instantly share code, notes, and snippets.

@terryjsmith
Created October 7, 2014 00:21
Show Gist options
  • Save terryjsmith/5363b4a77a0b1232a1ee to your computer and use it in GitHub Desktop.
Save terryjsmith/5363b4a77a0b1232a1ee to your computer and use it in GitHub Desktop.
Evolution Camera implementation
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include <camera.h>
Camera::Camera() {
translation = glm::vec3(0.0f, 0.0f, 0.0f);
look = glm::vec3(0.0f, 0.0f, -1.0f);
up = glm::vec3(0.0f, 1.0f, 0.0f);
right = glm::vec3(1.0f, 0, 0.0f);
rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
fnear = 0.1f;
ffar = 100.0f;
fov = 45.0f;
aspect = 1.3f;
}
Camera::~Camera() {
}
void Camera::SetTranslation(float x, float y, float z) {
translation = glm::vec3(x, y, z);
}
void Camera::Move(float x, float y, float z) {
translation += glm::vec3(x, y, z);
}
void Camera::Rotate(float degrees, glm::vec3 axis) {
glm::quat delta = glm::angleAxis(glm::radians(degrees), axis);
rotation = rotation * delta;
look = look * delta;
up = up * delta;
right = right * delta;
}
void Camera::SetLookAt(float x, float y, float z) {
look = glm::vec3(x, y, z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment