I'm currently working on a OpenGl Project and I have alot of difficulty understanding how arcball camera work. From what I have read online, all I have to do is to rotate a camera around a target and I dont have to worry about any others things. This is my code.
glm::vec4 cameraTarget = glm::vec4(InPointToFix.x, InPointToFix.y, InPointToFix.z, 1.0); const GLfloat x_Rotation = InPitchValue / 57.5829; const GLfloat y_Rotation = InYawValue / 57.5829; glm::mat4 tempoMatrix = InMatrix; tempoMatrix = glm::rotate(tempoMatrix, x_Rotation, glm::vec3(1.0, 0.0, 0.0)); tempoMatrix = glm::rotate(tempoMatrix, y_Rotation, glm::vec3(0.0, 1.0, 0.0)); glm::vec4 cameraPosition = (tempoMatrix * glm::vec4(1,1,1,1)); InMatrix = glm::lookAt(glm::vec3(cameraPosition), glm::vec3(cameraTarget), glm::vec3(0.0, 1.0, 0.0));
So, in my code, I get my previous View Matrix from the function and my angle parameters, I create a new tempoMatrix by using my old Matrix, I rotate it by the Yaw and pitch I received by the function, I then transform my tempo matrix into a vec4 (to be used as a vec3 later) and then I apply the change to my ViewMatrix I receive by reference.
What happen is that whenever I apply the change, the camera stays at the exact same position but just zoom out and out until I see nothing ...
It's been a while I'm trying to figure this out and I really need help with the ArcBall Camera.