This commit is contained in:
Robert 2021-01-23 16:43:59 +01:00
parent a17c73d3c9
commit d74c49fed5
6 changed files with 34 additions and 19 deletions

View file

@ -57,13 +57,18 @@ namespace oglu
void Camera::LookAt(GLfloat x, GLfloat y, GLfloat z)
{
transformation = glm::lookAt(translation, glm::vec3(x, y, z), glm::vec3(0.0f, 1.0f, 0.0f));
glm::decompose(transformation, scale, orientation, translation, skew, perspective);
LookAt(glm::vec3(x, y, z));
}
void Camera::LookAt(const GLfloat* target)
{
LookAt(target[0], target[1], target[2]);
LookAt(glm::make_vec3(target));
}
void Camera::LookAt(const glm::vec3& target)
{
transformation = glm::lookAt(translation, target, glm::vec3(0.0f, 1.0f, 0.0f));
glm::decompose(transformation, scale, orientation, translation, skew, perspective);
}
void Camera::LookAt(const Transformable& target)

View file

@ -9,6 +9,8 @@
#include <texture.hpp>
#include <transformable.hpp>
#include <glm/gtc/type_ptr.hpp>
namespace oglu
{
AbstractShader::AbstractShader(const AbstractShader& other) :
@ -254,7 +256,7 @@ namespace oglu
void AbstractShader::SetUniform(GLint location, Transformable& v0, GLboolean transpose)
{
glUniformMatrix4fv(location, 1, transpose, v0.GetMatrix());
glUniformMatrix4fv(location, 1, transpose, glm::value_ptr(v0.GetMatrix()));
}
void AbstractShader::SetUniform1fv(const GLchar* name, GLsizei count, const GLfloat* value)

View file

@ -161,23 +161,23 @@ namespace oglu
glm::decompose(transformation, this->scale, orientation, translation, skew, perspective);
}
const float* Transformable::GetMatrix()
const glm::mat4& Transformable::GetMatrix()
{
return glm::value_ptr(transformation);
return transformation;
}
const float* Transformable::GetPosition() const
const glm::vec3& Transformable::GetPosition() const
{
return glm::value_ptr(translation);
return translation;
}
const float* Transformable::GetRotation() const
const glm::quat& Transformable::GetRotation() const
{
return glm::value_ptr(orientation);
return orientation;
}
const float* Transformable::GetScaling() const
const glm::vec3& Transformable::GetScaling() const
{
return glm::value_ptr(scale);
return scale;
}
}