Hi guys,

I'm trying to use a keyboard handler class to toggle wireframe , texture , 
lighting etc. I followed the online tutorials and this is what i did - i 
created a new class derived from GUIEventHandler. and overid the "handle" 
function. 

                osg::StateSet* TerrainState = 
pTerrainNode->getOrCreateStateSet() ;
                TerrainState->clear() ;
                
                osg::PolygonMode* pTerrainPolygonMode = NULL ;
                pTerrainPolygonMode = dynamic_cast<osg::PolygonMode*> 
(TerrainState->getAttribute(osg::StateAttribute::POLYGONMODE)) ;
                
                if(pTerrainPolygonMode == NULL)
                {
                    pTerrainPolygonMode = new osg::PolygonMode() ;
                }

                pTerrainPolygonMode->setMode(osg::PolygonMode::FRONT_AND_BACK , 
osg::PolygonMode::FILL) ;
                TerrainState->setAttribute(pTerrainPolygonMode , 
osg::StateAttribute::ON) ;


The inherited keyboard handler class has pTerrainNode which gets the address of 
the geometry node in its constructor..

I had already set the attributes prior to rendering as lines. Now i want to 
render it as filled polygons or points...when invoking the keyboard handler , 
this is what i did..(in the main function)


    TerrainKeyboardEventHandler *keh = new 
TerrainKeyboardEventHandler(root.get()) ;
    osgViewer::Viewer viewer ;
    
    viewer.setSceneData( root.get() ) ;
    viewer.addEventHandler(keh) ;
    
    keh->AddFunction('w' , RenderWireframe) ;
    keh->AddFunction('v' , RenderPoints) ;
.
.
.


I dont understand what is wrong..I am using Visual Studio 2005 , osg 1.9.7 on 
xp.

Any hints , tips or suggestions would greatly help me. Thanks.


Siddharth



       
____________________________________________________________________________________Ready
 for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to