[osg-users] Arcball Camera without unexpecting 'roll' of the camera

Daniel Neos daniel.rd at hotmail.de
Mon May 16 05:59:07 PDT 2016

Hi everyone,

I have implemented a Cameramanipulator by myself, because I need more individually control over the camera in the scene, like rotating around a specific axis.

I let osg compute the Boundingsphere of my scene and set the rotationpoint and the lookat-point or center-point at the center of the Boundingsphere.

My rotation works like this

1.) Translate the camera to the center of the Boundingsphere (Multiplicated from the right side of the viewmatrix of the camera fist)

2.) Rotate the viewmatrix by the OSG::x_axis and OSG::y_axis (depending on the mousemovement)

3.) Translate the camera back with the vector from step 1.

4.) Now with the last step I ensure, that the camera stays focused at the samepoint by getting the eye, center and up vector and reseting the center vector, while eye and up remains the same.

This usually works fine and it is easy to navigate through the scene with the mouse, but as I reach some regions the camera unexpectedly seem to rotate around its own z-axis which results in to a 'roll'.

How can I prevent this behaviour? Sample code with arcball camera would be appreciated too :)

Thank you!


Read this topic online here:

More information about the osg-users mailing list