openglrotationaxisprojection-matrixarcball

Implementing arcball rotation axis without projection matrix?


I have a question about implementing the arcball in opengl es, using Android Studio.

After calculating the rotation axis, I should reverse the axis through the rendering pipeline back to the object space, so that the rotation could be applied in the object space.

This part would be written like:

obj_rotateAxis = normalize(vec3(inverse(mat3(camera->projMatrix) * mat3(camera->viewMatrix) * mat3(teapot->worldMatrix)) * rotateAxis));

However, I heard that the correct form should be like:

obj_rotateAxis = normalize(vec3(inverse(mat3(camera->viewMatrix) * mat3(teapot->worldMatrix)) * rotateAxis));

where projMatrix is discarded. Why do we not consider the projection matrix when we implement the arcball, although projection transform is done for the object?


Solution

  • As far as I know, you use the arcBall to compute an angle of rotation you will apply to your object. When you want to rotate an object you want to make it rotate from the origin of the world (world matrice) or from the viewpoint (view matrice).

    The projection matrice doesn 't represent the actual location of your object. The farest you are located the smaller you will get you don't want the depth to have an effect on your rotation.

    So you compute the rotation from the view point or the origin and then you let the projection matrice do its job at render.