23 #include "hx3d/graphics/cameras/camera.hpp" 25 #include "hx3d/graphics/gl.hpp" 26 #include "hx3d/math/vector_utils.hpp" 31 Camera::Camera(
const float width,
const float height,
const float near,
const float far):
33 direction(0.f, 0.f, -1.f),
38 viewportHeight(height)
43 target = glm::normalize(target);
45 if (target != glm::vec3(0)) {
46 float dot = glm::dot(target,
up);
47 if (std::abs(dot - 1) < 0.00001f) {
50 }
else if (std::abs(dot + 1) < 0.00001f) {
58 tmp = glm::cross(tmp,
up);
59 tmp = glm::normalize(tmp);
63 up = glm::normalize(
up);
77 glm::vec3 tmp(center);
void rotate(const float angle, const glm::vec3 axis)
Rotate the camera on one/multiple axes.
glm::vec3 up
Camera up vector.
Camera(const float width, const float height, const float near, const float far)
Create a camera with a viewport width and height.
void translate(const glm::vec3 vec)
Translate the camera.
glm::vec3 rotate(glm::vec3 vector, float angle, glm::vec3 axis)
Rotate a vector of an angle on one/multiple axis.
void lookAt(glm::vec3 target)
Look at target.
glm::vec3 position
Camera position.
void rotateAround(const glm::vec3 center, const float angle, const glm::vec3 axis)
Rotate the camera around one point, on one/multiple axes.
glm::vec3 direction
Camera direction.