hi,

As anyone already tried to have a camera track a mobile object ?
How is it supposed to be done using OSGViewer ?
if someone has some sample code, it would be welcome.

here is what I have tried, so far :

I'm using the OSGViewer, and I'm trying to have a camera follow a mobile 
object.
First, I had tried to attach the camera to the scenegraph where my 
object was. But after looking thoroughly through the OSGViewer source 
code, I realised that the rendering is done by linking the scenegraph to 
the active camera and perform an inverse transform of the desired camera 
position to the scenegraph. This means that adding the camera to the 
scenegraph create a cycle loop in the scenegraph, causing the OSGViewer 
to enter an infinite loop, ending in a stack overflow. So this seemed 
not to be the good way.

So, I realised that I had no escape but use a CameraManipulator to 
position my camera in the scenegraph.

Then I tried to move my object in the scene, in a kind of brute force 
way, by forcing the parent MatrixTransform of my mobile object with an 
updated matrix according to the movement I desired. This didn't work, as 
it seems that the scenegraph is either locked by the OSGViewer, or 
simply managed in a separate thread that prevents users to temper with 
the Scenegraph directly.

So I just resigned in using a NodeTrackerManipulator to set and schedule 
the movement I wanted.

Now, the problem is, I would like my camera to act as if it were linked 
to the moving object. I tried using the setNode method of my 
CameraManipulator, but it will only work for static objects. But 
whenever my object is moved by a NodeTrackerManipulator, the camera will 
be positionned to a default Home Position.
I tried to use the same animationPath for the mobile object and the 
camera, but there seems to be no way of handling an animationPath with a 
CameraManipulator, as it can be done with a NodeTrackerManipulator (it 
seems not possible to assign an updateCallback for the Camera, as can be 
done for a Node). So I can't set the speed along the path for the 
camera, and, even if I could, anyway, my camera will not actually follow 
the mobile object, but only follow the same path as my mobile object 
(and would seem to follow the mobile object only if I would synchronise 
the start of the movement for both camera and mobile object, which is 
not what I want, as I would like to switch to a follow mode at anytime 
of the movement)

thanks for your help

C.L

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to