Hi Adrien,

I'm trying to put a text on the top of a node, a sort of caption. This caption 
can be added for mutliple objects without being stacked with other captions. My 
idea is to add those caption to the global scene by getting the coordinates of 
the top of the followed node and project the text on the screen from the given 
coordinates.

Are you just trying to get the highest point of a node?

If so, just use the center of the node's bounds in X and Y, but the highest point in Z. You can get an approximate solution using

// node is your node
osg::Vec3 top = node->getBound().center() +
                node->getBound().radius() * osg::Vec3(0,0,1)

This won't work well for objects that are slim but not high (think of a box which is wide and deep but not high, so for example it has a size (100, 100, 1) ). In those cases the text will be too high above the object. You can get closer using the osgUtil::ComputeBoundsVisitor which just visits all drawables under your node and combines their bounding boxes into one bounding box which you can then get. Then using that bounding box, you can just use

// bb is the bounding box gotten from the ComputeBoundsVisitor
osg::Vec3 top(bb._max.x() - bb._min.x(),
              bb._max.y() - bb._min.y(),
              bb._max.z());

This all assumes that you're in Z-up as is default in OSG.

If this is not what you wanted, please clarify your question.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to