Re: [osg-users] Get the top coordonates from screen of an object
Hi, you can set the text position in 3D coords without worrying how they are projected to the screen. Text already has a mode to draw itself screen aligned and make the characters the same size no matter how far from the camera. e.g. mTextLabel-setAxisAlignment(osgText::Text::SCREEN); mTextLabel-setCharacterSizeMode(osgText::Text::SCREEN_COORDS); The same can be done for for e.g. icons using Autotransform. jp Adrien Joly wrote: Hi, 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. Here are my questions: Have you got a better idea? How can I get the top of the Node directly (I thought to use the LineSegment and BoundingSphere)? Is there an easier (and better for performances) way to get them? Thank you for your answers! Cheers, Adrien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16077#16077 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Get the top coordonates from screen of an object
Hi, 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. Here are my questions: Have you got a better idea? How can I get the top of the Node directly (I thought to use the LineSegment and BoundingSphere)? Is there an easier (and better for performances) way to get them? Thank you for your answers! Cheers, Adrien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16077#16077 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Get the top coordonates from screen of an object
Hi Adrien, I'm afraid I don't have an answer for you, but I am about to attempt to do the same thing, so would be interested to hear the answer. Any ideas OSG community? Thanks, Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16097#16097 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Get the top coordonates from screen of an object
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 Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org