[osg-users] How to traverse the adjacent drawables
OpenSceneGraph Users
osg-users at lists.openscenegraph.org
Sat Apr 18 02:14:16 PDT 2020
I think the easiest is to give the labels a certain name, then use a NodeVisitor and implement apply(Text3D) checking the name and setting the new font.
On 18. April 2020 09:54:24 MESZ, OpenSceneGraph Users <osg-users at lists.openscenegraph.org> wrote:
>I want to set the font of the axes labels(X,Y,Z) using GUI so I
>traverse
>through the scenegraph, to access the axis labels(X,Y,Z) which are
>text3D
>nodes. The function getLabelText3D(..) returns the drawables as text3D
>and
>later set the font of the drawable by setFont() but the font style
>only
>gets applied on X label but not Y,Z. Now how do I access the remaining
>drawables.
>
>
>osgText::Text3D* AxesNode::getLabelText3D(::osg::Node* axes)
> {
> osg::Switch *switch_node = getLabelSwitch(axes); // returns the
>switch node which has the Geode to which X,Y,Z text3D nodes are added
>as
>drawables.
> if(!switch_node)
> {
> return NULL;
> }
>
> osg::Node* node = switch_node->getChild(0);
> osg::Geode* geode_node = node->asGeode();
> if(geode_node && geode_node->getNumDrawables() > 1)
> {
> for(osg::Drawable* drawable : geode_node->getDrawableList())
> {
> osgText::Text3D* text =
>dynamic_cast<osgText::Text3D*>(drawable); //here I have three
>drawables
>X,Y,Z but the function only returns X drawable
> if(text)
> {
> return text;
> }
> }
> }
> return NULL;
> }
>
>
>
>void Vizkit3DWidget::setFont(....)
>{
>
> osg::Node *node = FindNode::find(*getRootNode(),"axes_node");
>
> osgText::Text3D* text3d =
>AxesNode::getLabelText3D(switch_node->getChild(0));
>
> text3d->setFont(font_d.get()); //only sets font for
>X label, no effect on Y,Z label
>
>emit propertyChanged("font");
>}
>
>
>
>
>--
>You received this message because you are subscribed to the Google
>Groups "OpenSceneGraph Users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to osg-users+unsubscribe at googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/osg-users/3f457cd4-2760-45a9-a376-361612aa312f%40googlegroups.com.
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>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/20200418/ca9839da/attachment.html>
More information about the osg-users
mailing list