Added normal matrices to transformable
This commit is contained in:
parent
b3e82ca9df
commit
862ef6d34b
|
@ -274,7 +274,7 @@ int main(int argc, char** argv)
|
|||
for (oglu::Object& cube : cubes)
|
||||
{
|
||||
shader->SetUniform("model", cube);
|
||||
shader->SetUniformMatrix3fv("normal", 1, GL_FALSE, glm::value_ptr(glm::mat3(glm::transpose(glm::inverse(cube.GetMatrix())))));
|
||||
shader->SetUniformMatrix3fv("normal", 1, GL_FALSE, glm::value_ptr(cube.GetNormalMatrix()));
|
||||
cube.Render();
|
||||
}
|
||||
|
||||
|
|
|
@ -351,6 +351,15 @@ namespace oglu
|
|||
*/
|
||||
virtual const glm::mat4& GetMatrix();
|
||||
|
||||
/**
|
||||
* @brief Returns a normal matrix.
|
||||
*
|
||||
* For use in shaders to compute normals of surfaces.
|
||||
*
|
||||
* @return A 3x3 normal matrix
|
||||
*/
|
||||
glm::mat3 GetNormalMatrix();
|
||||
|
||||
/**
|
||||
* @brief Get position as a 3D vector.
|
||||
*
|
||||
|
|
|
@ -197,6 +197,11 @@ namespace oglu
|
|||
return transformation;
|
||||
}
|
||||
|
||||
glm::mat3 Transformable::GetNormalMatrix()
|
||||
{
|
||||
return glm::mat3(glm::transpose(glm::inverse(GetMatrix())));
|
||||
}
|
||||
|
||||
const glm::vec3& Transformable::GetPosition() const
|
||||
{
|
||||
return translation;
|
||||
|
|
Loading…
Reference in a new issue