Hi Praveena,

On 5/07/12 23:19 , Praveena Sara wrote:
> Code:
> osg::ref_ptr<osg::Geometry> beam = new osg::Geometry; 
> 
> osg::ref_ptr<osg::Vec3Array> points = new osg::Vec3Array; 
> points->push_back(StartPoint); 
> points->push_back(EndPoint); 
> 
> osg::ref_ptr<osg::Vec4Array> color = new osg::Vec4Array; 
> color->push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f)); 
> 
> beam->setVertexArray(points.get()); 
> beam->setColorArray(color.get()); 
> beam->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE); 
> beam->addPrimitiveSet(new osg::DrawArrays(GL_LINES,0,2));
> 
> osg::ref_ptr<osg::Geode> geode = new osg::Geode; 
> geode->addDrawable(beam.get() );
> 
> 
> osg::ref_ptr<osg::LineWidth> lineWidth = new osg::LineWidth;
> lineWidth->setWidth(5.0f);
> 
> osg::StateSet* stateset = geode->getOrCreateStateSet();
> stateset->setAttribute(lineWidth.get());
> stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
> 
> pat->addChild(geode); //osg::PositionAttitudeTransform 
> 
> 
> 
> The lines are drawn precisely but the screen is not refreshed, thus it keeps 
> all the
> previously drawn lines. (Screenshot attached)

It's not really possible to tell what might be going wrong based on the code 
fragment
you've provided.  Is this setup code?  Called every time for a new line?

You're apparently creating a new osg::Geode with a new osg::Drawable every time 
and adding
the geode to an existing osg::PositionAttitudeTransform, without removing 
previous
objects.  I guess the PAT is just gathering a new Geode every time.

If you only need a single line it's better to just create a single Geode and 
modify the
coordinates on its Geometry/VertexArray.

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to