Hi Robert,
I tried the sprite solution but I'm experiencing a problem I don't understand.
Basically the first point I add is not automatically shown. Adding a second 
point makes both points/sprites to be visible.

Here is the code:


Code:

ControlPoints::ControlPoints()
{
   osg::StateSet* stateSet = getOrCreateStateSet();
   stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
   /// Disable depth test to avoid sort problems and Lighting
   stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);

   /// Setup the point sprites
   osg::PointSprite *sprite = new osg::PointSprite();
   stateSet->setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON);
   /// Give some size to the points to be able to see the sprite
   osg::Point *point = new osg::Point();
   point->setSize(40.0f);
   stateSet->setAttribute(point);

   geometry = new osg::Geometry;
   addDrawable(geometry);
   osg::Vec4Array* colors = new osg::Vec4Array;
   colors->push_back(osg::Vec4(1, 0, 0, 1));
   geometry->setColorArray(colors);
   geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
   geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, 
0));
   geometry->setVertexArray(new osg::Vec3Array);
}

void ControlPoints::add(const osg::Vec3& iPoint)
{   
   osg::DrawArrays* primitiveSet = 
static_cast<osg::DrawArrays*>(geometry->getPrimitiveSet(0));
   primitiveSet->setCount(primitiveSet->getCount() + 1);
   osg::Vec3Array* vertices = 
static_cast<osg::Vec3Array*>(geometry->getVertexArray());
   vertices->push_back(iPoint);
   //geometry->setVertexArray(vertices);
   geometry->dirtyDisplayList();
   geometry->dirtyBound();
}




Every time I pick with left mouse the add method is called. But the first time 
the point is not shown. Any idea?

Cheers,
Gianni[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=61944#61944





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

Reply via email to