I'm want to control the direction my camera looks, so I'm using Euler angles, so rotating around an axis is relative to rotation around previous axis. Something like this.
I want to always rotate using the blue axes. So I'm using three separate matrices to track rotation along their respective axes.
...
glm::vec3 mulVec (glm::mat4 const&, glm::vec3&);
glm::vec3 camPos = glm::vec3(0.0f, 1.0f, 0.0f);
glm::vec3 target = glm::vec3(0.0f, 0.0f, -5.0f);
glm::vec3 camup = glm::vec3(0.0f, 1.0f, 0.0f);
tulsi::ModelInput a1;
while (1) {
...
a1.tick(); // Tracks user input.
glm::mat4 lookat = glm::lookAt(
camPos,
mulVec(a1.yAxis * a1.xAxis, target),
mulVec(a1.yAxis * a1.xAxis, camup)
);
...
}
I get the desired output (rotate around x axis then y)
But when I switch the order of multiplication, I get different output (rotate around y then x axis)
glm::mat4 lookat = glm::lookAt(
camPos,
mulVec(a1.xAxis * a1.yAxis, target),
mulVec(a1.xAxis * a1.yAxis, camup)
);
So whats happening here. I'm assuming the order should not matter.