i forgot
This commit is contained in:
parent
a17c73d3c9
commit
d74c49fed5
|
@ -88,7 +88,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
shader->Use();
|
shader->Use();
|
||||||
shader->SetUniform("model", utah);
|
shader->SetUniform("model", utah);
|
||||||
shader->SetUniformMatrix4fv("view", 1, GL_FALSE, camera.GetMatrix());
|
shader->SetUniform("view", camera);
|
||||||
shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, camera.GetProjectionMatrix());
|
shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, camera.GetProjectionMatrix());
|
||||||
|
|
||||||
oglu::PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
oglu::PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
|
|
@ -78,6 +78,16 @@ namespace oglu
|
||||||
*/
|
*/
|
||||||
void LookAt(const GLfloat* target);
|
void LookAt(const GLfloat* target);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Have camera face at a certain position.
|
||||||
|
*
|
||||||
|
* This will adjust the camera's rotation in order to put the
|
||||||
|
* specified coordinate at the center of the screen.
|
||||||
|
*
|
||||||
|
* @param[in] target 3D vector with the target position
|
||||||
|
*/
|
||||||
|
void LookAt(const glm::vec3& target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Have camera face at a certain position.
|
* @brief Have camera face at a certain position.
|
||||||
*
|
*
|
||||||
|
@ -88,8 +98,6 @@ namespace oglu
|
||||||
*/
|
*/
|
||||||
void LookAt(const Transformable& target);
|
void LookAt(const Transformable& target);
|
||||||
|
|
||||||
// void Move(float x, float y, float z) override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the projection matrix of the camera.
|
* @brief Gets the projection matrix of the camera.
|
||||||
*
|
*
|
||||||
|
|
|
@ -307,28 +307,28 @@ namespace oglu
|
||||||
*
|
*
|
||||||
* @return An array of 16 floats representing the transformation matrix
|
* @return An array of 16 floats representing the transformation matrix
|
||||||
*/
|
*/
|
||||||
const float* GetMatrix();
|
virtual const glm::mat4& GetMatrix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get position as a 3D vector.
|
* @brief Get position as a 3D vector.
|
||||||
*
|
*
|
||||||
* @returns A pointer to an array of floats
|
* @returns A pointer to an array of floats
|
||||||
*/
|
*/
|
||||||
const float* GetPosition() const;
|
virtual const glm::vec3& GetPosition() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get rotation as a matrix.
|
* @brief Get rotation as a matrix.
|
||||||
*
|
*
|
||||||
* @returns A pointer to a 4x4 matrix
|
* @returns A pointer to a 4x4 matrix
|
||||||
*/
|
*/
|
||||||
const float* GetRotation() const;
|
virtual const glm::quat& GetRotation() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get scaling as a 3D vector.
|
* @brief Get scaling as a 3D vector.
|
||||||
*
|
*
|
||||||
* @returns A pointer to an array of floats
|
* @returns A pointer to an array of floats
|
||||||
*/
|
*/
|
||||||
const float* GetScaling() const;
|
virtual const glm::vec3& GetScaling() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// TODO: Separate translation, rotation and scaling matrices.
|
// TODO: Separate translation, rotation and scaling matrices.
|
||||||
|
|
|
@ -57,13 +57,18 @@ namespace oglu
|
||||||
|
|
||||||
void Camera::LookAt(GLfloat x, GLfloat y, GLfloat z)
|
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));
|
LookAt(glm::vec3(x, y, z));
|
||||||
glm::decompose(transformation, scale, orientation, translation, skew, perspective);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::LookAt(const GLfloat* target)
|
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)
|
void Camera::LookAt(const Transformable& target)
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <texture.hpp>
|
#include <texture.hpp>
|
||||||
#include <transformable.hpp>
|
#include <transformable.hpp>
|
||||||
|
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
namespace oglu
|
namespace oglu
|
||||||
{
|
{
|
||||||
AbstractShader::AbstractShader(const AbstractShader& other) :
|
AbstractShader::AbstractShader(const AbstractShader& other) :
|
||||||
|
@ -254,7 +256,7 @@ namespace oglu
|
||||||
|
|
||||||
void AbstractShader::SetUniform(GLint location, Transformable& v0, GLboolean transpose)
|
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)
|
void AbstractShader::SetUniform1fv(const GLchar* name, GLsizei count, const GLfloat* value)
|
||||||
|
|
|
@ -161,23 +161,23 @@ namespace oglu
|
||||||
glm::decompose(transformation, this->scale, orientation, translation, skew, perspective);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue