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@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+unsubscr...@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@lists.openscenegraph.org >http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/mailman.84819.1587201260.7166.osg-users-openscenegraph.org%40lists.openscenegraph.org.
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/mailman.84819.1587201260.7166.osg-users-openscenegraph.org%40lists.openscenegraph.org.