Saxum/camera.cc

57 lines
1.1 KiB
C++
Raw Normal View History

2014-11-13 16:17:46 +00:00
#include "camera.hh"
Camera::Camera(glm::vec2 rotation, float distance) {
2014-11-13 16:17:46 +00:00
this->rotation = rotation;
this->distance = distance;
}
Camera::Camera() {
rotation = glm::vec2(0.0f, 0.0f);
2014-11-13 16:17:46 +00:00
distance = 1.0f;
}
Camera::~Camera() {
}
float Camera::getDistance() {
return distance;
}
void Camera::setDistance(float distance) {
this->distance = distance;
}
glm::vec2 Camera::getRotation() {
2014-11-13 16:17:46 +00:00
return rotation;
}
void Camera::setRotation(glm::vec2 rotation) {
2014-11-13 17:17:58 +00:00
this->rotation = rotation;
}
void Camera::updateRotation(glm::vec2 rotation) {
if((this->rotation.x + rotation.x) >= 1.57f) {
this->rotation.x = 1.57;
this->rotation.y += rotation.y;
}
else if ((this->rotation.x + rotation.x) <= -1.57f) {
this->rotation.x = -1.57f;
this->rotation.y += rotation.y;
}
else {
this-> rotation += rotation;
}
2014-11-13 16:17:46 +00:00
}
2014-11-15 13:26:17 +00:00
void Camera:: updateDistance(float distance) {
if (this->distance + distance <= 1.0f) {
this->distance = 1.0f;
}
else if (this->distance + distance >= 100.0f) {
this->distance = 100.f;
}
else {
this->distance += distance;
}
}