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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to