Hi Delport,

I am attaching the code i put inside the keyboard handler. I believe it will 
provide you with more insight to suggest.

****************************************************************'
class BlurPassHandler : public osgGA::GUIEventHandler
{

public:
    BlurPassHandler(int key,BlurPass *bp,osg::Node *node):
        _bp(bp),
        _node(node),
        _key(key)
    {

    }

    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
    {
        if (ea.getHandled()) return false;

        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                    osg::notify(osg::NOTICE)<<"event handler"<<std::endl;

                    if(ea.getKey() == _key)
                    {
                        //find the node with the name in the parameter
                        FindNamedNode fnn("HUD");

                        _node->accept(fnn);

                        if(!_bp->shaderActive())
                            _bp->activateShader();
                        else
                        {
                             osg::notify(osg::NOTICE)<<"About to 
flip"<<std::endl;
                             _bp->flip();

                             //the hud cameara texture
                             //has to be updated, either
                             //after updating the shader
                             //or after doing the flip
                        }

                        if(fnn.getNode() != NULL)
                        {
                            osg::notify(osg::NOTICE)<<"HUD found"<<std::endl;

                            //assign to local node variable
                            _node = fnn.getNode();

                            osg::Geode *_geode = 
dynamic_cast<osg::Geode*>(_node);

                            if(_geode)
                            {
                               osg::notify(osg::NOTICE)<<"geode 
found"<<std::endl;

                               osg::Geometry *_geometry = 
dynamic_cast<osg::Geometry*>(_geode->getDrawable(0));

                               if(_geometry)
                               {
                                   osg::notify(osg::NOTICE)<<"geometry 
found"<<std::endl;
                               }

                               osg::StateSet *_stateset = 
_geometry->getOrCreateStateSet();

                               _stateset->setTextureAttributeAndModes(0, 
_bp->getOutputTexture().get(),osg::StateAttribute::ON);
                            }
                        }
                        else
                        {
                            osg::notify(osg::NOTICE)<<"HUD not 
found"<<std::endl;
                        }


                        return true;
                    }

                    break;
            }
        default:
            break;
        }

        return false;
    }


    BlurPass *_bp;
    osg::Node *_node;
    int _key;

};

***************************************************************** 

Thank you!

Cheers,
Sajjadul

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=34831#34831





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to