Hi!

I'm trying to add a "dashed line" between two points (for now, they're
hardcoded. They exist in the point cloud that is already in the scene).

With this code I expected two blue points of size 10 in the same place of
those in the point cloud and a dashed line between them, yet nothing is
shown.

Do you know what the problem may be?

Here's the last piece of code I tried:

osg::ref_ptr<osg::Vec3Array> dash_points = new osg::Vec3Array;

osg::ref_ptr<osg::Vec4Array> dash_color = new osg::Vec4Array;

osg::ref_ptr<osg::Geometry> dash_geometry( new osg::Geometry);

dash_color->push_back(osg::Vec4f(0.0,0.0,1.0,1.0));

const osg::Vec3f P1(525501.015,4668653.861,457.197);

const osg::Vec3f P2(525510.287,4668630.738,457.034);

dash_points->push_back(P1);

dash_points->push_back(P2);

qDebug() << "DASH";

qDebug() << "\tP1:" << P1[0] << P1[1] << P1[2];

qDebug() << "\tDASH_POINTS[0]:" << (*dash_points)[0][0] <<
(*dash_points)[0][1] << (*dash_points)[0][2];

qDebug() << "\tP2:" << P2[0] << P2[1] << P2[2];

qDebug() << "\tDASH_POINTS[1]:" << (*dash_points)[1][0] <<
(*dash_points)[1][1] << (*dash_points)[1][2];

dash_geometry->setVertexArray(dash_points.get());

dash_geometry->setColorBinding(osg::Geometry::BIND_OVERALL);

// The 1,0xf0f0 parameters were taken from one of the examples...

osg::ref_ptr<osg::LineStipple> linestipple( new osg::LineStipple(1,0xf0f0) );

dash_geometry->getOrCreateStateSet()->setAttributeAndModes(linestipple.get(),
osg::StateAttribute::OVERRIDE );

dash_geometry->addPrimitiveSet( new
osg::DrawArrays(GL_LINES,0,dash_points->size()) );

dash_geometry->getOrCreateStateSet()->setAttributeAndModes( new
osg::Point(10.0f) );

dash_geometry->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0,
dash_points->size()));

dash_geometry->setColorArray(dash_color.get());

shape->addDrawable( dash_geometry );

shape->addDrawable(text);


Thanks and best regards!

PS: I can show a "complete" line between the points. I thought that the
code would be similar, just adding the LineStipple part.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to