Hi OSG users
I try to add a child to a Node, and delete this child, and re-add a new child
in this node (in a infinity loop), but when I start my program, my software
crash (maybe a memory leak when i try to delete the child), how can i resolve
my problem
I work with OSG 1.2, and I can't upgrade.
Can you help me please ?
void MAPStiti::Birth()
{
_absTransform = new osg::MatrixTransform();
// Reports this information to the RTMaps console
ReportInfo("titi: Passing through Birth() method");
indexnode=0;
_firstTime=true;
}
void MAPStiti::Core()
{
if(_firstTime==true)
{
test();
TransmitNode(_absTransform.get(),"NodeOutput");
_firstTime=false;
}
test();
// Reports this information to the RTMaps console
ReportInfo("titi: Passing through Core() method");
Rest(100000);
}
void MAPStiti::Death()
{
// Reports this information to the RTMaps console
ReportInfo("titi: Passing through Death() method");
}
void MAPStiti::test()
{
osg::ref_ptr geom = new osg::Geometry;
osg::ref_ptr geode = new osg::Geode;
osg::ref_ptr coordo=new osg::Vec3Array;
osg::ref_ptr color = new osg::Vec4Array;
osg::ref_ptr drawElements = new
osg::DrawElementsUInt(osg::PrimitiveSet::QUADS,0);
drawElements->push_back(3);
drawElements->push_back(2);
drawElements->push_back(1);
drawElements->push_back(0);
coordo->push_back(osg::Vec3(0.0,0.0,0.0));
coordo->push_back(osg::Vec3(10.0,0.0,0.0));
coordo->push_back(osg::Vec3(10.0,10.0,0.0));
coordo->push_back(osg::Vec3(0.0,10.0,0.0));
color->push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
color->push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f));
color->push_back(osg::Vec4(0.0f,0.0f,1.0f,1.0f));
color->push_back(osg::Vec4(1.0f,0.0f,1.0f,1.0f));
geom->addPrimitiveSet(drawElements.get());
geom->setVertexArray( coordo.get() );
geom->setColorArray(color.get());
geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
geode->addDrawable(geom.get());
if(_firstTime==true)
{
_absTransform->addChild(geode.get());
indexnode=_absTransform->getChildIndex(geode.get());
}
else
{
_absTransform->replaceChild(_absTransform->getChild(indexnode),geode.get());
//_absTransform->removeChild(indexnode,1);
//_absTransform->insertChild(indexnode,geode.get());
indexnode=_absTransform->getChildIndex(geode.get());
}
}
Best regards
Charles (France)
Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org