0
votes

Can't seem to find the solution to my following problem. I have a perspective cam set up in libGDX. I use the .rotateAround routine to rotate my camera. This works perfectly when rotating around low coords. But the higher the coordines of the axis to rotate around, the more jerky the rotation is becoming.

In my CameraInputController Class:

@Override
protected boolean process(float deltaX, float deltaY, int button) {

        if (button == Buttons.LEFT) {

        // DRAG CAMERA

        } else if (button == Buttons.RIGHT) {

        // ROTATE CAMERA
        perspectiveCam.rotateAround(new Vector3(clickedX, clickedY, 0), Vector3.Z, deltaX * -100);

        } 

    return true;
}

This works:

perspectiveCam.rotateAround(new Vector3(0f, 0f, 0f), Vector3.Z, deltaX * -100) 

The following code results in small portions dragging, followed by a sudden rotation, then dragging again, etc:

perspectiveCam.rotateAround(new Vector3(100000f, 100000f, 0f), Vector3.Z, deltaX * -100)

I know it works by translating, then rotating the cam, and then translating the camera back. Can anyone point me in the right direction? Is it something in the radius/float value?

Thanks in advance!

EDIT: See here for the 'bug': rotating gif

1
im curiouos, what value does Vector3.Z return? O.oHllink
Vector3.Z is a new Vector3(0,0,1)! The axis I am turning my camera around... EDIT: the first parameter Vector 3 is the point where the rotation vector is set, the second parameter is the axis to rotate around (Vector.Z), the third parameter is the angle (float).user2150129

1 Answers

0
votes

I found my answer here: https://gamedev.stackexchange.com/questions/57547/vertices-shaking-with-large-camera-position-values

I didn't know this was a thing. Floating point precision on high position values. The answer is to move my meshes closer to (0,0,0).