GLM Getting Forward from view matrix returns a weird non working output

Viewed 10

I've been trying to figure this out for at least 2 months by now, I need to implement a way on how to get the Forward Vector, I've tried multiple approaches but every single time it works for certain cases. I store the rotation as euler angles, I tried converting them to Quaternions, Tried getting the view matrix from inverting the model matrix and getting the 3 row of that matrix, and every single time I get a weird output. if the rotation is all zero, it works, if it is a multiple of 90 in any axis the output works, but if the rotation is let's say 45 degress it doesn't work, the output is -0.707107, Y: -0, Z: 0.707107 which doesn't make sense. How I get the Forward vector:

glm::mat4 inverted = glm::inverse(CreateMatrix());
glm::vec3 ret = glm::normalize(glm::vec3(inverted[2]));
0 Answers
Related