[osg-users] addSlave messup main cameras stateset

suneel suresh compressor at gmail.com
Mon Apr 18 22:15:11 PDT 2011


hi in order to display a rectangle roi over the 3d scene i use the example provided in osg hud. however before drawing the roi i press a toggle selection button which gets the stateset of the main camera as given below


Code:

osg::StateSet *stateSet = osg_viewer->getCamera()->getOrCreateStateSet();
    osg::Point *pointState = (osg::Point*)stateSet->getAttribute(osg::StateAttribute::POINT);




The 2d rectangle is drawn by mouse drag using the handler function. In the handler function the slave camera is created and added to the viewer as addSlave. 


Code:

case(osgGA::GUIEventAdapter::PUSH): 
{
camera_slaveBBox = createBBoxCamera();
viewer->addSlave(camera_slaveBBox, false);
}




As the mouse the dragged the rectangle is drawn and all is good untill......On pressing the toggle selection button again in the first code "stateSet" is now returned NULL  :(  

Now if i comment

Code:

//commentviewer->addSlave(camera_slaveBBox, false)




then stateSet indeed has some value. whats is the problem?

[/code]

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








More information about the osg-users mailing list