Dear All,
I noticed that when one tries to pick an object from scene there is a critera
for that,I directly started the example from osgPicking example shown at the
officail Osg site.The code which generates the grids in scene are as follow,
problem with this is that PickHandler doesn't detect each line as individual
entity.
I can understand the behaviour of having all the vertices and lines stuffed
under the DrawImplementation to increase the performance and PickHandler not
detecting them, But If you create each line as individual osg::Geometry then
PickHandler must detect them which will result in obvious performance penalty.
I tried both osgUtil::LineSegmentIntersector and
view->computeIntersections(x,y,intersections) functions if any of them
intersects with scene objects, but none of them worked.
osg::Geode* CreateGrid(osg::Group* gr, int x, int y, int step){ osg::Geode*
gode = new osg::Geode();
for (int j=1; j<2000; j++){ osg::Geometry* linesGeom = new osg::Geometry();
osg::Vec3Array* vertices = new osg::Vec3Array(100 ); for (int i=0;i<50 ;i++
) { (*vertices)[2*i].set(-100, step+i*10, 40);
(*vertices)[2*i+1].set(100, step+i*10, 40); };
linesGeom->setVertexArray(vertices); // set the colors as before, plus
using the above osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
linesGeom->setColorArray(colors);
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// set the normal in the same way color. osg::Vec3Array* normals = new
osg::Vec3Array; normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
linesGeom->setNormalArray(normals);
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
linesGeom->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::LINES,0,100));
gode->addDrawable(linesGeom);} return gode;}
Regards,
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org