Hi Sébastien,
Sébastien Champmartin wrote:
void GmlOsgObject::createGrid()
{
osg::ref_ptr <osg::PositionAttitudeTransform> root =
CameraManager::getSingletonPtr()->getRoot();
osg::ref_ptr <osg::Geode> gridGeode = new osg::Geode();
if(/*!gridGeodePtr*/gridDisplayed==false )
{
root->addChild(gridGeode.get());
> gridGeode->addDrawable(gridGeometryV.get());
gridGeode->addDrawable(gridGeometryH.get());
...
}
else
{
gridGeode->setNodeMask(0);
root->removeChild(gridGeode.get());
gridDisplayed=false ;
}
}
You're creating 'gridGeode' every time the function is called. So for the first call you
create a 'gridGeode' and add it to 'root'. For the next call you're creating *another*
'gridGeode' and try to remove that from the 'root'.
Make 'gridGeode' a member of your object and make sure you only create it once.
To make the grid invisible it's actually enough to call 'gridGeode->setNodeMask(0)' (as
you're already doing) to make it invisible and call 'setNodeMask(~0)' to make it visible
again.
Cheers,
/ulrich
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org