[osg-users] Update node color on demand

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Mon Nov 26 13:51:11 PST 2018


Hi Diego,

can you post your Visitor code? It can be something like missing calling
->dirty() on the color array or such

On Mon, Nov 26, 2018 at 8:30 PM Diego Mancilla <dmancillac at gmail.com> wrote:

> Hello,
>
> I have tried Eran's suggestion with no success. I have successfully
> created the handler, and it gets called but no color change...
>
> My current code:
>
> On main:
>
> Code:
> _lines = osgDB::readNodeFile("lines.dxf");
> _topo->setDataVariance(osg::Object::DYNAMIC);
> osg::Geode* geode = new osg::Geode;
>
> _mViewer->addEventHandler(new ColorHandler);
>
> ColorVisitor newColor;
> newColor.setColor( 1.0f, 0.0f, 0.0f );
> _lines->accept(newColor);
> geode->addChild(_lines);
> _mViewer->realize();
>
>
>
>
> The handler:
>
>
> Code:
> bool ColorHandler::handle(const osgGA::GUIEventAdapter& ea,
> osgGA::GUIActionAdapter& aa)
> {
>         if (ea.getEventType() == ea.USER)
>         {
>                 auto changeColorEvent = dynamic_cast<const
> ChangeColorEvent*>(ea.getUserData());
>                 if (changeColorEvent != nullptr)
>                 {
>                         std::cout << "Hola Handler!!!" << std::endl;
>                         std::cout << "new color: " <<
> changeColorEvent->r<<" "<< changeColorEvent->g<< " "<<
> changeColorEvent->b<<std::endl;
>                         ColorVisitor newColor;
>                         newColor.setColor(changeColorEvent->r,
> changeColorEvent->g, changeColorEvent->b);
>                         changeColorEvent->node->accept(newColor);
>                         return true;
>                 }
>         }
>         return false;
>
>
>
> Thank you!
>
> Cheers,
> Diego
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75245#75245
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20181126/4dc753f3/attachment.html>


More information about the osg-users mailing list