Ok, now I've modified PolytopeIntersector to take a CalculationMode ( BOUNDING_SPHERE, VERTICES, PRIMITIVES) as a parameter. The vertices mode checks to see if any of the vertices are within the polytope. But even this isn't an accurate solution because what if you dragged a box to intersect just an edge of a polygon or completely in the interior of a polygon, then a vertex isn't necessarily in the polytope.
So I think the only accurate solution is to use a Primitives based calculation mode... On 11/17/06, c sklu <[EMAIL PROTECTED]> wrote:
Hi Robert, It was a bit difficult to explain and I was hoping the pictures would help. Basically, the yellow rectangles in the pictures show the region where a pick would return positive. So if you imagine that you click and drag a box on screen such that any portion of that box is within the yellow rectangle, a hit is returned. In looking at the code for Plane::intersect() and the logic for Polytope::contains() (although I can't follow it completely), I think it make sense to me now. Refer again to attached rudimentary pic. If the red box represents the desired box-selection, then obviously for planes A and B, the object is completely on the positive side of the plane. But for planes C and D you can see that a part of the object is on the positive side. I'm not really sure how Polytope::contains() handles this. But I think it is necessary to traverse all vertices if the initial bounding sphere calculation passes and see if any of them are completely contained in the polytope. I hope that makes sense. Chris On 11/17/06, c sklu <[EMAIL PROTECTED]> wrote: > Think I answered my own question, in Plane::intersect(vector<Vec3>&), > it just uses the bounding sphere. So I need to change the > PolytopeIntersector to traverse all of the points individually. Maybe > this could be made as a parameter? > > On 11/17/06, c sklu <[EMAIL PROTECTED]> wrote: > > Hi Robert, > > > > Box-selection seems to be working roughly, but I am getting the > > following behaviour. When doing the box select, the > > PolytopeIntersector is returning hits for an object in what seems to > > be a screen-aligned box around the object. I've attached two > > screenshots which will hopefully make it clearer. > > > > In box-horz.jpg, because the general orientation of the strip is > > horizontal, the screen-aligned box fits the object closely. The yellow > > rectangle indicates the region where PolytopeIntersector returns hits. > > > > In box-angle.jpg, you see the screen-aligned box doesn't fit the > > object very well. Again, the yellow rectangle represents the region > > where hits are returned... > > > > I've looked through the code and I don't understand how this can be. > > Ultimately it boils down to the call: Polytope::contains( const > > std::vector<Vec3> & ) which then recurses down to each of the planes > > and sees which side the vertices are on (I imagine). Any ideas on how > > this can happen? > > > > Cheers, > > Chris > > > > > > On 11/14/06, Robert Osfield <[EMAIL PROTECTED]> wrote: > > > Hi Chris, > > > > > > On 11/14/06, c sklu <[EMAIL PROTECTED]> wrote: > > > > Thanks for the reply, that's what I thought and I got things to work. > > > > My problem was however that I wasn't passing the root of the > > > > scenegraph to the IntersectVisitor. I was kind of wondering about this > > > > because in the PickVisitor, the viewport, projection, and model > > > > matrices are passed into the constructor. So I assume the new > > > > IntersectionVisitor is getting the initial transformations from the > > > > CameraNode which is usually at the root of the scenegraph. Is this > > > > correct? > > > > > > > > > > Yes the osgkeyboardmouse example uses the topmost CameraNode to set up the > > > IntersectionVisitor with the appropriate viewport, projection and view > > > matrices, then clones the source > > > PolytopeIntersection/LineSegmentIntersector and during the > > > cloning process the intersector is transformed into the new coordinate frame > > > defined by the current viewport/project and view matrices. > > > > > > The cloning action happens any time a new CameraNode or Transform node is > > > encountered. Its really an implementation detail that end users needn't > > > worry about. If you want to implement your own Intersector then you'll need > > > to implement the clone method and therefore know about the transformation > > > step. The exisitng Intersector implementation should provide a guide for > > > the later. > > > > > > Robert. > > > > > > _______________________________________________ > > > osg-users mailing list > > > [email protected] > > > http://openscenegraph.net/mailman/listinfo/osg-users > > > http://www.openscenegraph.org/ > > > > > > > > > > > > >
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
