Re: [osg-users] Picking Problem PolytopeIntersector
Hello Martin, I have a model with lots of points and I want to find the front/first point under the mouse click (quickly) Options are a polytrope intersector with a small box (2x2 5x5 pixels). What if I used a few line lineintersectors spaced a pixel apart, would that be faster? LineSegmentIntersector will not find points (at all). Even for 3D geometry, I wouldn't suggest using multiple LineSegmentIntersections because then you might miss objects (between the lines) - you're subject to sampling issues. PolytopeIntersector will not order results in closest-first fashion, but for points, you can do that yourself. Just order by the distance between the camera's eye point and the given point. This is possible for points but not for general geometry, for example imagine a bowl containing fruit, and picking from above: || || polytope \ | / | \/ bowl with fruit \_oOOo_/ The polytope above will pick both the fruit and the bowl, but which one is closest? The bowl is closest for part of the polytope, but the fruit are closest for another part. Since points are zero-dimensional you can order them by distance without ambiguity. Also is there a way to use the colour under the mouse cursor to quickly check if there is a point (by comparing to background) before doing the intersector? You could do that yourself by doing a readPixel in the mouse x,y point that was clicked. But it might be slow because it will flush the graphics fifo, and in general it won't work because the background might not be the clear color (if you have a skydome/skybox, or an environment in your scene). But if you want to try it, the way I'd do this is to delay the actual picking for one frame. Have your event handler add a camera post-draw callback that does an osg::Image::readPixels for the current camera and checks for those x,y. If there's an object there, it can then do the actual intersection test or whatever you want. The camera post-draw callback then removes itself (so it isn't used for all frames, just the frames where a pick was attempted - the osgViewer::ScreenCaptureHandler does this so that it takes a screenshot only once). Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hi, I second Paul on that. Generally speaking, you need some kind of tolerance (or margin) when picking for best user experience. Users dont want to spend time trying to pick an object. And that's exactly what polytope is about. But if you only have large objects (pixel size) in your application, well, line intersector may be just fine. Raphael On Fri, Apr 24, 2009 at 8:04 PM, Jean-Sébastien Guay < jean-sebastien.g...@cm-labs.com> wrote: > Hi Paul, > > When you do a mouse pick, you generally are trying to pick an object that >> falls into a small screen-space box around the cursor. In a perspective >> view, the box has smaller world-space extents at the near plane, and >> larger >> world-space extents at the far plane. In essence, it looks like a view >> frustum. PolytopeIntersector is the only intersector that accurately >> represents this pick volume. >> > > Yes, but this is only a problem if the user clicks on the pixels at the > edge of the object (or the limit case, if the object occupies only one pixel > on screen). The chances that the user will click just at the edge of the > object and the ray will miss are really small. Generally the object is big > enough on screen (even if the object occupies 5x5 pixels I'd be surprised to > see a user click on the edge, most of the time they'll click in the middle). > > Every developer is free to make the choices they want. I consider this case > much too infrequent, and it has not been a problem for us. I have not had > one user tell me "hey, I should have selected the object then but I didn't". > > J-S > -- > __ > Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com > http://www.cm-labs.com/ >http://whitestar02.webhop.org/ > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
I have a model with lots of points and I want to find the front/first point under the mouse click (quickly) Options are a polytrope intersector with a small box (2x2 5x5 pixels). What if I used a few line lineintersectors spaced a pixel apart, would that be faster? Also is there a way to use the colour under the mouse cursor to quickly check if there is a point (by comparing to background) before doing the intersector? Martin (Slightly nervous about pouring fuel on this discussion.) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=11024#11024 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hi Paul, When you do a mouse pick, you generally are trying to pick an object that falls into a small screen-space box around the cursor. In a perspective view, the box has smaller world-space extents at the near plane, and larger world-space extents at the far plane. In essence, it looks like a view frustum. PolytopeIntersector is the only intersector that accurately represents this pick volume. Yes, but this is only a problem if the user clicks on the pixels at the edge of the object (or the limit case, if the object occupies only one pixel on screen). The chances that the user will click just at the edge of the object and the ray will miss are really small. Generally the object is big enough on screen (even if the object occupies 5x5 pixels I'd be surprised to see a user click on the edge, most of the time they'll click in the middle). Every developer is free to make the choices they want. I consider this case much too infrequent, and it has not been a problem for us. I have not had one user tell me "hey, I should have selected the object then but I didn't". J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Glad to elaborate. (However, I fear I'm about to earn the nickname of "that raving lunatic who insists on using polytopes for picking"... :-) When you do a mouse pick, you generally are trying to pick an object that falls into a small screen-space box around the cursor. In a perspective view, the box has smaller world-space extents at the near plane, and larger world-space extents at the far plane. In essence, it looks like a view frustum. PolytopeIntersector is the only intersector that accurately represents this pick volume. A line segment is less accurate because it does a poor job of representing that view volume. And in fact, the line segment becomes less and less accurate when you try to pick objects that are farther and farther away from the viewer. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Jason Daly Sent: Thursday, April 23, 2009 5:30 PM To: OpenSceneGraph Users Subject: Re: [osg-users] Picking Problem PolytopeIntersector Paul Martz wrote: > You _can_ use a line segment for mouse click picking, but in a > perspective view, polytope is really better suited for this task. > Also, polytope will pick point and line primitives, while line segment > intersection will miss them. > Unless you're dealing with points/lines, I'm failing to see why a polytope is "really better suited for this task." I also fail to see why accuracy would be a problem when using line segments (unless you're trying to pick something one or two pixels wide, which doesn't happen often in my experience). Can you elaborate a bit (or point me at something that explains it)? --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hello now ive implemented my own Pick Handler and it runs perfect with the LineSegmentIntersector thanks a lot !! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10812#10812 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Paul Martz wrote: You _can_ use a line segment for mouse click picking, but in a perspective view, polytope is really better suited for this task. Also, polytope will pick point and line primitives, while line segment intersection will miss them. Unless you're dealing with points/lines, I'm failing to see why a polytope is "really better suited for this task." I also fail to see why accuracy would be a problem when using line segments (unless you're trying to pick something one or two pixels wide, which doesn't happen often in my experience). Can you elaborate a bit (or point me at something that explains it)? --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hi Paul, Hi J-S -- You can dismiss tradition in this area, but I prefer to learn lessons instead. I was just joking :-) I've used GL_SELECTION too in the past, it was a good tool, but there are better ways now. Generally speaking, polytope is what you want. It generally runs faster than a cull traversal, so performance is rarely an issue. Most users can tolerate a small delay anyway, but are very unforgiving of accuracy issues when it comes to picking. Try using the polytope intersector with a polytope more than a few pixels wide (say 100x100 pixels, encompassing a large model with tens of thousands of polygons), and you'll see that it causes a severe frame drop. When all I want is to select the model, I don't need to know that the polytope encompassed all the model's polygons, so this part of PolytopeIntersector is useless and takes time for nothing. If the object occupies more than a few pixels, a line segment will pass through it without problems, and will only return a few intersections (for a manifold object) so it will work great. Of course, if you want a box intersection you don't have a choice. Polytope gives you more accuracy at greater distances, and also intersects with point and line primitives. If you choose to use line segment intersections for picking, don't come crying to me when you encounter inherent accuracy issues. :-) I have used it extensively, without any problems. Of course, again, if you want to pick points and lines, you can't, period. But for the rest, line segment is faster and is generally good enough. The bottom line is that the developer must know their app's requirements and must know how line segment and polytope intersection work, then make an appropriate choice. I totally agree. And hey, if you want a single code path for picking everything and doing both box and click selection, then sure, polytope is your man (err, class). But we have multiple paths for both cases, and it works great. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hi J-S -- You can dismiss tradition in this area, but I prefer to learn lessons instead. Generally speaking, polytope is what you want. It generally runs faster than a cull traversal, so performance is rarely an issue. Most users can tolerate a small delay anyway, but are very unforgiving of accuracy issues when it comes to picking. Polytope gives you more accuracy at greater distances, and also intersects with point and line primitives. If you choose to use line segment intersections for picking, don't come crying to me when you encounter inherent accuracy issues. :-) The bottom line is that the developer must know their app's requirements and must know how line segment and polytope intersection work, then make an appropriate choice. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hi Jean-Sébastien, Jean-Sébastien Guay schrieb: Hello Matthias, [...] Another difference, the line segment intersector orders objects by their distance (closest intersection first), but the polytope intersector doesn't (it would be pretty hard to implement even an approximation, and even that would be slow - the polytope intersector is slow enough as it is). I'd like to correct you on that one. Let me quote PolytopeIntesector: /** set the plane used to sort the intersections. * The intersections are sorted by the distance of the * localIntersectionPoint and the reference plane. * The default for the reference plane is the * last plane of the polytope. */ inline void setReferencePlane(const osg::Plane& plane) {...} We use this for point and line picking and only have to check the first (few) intersections. So you see, the two types of intersectors lend themselves naturally to different applications. Hope this helps, J-S Regards Peter -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Paul Martz wrote: If you want to pick an object by a single click, you can use a line segment. If you want to pick by drawing a box, you can use a polytope. Err, that wasn't Paul, that was me... You _can_ use a line segment for mouse click picking, but in a perspective view, polytope is really better suited for this task. Also, polytope will pick point and line primitives, while line segment intersection will miss them. But PolytopeIntersection is really slow, and does not allow (easily) getting the first intersection. If all you want to do is select the object under the cursor, LineSegment is more than enough and is really fast with the kdtree support. Polytope intersection has traditionally been used for mouse click picking. See gluPickMatrix in the GLU library, dating back over 15 years. It is useful for OpenGL 1.x/2.x GL_SELECTION render mode. Dinosaur! :-) J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
> If you want to pick an object by a single click, you can use a line segment. > If you want to pick by drawing a box, you can use a polytope. You _can_ use a line segment for mouse click picking, but in a perspective view, polytope is really better suited for this task. Also, polytope will pick point and line primitives, while line segment intersection will miss them. Polytope intersection has traditionally been used for mouse click picking. See gluPickMatrix in the GLU library, dating back over 15 years. It is useful for OpenGL 1.x/2.x GL_SELECTION render mode. It restricts the perspective projection matrix to a small box around the mouse click, producing a narrow view frustum. The net result is essentially a polytope intersection. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hello Matthias, In the context of intersection, the different intersectors are just used for different tasks. If you want to pick an object by a single click, you can use a line segment. If you want to pick by drawing a box, you can use a polytope. If you want to pick something that has an area / volume, you can use a line segment. But if you want to pick points, you'll get a hard time getting a line segment from the mouse coordinates to intersect a point, so you'd use a polytope (perhaps one that represents a 2x2 or 4x4 pixel box around the clicked point, extruded from near to far plane). Another difference, the line segment intersector orders objects by their distance (closest intersection first), but the polytope intersector doesn't (it would be pretty hard to implement even an approximation, and even that would be slow - the polytope intersector is slow enough as it is). So you see, the two types of intersectors lend themselves naturally to different applications. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
On Wed, Apr 22, 2009 at 5:22 PM, Matthias Asselborn wrote: > what is the difference between Polytope Intersector and Linesegment > Intersector ? The clue to the difference is the name PolytopeIntersector uses a Polytope do the intersection tests, while a LineSegmentIntersector uses a LineSegmenet. A Polytope is convex hull built from a list of planes (that represent half spaces). A LineSegment is simple two vertices that define the line segment. I would encourage you to search the web for more indepth discussion of what a Polytope is and what it's used for. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
what is the difference between Polytope Intersector and Linesegment Intersector ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10665#10665 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
oh what a great idee! ive checked that no... i can't reproduce my problems ... in osgkeyboardmouse example i will change my code! and i will notice you! thanks -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10664#10664 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Hi Matthias, Matthias Asselborn schrieb: Yes it is. First my SceneGraph has a a root ( osg::Group ). The Root contains few transform nodes under one transform nodes is one node, a model added by a loader. now i want to click on a object on the screen. and i want to get a pointer of this object by picking! the example in the book is done with the PolytopeIntersector but it doesnt work accurately i get a node when i clicked on a empty place in the scene or i clicked on another node and i get a other node from the picker. Can you reproduce your problems with the osgkeyboardmouse example? It switches to use the PolytopeIntersector when you press 'p' once (actually it toggles). If you use a OSG loader you can pass your filename as first parameter to the executable. I have not read the quick start guide but I have some general remarks: - you can adjust the accuracy of the Polytope-Picking by the size of the polytope which is usually incorporated in the constructor arguments of PolytopeIntersector (see osgkeyboardmouse) - the PolytopeIntersector returns *all* intersections it encounters, and if you call getFirstIntersection() you will only get one. This may account for your getting the "wrong" node. ive tested the LineIntersector in OSG examples it works great but i get only points on the screen no nodes... Regards, Peter Hrenka -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking Problem PolytopeIntersector
Yes it is. First my SceneGraph has a a root ( osg::Group ). The Root contains few transform nodes under one transform nodes is one node, a model added by a loader. now i want to click on a object on the screen. and i want to get a pointer of this object by picking! the example in the book is done with the PolytopeIntersector but it doesnt work accurately i get a node when i clicked on a empty place in the scene or i clicked on another node and i get a other node from the picker. ive tested the LineIntersector in OSG examples it works great but i get only points on the screen no nodes... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10648#10648 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org