Changed the ordering of the picking intersections.

This commit is contained in:
Robert Osfield
2003-04-18 21:44:48 +00:00
parent 1cf0be9963
commit b6ee5445b7
2 changed files with 18 additions and 4 deletions

View File

@@ -20,6 +20,7 @@
#include <osg/OccluderNode>
#include <osg/Geometry>
#include <osg/ShapeDrawable>
class OccluderEventHandler : public osgGA::GUIEventHandler
@@ -43,7 +44,6 @@ class OccluderEventHandler : public osgGA::GUIEventHandler
osgProducer::Viewer* _viewer;
osg::ref_ptr<osg::Group> _rootnode;
osg::ref_ptr<osg::Group> _occluders;
osg::ref_ptr<osg::ConvexPlanarOccluder> _convexPlanarOccluder;
};
@@ -110,6 +110,16 @@ void OccluderEventHandler::addPoint(const osg::Vec3& pos)
osg::ConvexPlanarPolygon& occluder = _convexPlanarOccluder->getOccluder();
occluder.add(pos);
//
// osg::BoundingSphere bs = rootNode()->getBound();
//
// osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(pos,bs.radius()*0.001f));
// osg::Geode* geode = new osg::Geode;
// geode->addDrawable(sd);
//
// rootNode()->addChild(geode);
//
}

View File

@@ -38,6 +38,10 @@ public:
// the ray transformed by Projection
_lineSegment = new osg::LineSegment;
_lineSegment->set(nr,fr); // make a line segment
std::cout<<"near "<<nr<<std::endl;
std::cout<<"far "<<fr<<std::endl;
addLineSegment(_lineSegment.get());
scene->accept(*this);
@@ -65,7 +69,7 @@ public:
// Assumes that the Projection is an absolute projection
osg::Matrix mt;
mt.invert(pr.getMatrix());
osg::Vec3 npt=osg::Vec3(xp,yp,1.0f) * mt, farpt=osg::Vec3(xp,yp,-1.0f) * mt;
osg::Vec3 npt=osg::Vec3(xp,yp,-1.0f) * mt, farpt=osg::Vec3(xp,yp,1.0f) * mt;
// traversing the nodes children, using the projection direction
for (unsigned int i=0; i<pr.getNumChildren(); i++)
@@ -102,8 +106,8 @@ public:
// x,y are values returned by
osg::Matrix inverseMVPW;
inverseMVPW.invert(projm);
osg::Vec3 near_point = osg::Vec3(x,y,1.0f)*inverseMVPW;
osg::Vec3 far_point = osg::Vec3(x,y,-1.0f)*inverseMVPW;
osg::Vec3 near_point = osg::Vec3(x,y,-1.0f)*inverseMVPW;
osg::Vec3 far_point = osg::Vec3(x,y,1.0f)*inverseMVPW;
setxy(x,y);
getHits(node,near_point,far_point);
return _PIVsegHitList;