Search code examples
androidlibgdx

Libgdx camera rotate around on a center point with EulerAngles


Here is my code:

private Quaternion getRotatedQuaternion(float pitch, float yaw, float roll) {
    tempQuat.setEulerAngles(pitch, yaw, roll);
    rotationQuat.mulLeft(tempQuat);

    return rotationQuat;
}

and

            camera.view.setToLookAt(tempPos, tempLookat, Axis.UP);

            Quaternion rotQuat = getRotatedQuaternion(gestureListener.getXAngle(), gestureListener.getYAngle(), 0);
            camera.view.rotate(rotQuat);
            camera.combined.set(camera.projection);

            Matrix4.mul(camera.combined.val, camera.view.val);

This is a camera rotation in the center, on 0,0,0. Gimbal lock probleme solved by this way. But how can I add a new center point to it?

Basically I want to rotate the camera around my object, not 0,0,0

Thanks


Solution

  • I ended up with two matrox rotation and a vector to use as an arcball rotation