[osg-users] Working with osg::Text on animation

Ravi Mathur ravidavi at utexas.edu
Thu Dec 20 12:51:27 PST 2018


If you will be dynamically changing your text, then specify that when you
first create it:
    osgText::Text* text = new osgText::Text;
    text->setDataVariance(osg::Object::DYNAMIC);
Note that setting the data variance is important for multithreaded Viewers
<http://forum.openscenegraph.org/viewtopic.php?t=10441&view=next>.

Then you can change the text easily:
    text->setText("insert dynamically-generated string here");

You can show/hide the text with its node mask:
    text->setNodeMask(0x0); // NodeMask = 0 to hide
    text->setNodeMask(~0x0); // NodeMask = 0xffffffff to show

Hope that helps,
Ravi

On Thu, Dec 20, 2018 at 8:39 AM Diego Mancilla <dmancillac at gmail.com> wrote:

> Hello,
>
>  I have a couple of doubts regarding the proper way of handling osg::Text
> inside an animation.
>
>  For the sake of simplicity lets say we are working on the osganimate
> example, and we have multiple cessna moving around.
>
> 1- What is the proper way of changing the text of osg::Text on runtime?
> For instance, if I want to display current position of cessna.
>
> 2- How can I hide/show the current value of the text on user request
> (stoke of key for example).
>
> Thank you!
>
> Cheers,
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75329#75329
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20181220/a1258200/attachment.html>


More information about the osg-users mailing list