hi all,

I made a class who have to draw a simple line (see below)
but I don't know why when I delete CLine class, the line is always visible
(but the class is well deleted)

I put the code of the class.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class CLine{


       private:
               osg::ref_ptr<osg::Geode> SegmentGeode;
               osg::ref_ptr<osg::Geometry> SegmentGeometry;

      public:

               CLine(  double x1,double y1,double z1, double x2,double
y2,double z2);

       ~CLine();

};
-----------------------------------------------------------------------------------------------------------------


CLine::CLine(  double x1,double y1,double z1,
               double x2,double y2,double z2){

       SegmentGeode = new osg::Geode();   //
       SegmentGeometry = new osg::Geometry();

       SegmentGeode->addDrawable(SegmentGeometry.get());
       CGeneral::instance().root->addChild(SegmentGeode.get());

       osg::Vec3Array* SegmentVertices = new osg::Vec3Array;
       SegmentVertices->push_back( osg::Vec3( x1, y1, z1) );
       SegmentVertices->push_back( osg::Vec3( x2, y2, z2) );

       SegmentGeometry->setVertexArray( SegmentVertices );
       osg::DrawElementsUInt* SegmentBase = new
osg::DrawElementsUInt(osg::PrimitiveSet::LINES, 0);
       SegmentBase->push_back(0);
       SegmentBase->push_back(1);
       SegmentGeometry->addPrimitiveSet(SegmentBase);

       osg::Vec4Array* colors = new osg::Vec4Array;
       colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
       SegmentGeometry->setColorArray(colors);
       SegmentGeometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);

       CGeneral::instance().root->addChild(SegmentGeode.get());
}

CLine::~CLine(){

       CGeneral::instance().root->removeChild(SegmentGeode.get());
       SegmentGeode = 0;

}




THANKS;

a++++
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to