[osg-users] Using a manipulator to follow a moving object

147 views
Skip to first unread message

Brian Palmer

unread,
Dec 8, 2010, 4:14:47 PM12/8/10
to osg-...@lists.openscenegraph.org
Hi,

I'm working on an application where the initial scene is scene is very large. However, as the user adds smaller objects to the scene I want the camera to be able to follow the objects. I'd like to be able to center the manipulator on an object and follow the object along a path.

I'm trying to use the orbitalManipulator's setTransformation function to do this by calculating an eye vector (based on a North East Down offset from the center and rotation back to X,Y,Z), a center (the object's position), and an up vector (the unit vector of the object's position). I can run the model and printout what appear to be valid vectors for the eye, center, and up, but the camera appears to be looking at my object from the wrong direction.

Does my approach seem logical, and is there some obvious coordinate conversion that I'm not doing to go between global (x,y,z -model coordinates) to viewing (cameraManipulator) coordinates?

ViewerQT* canvas;

canvas->getCameraManipulator()->setTransformation(eye, center, up);

Thank you!

Cheers,
Brian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=34638#34638

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Brian Palmer

unread,
Dec 9, 2010, 2:10:57 AM12/9/10
to osg-...@lists.openscenegraph.org
Hi,

Sorry, I missed this reference in the wiki. I'll try to do better next time. I haven't got this working yet, but can't help but think this will be the right way to implement what I'm looking for.

Thank you!

Cheers,
Brian

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=34651#34651

Brian Palmer

unread,
Dec 10, 2010, 12:35:53 AM12/10/10
to osg-...@lists.openscenegraph.org
Hi,
How do I get the NodeTrackerManipulator to be relatively close to the node it is following? I've tried calling setDistance to no avail. It is seems to be using the boundingSphere of the base node as opposed to the node I'm trying to track. I don't where in the NodeTrackerManipulator the distance is set. It appears to follow in center and rotation only. Any ideas on how to get the NodeTrackerManipulator to follow a smaller object in a larger scene?

Thank you!

Cheers,
Brian

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=34680#34680

Robert Osfield

unread,
Dec 10, 2010, 2:38:57 AM12/10/10
to osg-...@lists.openscenegraph.org
HI Brian,

NodeTrackerManipulator used to set it's distance relative to the node
being tracked, so what you describe is a regression that must have
been introduced when I merged a submission that re-factored the
manipulators to make them more flexible. I can't fix this right away
as I'm heads down on another task right now.

Robert.

Reply all
Reply to author
Forward
0 new messages