jPCT-AE - a 3d engine for Android > Support

Camera rotation issue

(1/2) > >>

AeroShark333:
Hello,

I got a small issue with camera rotations.
My camera automatically rotates around a spherical object like this:
1. Set camera position to center of sphere.
2. Apply rotations
3. Camera.MOVE_OUT
This all works fine but after a long while (let's say 8+ hours) the rotation around the sphere don't seem spherical any more (or the rotation pivot center has some offset).
But the spherical object that the camera is facing isn't in the center any more but slightly offset. The longer you wait the worse this offset gets.
I suppose it'd have to do something with floating point precision but I'm not sure.
Any solutions?

Cheers

EgonOlsen:
Yes, shoulds like some accuracy issue, but some your description, it's hard to tell where it comes from!? What does step 2/apply rotations actually do?

AeroShark333:
So I have a spherical object (which position changes every draw call).
For that, I need to move the camera along with the object which is step 1 (settings the camera's position to the center of the sphere)
But the user might have some touch interaction going on (which changes the camera rotation)
Also autorotation could be enabled (which also changes camera rotation)
I basically change the rotation of the camera while the camera is in the center of the spherical object.
And only after that I apply step 3 (Camera.MOVE_OUT), this makes sure that the camera faces the center of the spherical object.
But it's not like I'm using Camera.MOVE_OUT with diffferent radia, it's fixed.

EDIT: I just noticed that I swapped step 1 and step 2 in my code... but that still shouldn't matter I believe

Only when autorotation is enabled it will start to get messy after a while. (the spherical object is no longer perfectly in the center)
When you try to change the rotation with touch(or autorotation), it will look like the spherical object is also rotating around some (really small) pivot point (which isn't really there since it should just be the object's center)
But at launch (when autorotation hasn't been active for long) the rotation using touch (or autorotation) works fine and there's no weird offsets or extra 'pivot point'.

The spherical object does actually rotate around some pivot, but this position is reset every draw call (so I don't think it's related to this).
The camera's rotation is never reset so I think the issue might lie here... (long-term rotations causing accuracy issues)

_______________________
SIMPLIFIED CODE FOR DRAW CALLS:
_______________________
object.clearRotation();
object.clearTranslation();
object.translate(blahblah1);
object.rotate(blahblah2); // I personally don't think the issue is here since the rotations aren't accumulated but reset for every draw call

camera.rotateX(touchX+autorotationX);
camera.rotateX(touchY+autorotationY);
camera.rotateZ(dualTouchZ+autorotationZ);

camera.setPosition(object.getTransformedCenter());

camera.moveCamera(Camera.CAMERA_MOVEOUT, someRadius);

EgonOlsen:

--- Quote ---The camera's rotation is never reset so I think the issue might lie here...
--- End quote ---
Yes, most likely. You can try to apply http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Matrix.html#orthonormalize() from time to time to it and see if that helps.

AeroShark333:
I think this would solve the problem, thanks! :)
I'll report back later if I can test it

Navigation

[0] Message Index

[#] Next page

Go to full version