Re: [osg-users] PolytopeIntersector returns no hits when zoomed in (3.6.5)
To answer my own question. The approach that worked was to just remove the "zNear" plane from the Polytope. It is the last plane. Seems like an unnecessary hack. PolytopeIntersector* picker = new PolytopeIntersector ( osgUtil::Intersector::PROJECTION, nx1, ny1, nx2, ny2 ); auto planeList = picker->getPolytope().getPlaneList(); planeList.pop_back(); picker->getPolytope().set ( planeList ); On Friday, May 1, 2020 at 12:06:26 PM UTC-7, AndrewC wrote: > > Hi, > I am using the PolytopeIntersector to select objects in a "selection box" > Works as expected in most cases. > However when I am "zoomed in" (perspective view) fairly tightly ( the eye > point is inside the bounding box of the geometry), the PolytopeIntersector > returns "no hits" on the geometry. > > I am at my wits end on this one after walking through the OSG code, it > seems to be deciding the geometry is not inside the planes of the Polytope. > > > Andrew > > > > -- You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/fac96b1d-6d15-436a-9cd7-e9c3472022fb%40googlegroups.com. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] PolytopeIntersector returns no hits when zoomed in (3.6.5)
Hi, I am using the PolytopeIntersector to select objects in a "selection box" Works as expected in most cases. However when I am "zoomed in" (perspective view) fairly tightly ( the eye point is inside the bounding box of the geometry), the PolytopeIntersector returns "no hits" on the geometry. I am at my wits end on this one after walking through the OSG code, it seems to be deciding the geometry is not inside the planes of the Polytope. Andrew -- You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/f78291b2-4eff-4db8-b123-d5309a33e2ba%40googlegroups.com. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] PolytopeIntersector::Intersection::primitiveIndex
Hi, I am looking for some clarification of the primitiveIndex value of polytope intersection. I have added a very simple scene file containing 3 planar faces of a cube with 6 triangles in a primitive set. I have been testing the polytope intersector with osgkeyboardmouse using the following command Code: 'osgkeyboardmouse --kdtree box_partial_work_1set.osgt' Running this command and hitting the 'p' key and then selecting the 2 triangles making up the red face I get the following output. Code: osgkeyboardmouse --kdtree box_partial_work_1set.osgt Building KdTrees ViewerBase::configureAffinity() numProcessors=4 databasePagers = 1 _forceVertexArrayObject = 0 _forceVertexBufferObject = 0 Using PolytopeIntersector PoltyopeIntersector traversal took 0.104ms Picked 10 2.44399 1.97205 Distance to ref. plane 4.928, max. dist 5.0417, primitive index 4, numIntersectionPoints 2 Hits Geometry nodePath size 3 parent Group PoltyopeIntersector traversal took 0.034ms Picked 10 7.93759 7.66585 Distance to ref. plane 4.13599, max. dist 4.24392, primitive index 5, numIntersectionPoints 2 Hits Geometry nodePath size 4 parent Scribe why are primitive indexes 4 and 5? Shouldn't they be 0 and 1 because those triangles are listed first in the scene file? If I do the same procedure and leave off '--kdtree' I am getting indexes of 1 and 2. Thank you! Cheers, tom[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70992#70992 Attachments: http://forum.openscenegraph.org//files/box_partial_work_1setosgt_251.zip ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector with AutoTransform
Thanks for the answer. How could I solve this? 2016-12-04 12:47 GMT+00:00 Robert Osfield : > Hi Bruno, > > The complication with AutoTransform is the it computes it's values > only in the CullVisitor so you'll inherit what ever the last frame > used for it's settings. This should work OK most of the time. If you > have multiple views on the scene this will mean that there are > multiple stats but only the last one will be left in place for the > next frame. > > Robert. > > > > On 3 December 2016 at 17:55, Bruno Oliveira > wrote: > > Hello, > > > > in my scene graph I'm using an AutoTransform to add a circle with > Radius=10, > > centered on (0,0,0): > > > > float Radius = 10; > > for (int i = 0; i < nPointsInCircle; i++) > > vertArray[i] = Vec3d( radius * sin(...), radius* cos(...), 0.)); > > > > then I add this to a Drawable + Geode, and add that Geode to an > > AutoTransform: > > > > auto* autoTransform = new osg::AutoTransform; > > autoTransform->addChild(circleGeode); > > autoTransform->setAutoScaleToScreen(true); > > autoTransform->setPosition(100, 100, 0); > > > > This results in a circle located in (100, 100, 0), with radius 10, > scaling > > automatically to screen. VISUALLY this is what I want. > > Now when I use a PolytopeIntersector on this node, it returns > intersection > > coordinates of the circle , in the Circle's geometry frame, centered in > > (0,0,0) with radius 10. This means that, if I hover my mouse over the > > Circle, which is located in world coordinates in (100, 100, 0), the > > PolytopeIntersector returns coordinates centered in (0,0,0) with maximum > > radius 10. > > > > > > How can I obtain true world coordinates with Autotransforms? > > > > ___ > > 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 > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector with AutoTransform
Hi Bruno, The complication with AutoTransform is the it computes it's values only in the CullVisitor so you'll inherit what ever the last frame used for it's settings. This should work OK most of the time. If you have multiple views on the scene this will mean that there are multiple stats but only the last one will be left in place for the next frame. Robert. On 3 December 2016 at 17:55, Bruno Oliveira wrote: > Hello, > > in my scene graph I'm using an AutoTransform to add a circle with Radius=10, > centered on (0,0,0): > > float Radius = 10; > for (int i = 0; i < nPointsInCircle; i++) > vertArray[i] = Vec3d( radius * sin(...), radius* cos(...), 0.)); > > then I add this to a Drawable + Geode, and add that Geode to an > AutoTransform: > > auto* autoTransform = new osg::AutoTransform; > autoTransform->addChild(circleGeode); > autoTransform->setAutoScaleToScreen(true); > autoTransform->setPosition(100, 100, 0); > > This results in a circle located in (100, 100, 0), with radius 10, scaling > automatically to screen. VISUALLY this is what I want. > Now when I use a PolytopeIntersector on this node, it returns intersection > coordinates of the circle , in the Circle's geometry frame, centered in > (0,0,0) with radius 10. This means that, if I hover my mouse over the > Circle, which is located in world coordinates in (100, 100, 0), the > PolytopeIntersector returns coordinates centered in (0,0,0) with maximum > radius 10. > > > How can I obtain true world coordinates with Autotransforms? > > ___ > 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
[osg-users] PolytopeIntersector with AutoTransform
Hello, in my scene graph I'm using an AutoTransform to add a circle with Radius=10, centered on (0,0,0): float Radius = 10; for (int i = 0; i < nPointsInCircle; i++) vertArray[i] = Vec3d( radius * sin(...), radius* cos(...), 0.)); then I add this to a Drawable + Geode, and add that Geode to an AutoTransform: auto* autoTransform = new osg::AutoTransform; autoTransform->addChild(circleGeode); autoTransform->setAutoScaleToScreen(true); autoTransform->setPosition(100, 100, 0); This results in a circle located in (100, 100, 0), with radius 10, scaling automatically to screen. VISUALLY this is what I want. Now when I use a PolytopeIntersector on this node, it returns intersection coordinates of the circle , in the Circle's geometry frame, centered in (0,0,0) with radius 10. This means that, if I hover my mouse over the Circle, which is located in world coordinates in (100, 100, 0), the PolytopeIntersector returns coordinates centered in (0,0,0) with maximum radius 10. How can I obtain true world coordinates with Autotransforms? ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector LIMIT_NEAREST (or LIMIT_ONE) different distances for different groupnodes
Hi robertosfield, Thank you for you reply. This absolutley understandable. Every group can have it's own transformation and so every group has it's own local coordinates. Quite clear. So i guess there is absolutley no way to caluclate distances in Worldcoordinates? I admit, I don't understand much about how the IntersectionVisitor works and I still searching for the right lines in the osgUtil Project. I've just written simpel boolean collision code before. PS: Would you mind to remove my email address from the qoute? : D I actually like that to be private. : ) Cheers, NoxxKn -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=67326#67326 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector LIMIT_NEAREST (or LIMIT_ONE) different distances for different groupnodes
Hi David, Way too much detail in a difficult form to follow when skimming over things to spot what might going amiss. The best I can suggest right now is think about the coordinate frame that the distance and coordinate values are being reported in. If you have transforms in your scene graph then the coordinates generated on one subgraph can be different to another subgraph as each subgraph now has it's own coordinate frame. This means the same point in world coordinates can have different local coordinates. Robert. On 1 June 2016 at 15:07, David Knipp wrote: > Hi, > > I'm very sorry that i have to create a new post. I'm currently facing a > problem i can't solve on my own. > > Im working on a single Model which has a lot of group nodes and geometry > nodes. This model is categorized in a few "main" groups. > > In the beginning i worked only with one of this main groups at once. > > The application does view this group and handle pickings on them. Everything > worked nice and cleanly. After i was mixing some of the groups the results of > the picker got strange. > > Groups got different distances and also the differences change if i just > change the angle i'm looking at the model. (orbit manipulator! I don't change > the distance!) > > The strange behavior is that i start picking nodes that where BEHIND of the > nodes i wanted to pick (in viewer). > > I'm working with a picker like so: > > int x = GET_X_LPARAM(lParam); // windows mouse pos > int y = GET_Y_LPARAM(lParam); // windows mouse pos > > float _x = static_cast(x); > float _y = static_cast(y); > > _x = 2.f * (_x - 0.f) / (window_width - 0.f) - 1.f; > _y = -(2.f * (_y - 0.f) / (window_height - 0.f) - 1.f); > > double w = 0.005, h = 0.005; > osgUtil::PolytopeIntersector * picker = new > osgUtil::PolytopeIntersector(osgUtil::Intersector::CoordinateFrame::PROJECTION, > _x - w, _y - h, _x + w, _y + h); > > picker->setIntersectionLimit(osgUtil::Intersector::LIMIT_NEAREST); > picker>setPrecisionHint(osgUtil::Intersector::PrecisionHint::USE_DOUBLE_CALCULATIONS); > picker->setDimensionMask(osgUtil::PolytopeIntersector::AllDims); > > osgUtil::IntersectionVisitor iv(picker); > iv.setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN); > > viewer->getCamera()->accept(iv); > > if (picker->containsIntersections()) { >const osg::NodePath& nodePath = >picker->getFirstIntersection().nodePath; >unsigned int idx = nodePath.size(); >while (idx--) { > // bla bla specifc > } > } > > What i mean is described in Attachments. > > First Image "pick-error.png": > > Red: Calculated nearer (but are in viewer BEHIND!) > Green: Calculated further away (Actually the node i wanted to pick) > > Second Image "pick-error2.png": > > I just change the angle of the orbit viewer for about 30 degrees and don't > change the distance to object. The Distances just explode to much higher > values. (Note the Model should only be about "2.f" heigh!) > > I guess the second image error was allways present, but i didn't realised it, > because the picker worked allways right. > > Another side node, the model seems to doesn't stand in the right position. It > should be in 0 0 0 but is located anywhere like 1 -11 -180 or something like > that. Which is very strange but never made a problem. > For loading i do: > > // ... osg::MatrixTransform mt > const double angle = osg::DegreesToRadians(90.); > const osg::Vec3d axis(1, 0, 0); > mt->setMatrix(osg::Matrix::rotate(angle, axis)); > mt->addChild(model); > root->addChild(mt); > .. > > I can't upload the model because it's not for public use. > > I hope the informations are enough that some kind person can give me a hint. > > I worked to all coordinate frames. Only Projection seemd to work for me. > Never found the right matrices to make View or Model working. Precision Hint > can be float which has the same errors. Intersection Limit can be "NO_LIMIT" > and wouldn't change a thing. > > A LineSegmentIntersector never found a result. > > Cheers, > NoxxKn > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=67319#67319 > > > > > Attachments: > http://forum.openscenegraph.org//files/pick_error2_941.png > http://forum.openscenegraph.org//files/pick_error_165.png > > > ___ > 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
[osg-users] PolytopeIntersector LIMIT_NEAREST (or LIMIT_ONE) different distances for different groupnodes
Hi, I'm very sorry that i have to create a new post. I'm currently facing a problem i can't solve on my own. Im working on a single Model which has a lot of group nodes and geometry nodes. This model is categorized in a few "main" groups. In the beginning i worked only with one of this main groups at once. The application does view this group and handle pickings on them. Everything worked nice and cleanly. After i was mixing some of the groups the results of the picker got strange. Groups got different distances and also the differences change if i just change the angle i'm looking at the model. (orbit manipulator! I don't change the distance!) The strange behavior is that i start picking nodes that where BEHIND of the nodes i wanted to pick (in viewer). I'm working with a picker like so: int x = GET_X_LPARAM(lParam); // windows mouse pos int y = GET_Y_LPARAM(lParam); // windows mouse pos float _x = static_cast(x); float _y = static_cast(y); _x = 2.f * (_x - 0.f) / (window_width - 0.f) - 1.f; _y = -(2.f * (_y - 0.f) / (window_height - 0.f) - 1.f); double w = 0.005, h = 0.005; osgUtil::PolytopeIntersector * picker = new osgUtil::PolytopeIntersector(osgUtil::Intersector::CoordinateFrame::PROJECTION, _x - w, _y - h, _x + w, _y + h); picker->setIntersectionLimit(osgUtil::Intersector::LIMIT_NEAREST); picker>setPrecisionHint(osgUtil::Intersector::PrecisionHint::USE_DOUBLE_CALCULATIONS); picker->setDimensionMask(osgUtil::PolytopeIntersector::AllDims); osgUtil::IntersectionVisitor iv(picker); iv.setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN); viewer->getCamera()->accept(iv); if (picker->containsIntersections()) { const osg::NodePath& nodePath = picker->getFirstIntersection().nodePath; unsigned int idx = nodePath.size(); while (idx--) { // bla bla specifc } } What i mean is described in Attachments. First Image "pick-error.png": Red: Calculated nearer (but are in viewer BEHIND!) Green: Calculated further away (Actually the node i wanted to pick) Second Image "pick-error2.png": I just change the angle of the orbit viewer for about 30 degrees and don't change the distance to object. The Distances just explode to much higher values. (Note the Model should only be about "2.f" heigh!) I guess the second image error was allways present, but i didn't realised it, because the picker worked allways right. Another side node, the model seems to doesn't stand in the right position. It should be in 0 0 0 but is located anywhere like 1 -11 -180 or something like that. Which is very strange but never made a problem. For loading i do: // ... osg::MatrixTransform mt const double angle = osg::DegreesToRadians(90.); const osg::Vec3d axis(1, 0, 0); mt->setMatrix(osg::Matrix::rotate(angle, axis)); mt->addChild(model); root->addChild(mt); .. I can't upload the model because it's not for public use. I hope the informations are enough that some kind person can give me a hint. I worked to all coordinate frames. Only Projection seemd to work for me. Never found the right matrices to make View or Model working. Precision Hint can be float which has the same errors. Intersection Limit can be "NO_LIMIT" and wouldn't change a thing. A LineSegmentIntersector never found a result. Cheers, NoxxKn -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=67319#67319 Attachments: http://forum.openscenegraph.org//files/pick_error2_941.png http://forum.openscenegraph.org//files/pick_error_165.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector and LineSegmentIntersector
Hi Gianni, On 03.11.2014 11:47, Gianni Ambrosio wrote: > Hi Peter, > thank you for the fast reply. > > I need some clarifications about question 1. > In my application I will use the "picked" point to calculate, and then show, > the arclength of a path, i.e. the length of the path from start to the picked > point. So I would not need to show coordinates to the user. So I guess WINDOW > or PROJECTION would be the same for my case. > But I would like to understand why I get different coordinates from > "intersection.localIntersectionPoint" with osgUtil::Intersector::WINDOW wrt > osgUtil::Intersector::PROJECTION > > Here is a code snippet as an example: > > Code: > >osgUtil::PolytopeIntersector* picker; >{ > osg::Viewport* viewport = viewer->getCamera()->getViewport(); > double mx = viewport->x() + (int)((double > )viewport->width()*(ea.getXnormalized()*0.5+0.5)); > double my = viewport->y() + (int)((double > )viewport->height()*(ea.getYnormalized()*0.5+0.5)); > > double w = 5.0f; > double h = 5.0f; > picker = new osgUtil::PolytopeIntersector( > osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h ); > osgUtil::IntersectionVisitor iv(picker); > viewer->getCamera()->accept(iv); > if (picker->containsIntersections()) > { > osgUtil::PolytopeIntersector::Intersection intersection = > picker->getFirstIntersection(); > std::cout << "osgUtil::Intersector::WINDOW " << > intersection.localIntersectionPoint.x() << " " << > intersection.localIntersectionPoint.y() << " " << > intersection.localIntersectionPoint.z() << std::endl; > } >} >{ > double mx = ea.getXnormalized(); > double my = ea.getYnormalized(); > double w = 0.05; > double h = 0.05; > picker = new osgUtil::PolytopeIntersector( > osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h ); > osgUtil::IntersectionVisitor iv(picker); > viewer->getCamera()->accept(iv); > if (picker->containsIntersections()) > { > osgUtil::PolytopeIntersector::Intersection intersection = > picker->getFirstIntersection(); > std::cout << "osgUtil::Intersector::PROJECTION " << > intersection.localIntersectionPoint.x() << " " << > intersection.localIntersectionPoint.y() << " " << > intersection.localIntersectionPoint.z() << std::endl; > } >} > > > > And I get an output like this: > > osgUtil::Intersector::WINDOW 18.8821 0.0163024 0 > osgUtil::Intersector::PROJECTION 31.7343 0.0274029 0 > osgUtil::Intersector::WINDOW 18.8821 0.0163024 0 > osgUtil::Intersector::PROJECTION 31.7343 0.0274029 0 > osgUtil::Intersector::WINDOW 22.529 0.019452 0 > osgUtil::Intersector::PROJECTION 34.8797 0.0301198 0 > > The WINDOW case shows different coordinates (look at X coordinate please) wrt > PROJECTION case, but they does not seem to be one in pixel and the other > normalized. Am I missing something? The PROJECTION/WINDOW parameter specifies the coordinate system of the polytope you are using. The intersections points you are printing are in the local coodinate system, i.e. the one where the basic geometry was defined. The PolytopeIntersector has the added quirk that the localIntersectionPoint is actually the geometric center of all intersectionPoints. IntersectionPoints are points where the primitive is intersecting a polytope plane and all primitive vertices completely inside the polytope volume. This could account for different results you are seeing. > Moreover in the WINDOW case I need to be closer to the geomwetry to get a > valid intersection. Can you explain me please why? The WINDOW case uses a 10 by 10 pixel area around the mouse position and the projection case uses 0.1*screenWidth by 0.1*screenHeight which is only the same if you have a screen resolution of 100x100. > Best regards, > Gianni Best regards, Peter ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector and LineSegmentIntersector
Hi Peter, thank you for the fast reply. I need some clarifications about question 1. In my application I will use the "picked" point to calculate, and then show, the arclength of a path, i.e. the length of the path from start to the picked point. So I would not need to show coordinates to the user. So I guess WINDOW or PROJECTION would be the same for my case. But I would like to understand why I get different coordinates from "intersection.localIntersectionPoint" with osgUtil::Intersector::WINDOW wrt osgUtil::Intersector::PROJECTION Here is a code snippet as an example: Code: osgUtil::PolytopeIntersector* picker; { osg::Viewport* viewport = viewer->getCamera()->getViewport(); double mx = viewport->x() + (int)((double )viewport->width()*(ea.getXnormalized()*0.5+0.5)); double my = viewport->y() + (int)((double )viewport->height()*(ea.getYnormalized()*0.5+0.5)); double w = 5.0f; double h = 5.0f; picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h ); osgUtil::IntersectionVisitor iv(picker); viewer->getCamera()->accept(iv); if (picker->containsIntersections()) { osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection(); std::cout << "osgUtil::Intersector::WINDOW " << intersection.localIntersectionPoint.x() << " " << intersection.localIntersectionPoint.y() << " " << intersection.localIntersectionPoint.z() << std::endl; } } { double mx = ea.getXnormalized(); double my = ea.getYnormalized(); double w = 0.05; double h = 0.05; picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h ); osgUtil::IntersectionVisitor iv(picker); viewer->getCamera()->accept(iv); if (picker->containsIntersections()) { osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection(); std::cout << "osgUtil::Intersector::PROJECTION " << intersection.localIntersectionPoint.x() << " " << intersection.localIntersectionPoint.y() << " " << intersection.localIntersectionPoint.z() << std::endl; } } And I get an output like this: osgUtil::Intersector::WINDOW 18.8821 0.0163024 0 osgUtil::Intersector::PROJECTION 31.7343 0.0274029 0 osgUtil::Intersector::WINDOW 18.8821 0.0163024 0 osgUtil::Intersector::PROJECTION 31.7343 0.0274029 0 osgUtil::Intersector::WINDOW 22.529 0.019452 0 osgUtil::Intersector::PROJECTION 34.8797 0.0301198 0 The WINDOW case shows different coordinates (look at X coordinate please) wrt PROJECTION case, but they does not seem to be one in pixel and the other normalized. Am I missing something? Moreover in the WINDOW case I need to be closer to the geomwetry to get a valid intersection. Can you explain me please why? Best regards, Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61495#61495 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector and LineSegmentIntersector
Hello Gianni, 2) line geometry is infinitely thin. To create an exact intersection with another line in floating point precision is like winning the lottery. You will want to use PolytopeIntersector to intersect with non-polygonal geometry instead. 2014-11-03 10:37 GMT+01:00 Gianni Ambrosio : > Hi All, > I'm trying to handle mouse movements to show some informations to the user. > I have basically two questions. > > 1) Lookig at "osgkeyboardmouse.cpp" example found the following code: > > Code: > > if (_useWindowCoordinates) > { > // use window coordinates > // remap the mouse x,y into viewport coordinates. > osg::Viewport* viewport = > viewer->getCamera()->getViewport(); > double mx = viewport->x() + (int)((double > )viewport->width()*(ea.getXnormalized()*0.5+0.5)); > double my = viewport->y() + (int)((double > )viewport->height()*(ea.getYnormalized()*0.5+0.5)); > > // half width, height. > double w = 5.0f; > double h = 5.0f; > picker = new osgUtil::PolytopeIntersector( > osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h ); > } else { > double mx = ea.getXnormalized(); > double my = ea.getYnormalized(); > double w = 0.05; > double h = 0.05; > picker = new osgUtil::PolytopeIntersector( > osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h ); > } > > > > Is there a casa in which osgUtil::Intersector::WINDOW option is preferred > with respect to osgUtil::Intersector::PROJECTION? > > 2) osgUtil::LineSegmentIntersector does not seem to work fine if the > geometry is a line created with: > >osg::Vec3Array* vertices = new osg::Vec3Array; >... >osg::DrawElementsUInt* elements = new > osg::DrawElementsUInt(osg::PrimitiveSet::LINE_STRIP); >geometry->setVertexArray(vertices); >geometry->addPrimitiveSet(elements); > > In this case when I move the mouse over that geometry I get > containsIntersections() = false. > Could you please explain me why? > > Regards, > Gianni > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=61492#61492 > > > > > > ___ > 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
[osg-users] PolytopeIntersector and LineSegmentIntersector
Hi All, I'm trying to handle mouse movements to show some informations to the user. I have basically two questions. 1) Lookig at "osgkeyboardmouse.cpp" example found the following code: Code: if (_useWindowCoordinates) { // use window coordinates // remap the mouse x,y into viewport coordinates. osg::Viewport* viewport = viewer->getCamera()->getViewport(); double mx = viewport->x() + (int)((double )viewport->width()*(ea.getXnormalized()*0.5+0.5)); double my = viewport->y() + (int)((double )viewport->height()*(ea.getYnormalized()*0.5+0.5)); // half width, height. double w = 5.0f; double h = 5.0f; picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h ); } else { double mx = ea.getXnormalized(); double my = ea.getYnormalized(); double w = 0.05; double h = 0.05; picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h ); } Is there a casa in which osgUtil::Intersector::WINDOW option is preferred with respect to osgUtil::Intersector::PROJECTION? 2) osgUtil::LineSegmentIntersector does not seem to work fine if the geometry is a line created with: osg::Vec3Array* vertices = new osg::Vec3Array; ... osg::DrawElementsUInt* elements = new osg::DrawElementsUInt(osg::PrimitiveSet::LINE_STRIP); geometry->setVertexArray(vertices); geometry->addPrimitiveSet(elements); In this case when I move the mouse over that geometry I get containsIntersections() = false. Could you please explain me why? Regards, Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61492#61492 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector, LineSegmentIntersector, and PagedLOD
Hi, Thanks for the tips. I know the planes' orientations need to be right. I assumed that by creating the Polytope from a BoundingBox that they would be, and when I inspect the values I think they're correct. I did try flipping them all in case I was wrong about the orientation, but that didn't help. I meant to say that I did set a read callback on my PagedLODs. The callback works just fine for rendering, but maybe there's something weird about it when it comes to intersection visitors. I'm generating traces now to see how the LineSegmentIntersector and PolytopeIntersector differ. Thanks again. Cheers, Chris -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58596#58596 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector, LineSegmentIntersector, and PagedLOD
HI Chris, It really is hard to know what is going on with your usage as I don't know you data or the code that you are using with the OSG. It could be a problem with the orientation of the planes of the Polytope - they are need to be consistent with all their normals pointing inwards. If you have just one plane's normal pointing outwards the test will fail, using a flip on the all the planes of the polytop will just reverse the problem so won't magically fix anything. Robert. On 12 March 2014 20:15, Chris Long wrote: > Hi, > > I'm getting unexpected behavior from PolytopeIntersector and was wondering > if it might have something to do with the PagedLODs in my scene graph. > > I want to find all polygons in a rectilinear volume in my model, in model > coordinates (not related to any view on the screen) based on two corner > vertices. > > The weird thing is that if I use the two corner points as the ends of a > LineSegmentIntersector, I find intersections, but a PolytopeIntersector > with Polytope made from a BoundingBox with those same corner points, over > the same graph, finds no intersections. > > Shouldn't the PolytopeIntersector at least find the geometry that the > LineSegmentIntersector does? > > I thought I might have the direction of the planes backwards for the > Polytope, so I tried flip() but either way I get no intersections. > > I've read through the code and it looks like there might be issues related > to the PagedLODs in my scene graph. Any idea if PolytopeIntersector and > PagedLOD play together well or not? > > I've looked for examples and read code for PolytopeIntersector, but there > doesn't seem to be much out there, and most of it uses View-based > intersection, not model-based. > > Thank you! > > Cheers, > Chris > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=58575#58575 > > > > > > ___ > 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] PolytopeIntersector, LineSegmentIntersector, and PagedLOD
Hi Chris, I also fight a long time with PolytopeIntersector and PagedLOD. Did you add callback to read your PagedLOD? See osgSim::LineOfSight for an example. Does it help? Regards 2014-03-12 21:15 GMT+01:00 Chris Long : > Hi, > > I'm getting unexpected behavior from PolytopeIntersector and was wondering > if it might have something to do with the PagedLODs in my scene graph. > > I want to find all polygons in a rectilinear volume in my model, in model > coordinates (not related to any view on the screen) based on two corner > vertices. > > The weird thing is that if I use the two corner points as the ends of a > LineSegmentIntersector, I find intersections, but a PolytopeIntersector > with Polytope made from a BoundingBox with those same corner points, over > the same graph, finds no intersections. > > Shouldn't the PolytopeIntersector at least find the geometry that the > LineSegmentIntersector does? > > I thought I might have the direction of the planes backwards for the > Polytope, so I tried flip() but either way I get no intersections. > > I've read through the code and it looks like there might be issues related > to the PagedLODs in my scene graph. Any idea if PolytopeIntersector and > PagedLOD play together well or not? > > I've looked for examples and read code for PolytopeIntersector, but there > doesn't seem to be much out there, and most of it uses View-based > intersection, not model-based. > > Thank you! > > Cheers, > Chris > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=58575#58575 > > > > > > ___ > 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
[osg-users] PolytopeIntersector, LineSegmentIntersector, and PagedLOD
Hi, I'm getting unexpected behavior from PolytopeIntersector and was wondering if it might have something to do with the PagedLODs in my scene graph. I want to find all polygons in a rectilinear volume in my model, in model coordinates (not related to any view on the screen) based on two corner vertices. The weird thing is that if I use the two corner points as the ends of a LineSegmentIntersector, I find intersections, but a PolytopeIntersector with Polytope made from a BoundingBox with those same corner points, over the same graph, finds no intersections. Shouldn't the PolytopeIntersector at least find the geometry that the LineSegmentIntersector does? I thought I might have the direction of the planes backwards for the Polytope, so I tried flip() but either way I get no intersections. I've read through the code and it looks like there might be issues related to the PagedLODs in my scene graph. Any idea if PolytopeIntersector and PagedLOD play together well or not? I've looked for examples and read code for PolytopeIntersector, but there doesn't seem to be much out there, and most of it uses View-based intersection, not model-based. Thank you! Cheers, Chris -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58575#58575 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi, I'm also interested if you have a solution to easily pick points & lines ! Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52972#52972 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
On Thu, Mar 7, 2013 at 4:53 AM, Robert Milharcic < robert.milhar...@ib-caddy.si> wrote: > On 4.3.2013 11:05, Andreas Roth wrote: > >> hanks to Aurelien for the work-around. >> > Hi Andreas, > > That is of course my personal opinion, but i think PolytopeIntersector is > overkill for most, if not all usage scenarios plus it doesn't work > correctly on a scaled geometry. I simply took LineSegmentIntersector > renamed it to IntersectorPrivate, added some sensitive area along picking > vector, added suport for lines, points etc... As I remember it, it was > pretty straight foward task... I'm not saying my solution is perfect nor > thoroughly tested but it works well for our needs. Of course if someone > would like to see what I did I can paste code here... The only reason we used the PI in osgEarth was to support line and point picking. So if you have a better solution that you are willing to share, we would be interested in evaluating it. Glenn Waldron / @glennwaldron ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
On 4.3.2013 11:05, Andreas Roth wrote: hanks to Aurelien for the work-around. Hi Andreas, That is of course my personal opinion, but i think PolytopeIntersector is overkill for most, if not all usage scenarios plus it doesn't work correctly on a scaled geometry. I simply took LineSegmentIntersector renamed it to IntersectorPrivate, added some sensitive area along picking vector, added suport for lines, points etc... As I remember it, it was pretty straight foward task... I'm not saying my solution is perfect nor thoroughly tested but it works well for our needs. Of course if someone would like to see what I did I can paste code here... Robert Milharcic ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi, i tried to use the osgEarth::Picker class, which uses the PolytopeIntersector for picking and came across the same issue. I used Aurelien work-around and recalculate the distance, but as Aurelien already mentioned it's quite slow because of all the recalculation and sorting. Since Aurelien posted it's work-around more than a year has passed and i'm curious if there's are progress concerning this issue (i'm using 3.1.5 and the issue is still there). For now i'm happy with the work-around, but this not the best solution i think. Many thanks to Aurelien for the work-around. Regards, Andreas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52947#52947 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi, Yes, I'm facing the same problem. I found a workaround by resorting intersections in a new container : for each intersection : - I compute the worldIntersectionPoint by transfoming the localIntersectionPoint in world coordinates - I compute the camera world position <-> worldIntersectionPoin distance It's a little slow, and it's only a workaround, but it works. Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44973#44973 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Peter Hrenka wrote: > > I had a partial fix which helped as long as there is no projection involved. > Unfortunately that is probably the main use-case... I think the proper way to > do this involves storing the inverse matrices in the result-structure and > back-transforming the intersection points before sorting. > Has anyone resolved this bug with incorrect "distance" reported by the PolytopeIntersector when objects are scaled? cheers, nick -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42907#42907 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector usage
Hi Peter, Yes this is a nice precision, the euclidian distance will be a second pass to check the intersected results. Thanks a lot :-) Regards, Vincent Le 08/09/2011 10:21, Peter Hrenka a écrit : Hi Vincent, Am 08.09.2011 10:00, schrieb Vincent Bourdier: Hi Peter Le 08/09/2011 09:40, Peter Hrenka a écrit : The goal is to compute if a point is at less than a fixed distance from a node, and to my mind the intersection is the best way but maybe there is something more adapted ? I think that should be possible. I would recommend using a cube which contains the distance-sphere as the polytope and check the results from the PolytopeIntersector for the real (euclidian) distance. I would advise against trying to use a "sphere"-polytope since the intersector must check all polytope-planes in the innermost loop. I am trying with an octaedron (8 faces) to avoid having a complex structure (like a sphere) with too much faces, just to run some tests. I build the polytope a the point position (radius or the checked distance) and compute the intersection. If there is a least one result, I consider the point is near from the the model. There is no need to check the euclidian distance to my mind, isn't it ? Well, it depends what you mean by "distance"... If the octahedron is good enough for you then you are done. But if you need to consider the exact (euclidian) distance then must choose your octahedron to contain the distance-sphere and check the results to eliminate the false-positives which lie in the octahedron but not in the sphere. Thanks for your help. Regards, Vincent Cheers, Peter ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector usage
Hi Vincent, Am 08.09.2011 10:00, schrieb Vincent Bourdier: > Hi Peter > > Le 08/09/2011 09:40, Peter Hrenka a écrit : >>> The goal is to compute if a point is at less than a fixed distance from >>> a node, and to my mind the intersection is the best way but maybe there >>> is something more adapted ? >> I think that should be possible. >> I would recommend using a cube which contains >> the distance-sphere as the polytope and >> check the results from the PolytopeIntersector >> for the real (euclidian) distance. >> >> I would advise against trying to >> use a "sphere"-polytope since >> the intersector must check all >> polytope-planes in the innermost loop. > > I am trying with an octaedron (8 faces) to avoid having a complex > structure (like a sphere) with too much faces, just to run some tests. > > I build the polytope a the point position (radius or the checked > distance) and compute the intersection. > If there is a least one result, I consider the point is near from the > the model. > There is no need to check the euclidian distance to my mind, isn't it ? Well, it depends what you mean by "distance"... If the octahedron is good enough for you then you are done. But if you need to consider the exact (euclidian) distance then must choose your octahedron to contain the distance-sphere and check the results to eliminate the false-positives which lie in the octahedron but not in the sphere. > Thanks for your help. > > Regards, >Vincent Cheers, 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: Philippe Miltin 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] PolytopeIntersector usage
Hi Peter Le 08/09/2011 09:40, Peter Hrenka a écrit : The goal is to compute if a point is at less than a fixed distance from a node, and to my mind the intersection is the best way but maybe there is something more adapted ? I think that should be possible. I would recommend using a cube which contains the distance-sphere as the polytope and check the results from the PolytopeIntersector for the real (euclidian) distance. I would advise against trying to use a "sphere"-polytope since the intersector must check all polytope-planes in the innermost loop. I am trying with an octaedron (8 faces) to avoid having a complex structure (like a sphere) with too much faces, just to run some tests. I build the polytope a the point position (radius or the checked distance) and compute the intersection. If there is a least one result, I consider the point is near from the the model. There is no need to check the euclidian distance to my mind, isn't it ? Thanks for your help. Regards, Vincent ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector usage
Hi Vincent, Am 08.09.2011 08:51, schrieb Vincent Bourdier: > Hi all, > > I'm currently trying to compute an intersection between a sphere and a > node. > PolytopeIntersector seems to be the best choice according to the > documentation, but I didn't find any example of implementation. Have a look at the osgkeyboardmouse example. > Next, are there some limitations to its usage ? (I saw something about > convex clipping volumes...) PolytopeIntersector is mostly useful when used for interactive picking with small volumes. Its return data structure is too big for large volumes (containing lots of intersections). > The goal is to compute if a point is at less than a fixed distance from > a node, and to my mind the intersection is the best way but maybe there > is something more adapted ? I think that should be possible. I would recommend using a cube which contains the distance-sphere as the polytope and check the results from the PolytopeIntersector for the real (euclidian) distance. I would advise against trying to use a "sphere"-polytope since the intersector must check all polytope-planes in the innermost loop. > Thanks for your help. > > Regards, > Vincent. Cheers, 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: Philippe Miltin 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
[osg-users] PolytopeIntersector usage
Hi all, I'm currently trying to compute an intersection between a sphere and a node. PolytopeIntersector seems to be the best choice according to the documentation, but I didn't find any example of implementation. Next, are there some limitations to its usage ? (I saw something about convex clipping volumes...) The goal is to compute if a point is at less than a fixed distance from a node, and to my mind the intersection is the best way but maybe there is something more adapted ? Thanks for your help. Regards, Vincent. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector and containment
Hi Peter, Just I did notice that for long/skinny objects the bounding sphere is a very poor fit. One option for me is to dig down and get the boundingBox() of the drawable that lies as the basis of my geometry. In my experience, that can allow for a much tighter fit for this type of selection. Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28253#28253 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector and containment
Hi Andrew, Andrew Cunningham schrieb: Umm, I think I found my own answer. - Subclass PolytopeIntersector to get access to the _polyTope member - transform this PolyTope by the inverse camera projection matrix to put it into world coords - When processing the Node, get the Node's bounding sphere, and transform that by the Intersection matrix into world coordinates - use the containsAllOf() method of the Polytope You should be aware that bounding spheres can be a really bad fit, especially for "long" objects. That means you can get false negatives because the bounding sphere is not inside the polytope but the actual object is. PolytopeIntersector uses practically the same approach as yours as fast check but unlike your approach it continues to check on the primitives-level if the bounding sphere check fails. In any case the current Intersection- structure of PolytopeIntersector is not well suited to usage patterns where the polytope volume is large (because for every primitive of a contained object a new Intersection is generated). One idea to improve this could be to implement a higher-level-intersection- result interface and generate the old and verbose Intersection format only on demand thus preserving backward compatibility. Whew! Cheers, 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] PolytopeIntersector and containment
Umm, I think I found my own answer. - Subclass PolytopeIntersector to get access to the _polyTope member - transform this PolyTope by the inverse camera projection matrix to put it into world coords - When processing the Node, get the Node's bounding sphere, and transform that by the Intersection matrix into world coordinates - use the containsAllOf() method of the Polytope Whew! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28213#28213 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] PolytopeIntersector and
Hi, I am using the PolytopeIntersector to select , using a mouse based screen rectangle, objects in my scene. Works great. However, when post-processing the intersections returned by the PolytopeIntersector I would like to check for certain nodes whether the (bounding box of the ) node is ENTIRELY within the screen rectangle (aka the PolyTope of the PolytopeIntersector ). This seems like it should be trivial, but I have gone round and round in circles after searching the mailing list and now am totally confused about the best way to do this. Thanks Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28203#28203 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi Peter, I have no time to work on this either at the moment. I will just avoid the scale transforms and scale the objects 'manually'. Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16108#16108 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi Andrew, Andrew Cunningham schrieb: Hi Peter, Did you ever work up a fix for this? ... I had a partial fix which helped as long as there is no projection involved. Unfortunately that is probably the main use-case... I think the proper way to do this involves storing the inverse matrices in the result- structure and back-transforming the intersection points before sorting. Right now I do not have much time to work on PolytopeIntersector, but if you want to fix it yourself I could describe my idea in more detail. It should not be hard (no hairy math involved). Thank you! Cheers, Andrew Cheers, 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] PolytopeIntersector "distance" and Transform
Hi Peter, Did you ever work up a fix for this? ... Thank you! Cheers, Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16056#16056 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi, Peter Thanks for looking into this a tricky bug ... I got really lost trying to trace the problem myself. good luck! I think as a workaround I will scale the geometry manually without using a transform. Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14370#14370 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi Andrew, Andrew Cunningham schrieb: Hi Peter, Although your fix did not work - it is definitely the "scale" part of the transform causing the problem. If I remove the scaling part of the transform , then the polytope picking works as expected ... Thank you for the example. It turns out that transforming the "distance" plane is not so straight-forward after all when scaling is involved. I'll try to work out the proper transformation for that case. Cheers, 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] PolytopeIntersector "distance" and Transform
Hi Peter, Although your fix did not work - it is definitely the "scale" part of the transform causing the problem. If I remove the scaling part of the transform , then the polytope picking works as expected ... Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14246#14246 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi again Andrew, Andrew Cunningham schrieb: Hi, I am having some problems with the "distance" found by the PolytopeIntersector but only when the geometry I am trying to pick has a non-null (Matrix)Transform in it's parent. The PolytopeIntersector registers that object as a 'hit', BUT the distance recorded appears to be incorrect ( the end result is I end up 'highlighting' the wrong object behind the object I want to pick). The intersection calculation works perfectly (with the transformed object) but the distance to the reference plane (used for sorting the intersections) does not accurately reflect the expected distance. Just to re-iterate this. As long as I do not try to pick a node with a transform, the sorting of the PolytopeIntersector works as expected Using the "LineSegmentIntersector" on the same scene does not show the issue. It correctly sorts the intersections. Any ideas? I had another look at the code and found a nasty surprise in Plane::transformProvidingInverse(). There is a call to Plane::makeUnitLength() in it which should totally screw distance results of PolytopeIntersector if you have any non-orthogonal Matrix-Transforms (i.e. scaling). Could you try commenting out this line and check if it works for you? If it does help I will think of a proper fix. Thanks Andrew Cheers 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] PolytopeIntersector
Hi Maxime, Maxime BOUCHER schrieb: Hi, Just a question. The polytopeIntersections compute the intersections with planes or "all" "objects" in the Polytope? I mean if I draw the "local intersection points" will I get an empty or full shape of the polytope? The polytopeIntersector performs the intersection with the space volume defined by the polytope. So if a triangle lies completely inside the polytope (without intersecting the polytope's planes) it is still considered an "intersection" because it intersects the volume. I wonder because I tried a polytope with a single plane (to test), and I had a lot of points non coplanars... Yes, that is to be expected because you basically got all primitives lying in the half-space to one side of your plane. I also drawed it using intersection.localIntersectionPoint, which is the center of the primitive, isn't it? Almost ;-) No actually it is the center of all "intersection"-points. Say you have a triangle where two points lie inside the polytope-space and one point lies outside of this space. Than you have 2 intersection-points for the points lying inside, and 2 intersections points where the edges intersect the polytope plane(s). This gives you a total of 4 intersection points and the localIntersectionPoint is the centroid(barycenter) of those 4 points. Cheers, 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] PolytopeIntersector
Hi, Just a question. The polytopeIntersections compute the intersections with planes or "all" "objects" in the Polytope? I mean if I draw the "local intersection points" will I get an empty or full shape of the polytope? I wonder because I tried a polytope with a single plane (to test), and I had a lot of points non coplanars... I also drawed it using intersection.localIntersectionPoint, which is the center of the primitive, isn't it? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14226#14226 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector "distance" and Transform
Hi Andrew, Andrew Cunningham schrieb: Hi, I am having some problems with the "distance" found by the PolytopeIntersector but only when the geometry I am trying to pick has a non-null (Matrix)Transform in it's parent. The PolytopeIntersector registers that object as a 'hit', BUT the distance recorded appears to be incorrect ( the end result is I end up 'highlighting' the wrong object behind the object I want to pick). The intersection calculation works perfectly (with the transformed object) but the distance to the reference plane (used for sorting the intersections) does not accurately reflect the expected distance. Just to re-iterate this. As long as I do not try to pick a node with a transform, the sorting of the PolytopeIntersector works as expected I had a look at the code but could not spot any obvious flaws. The Matrix-Transforms are handled in the method PolytopeIntersector::clone() and the reference-plane is transformed in sync with the Polytope. Using the "LineSegmentIntersector" on the same scene does not show the issue. It correctly sorts the intersections. Any ideas? Do your transformations have a scaling component? Thanks Andrew Cheers 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
[osg-users] PolytopeIntersector "distance" and Transform
Hi, I am having some problems with the "distance" found by the PolytopeIntersector but only when the geometry I am trying to pick has a non-null (Matrix)Transform in it's parent. The PolytopeIntersector registers that object as a 'hit', BUT the distance recorded appears to be incorrect ( the end result is I end up 'highlighting' the wrong object behind the object I want to pick). The intersection calculation works perfectly (with the transformed object) but the distance to the reference plane (used for sorting the intersections) does not accurately reflect the expected distance. Just to re-iterate this. As long as I do not try to pick a node with a transform, the sorting of the PolytopeIntersector works as expected Using the "LineSegmentIntersector" on the same scene does not show the issue. It correctly sorts the intersections. Any ideas? Thanks Andrew -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14189#14189 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector
[quote]The point of Polytopes is that they are convex which makes all kinds of tests very easy. If you want to modell something non-convex (something like Constructive Solid Geometry) then PolytopeIntersector will not help you as it is.[quote] My solutution was to triangulate the convex polygon I wanted to search using osgUtil::Tessellator and then use polytrope interceptor for each triangle. I also looked at splitting the polygon into a number of convex polygons but there was no speed difference for polygons having <100 sides. Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14115#14115 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector
Hi Maxime, Maxime BOUCHER schrieb: [...] Peter Hrenka wrote: You call the method accept(osg::NodeVisitor&) of your model (which is a osg::Node). See the example osgkeyboardmouse. My bad, I should have seen it. We certainly need an osgpolytopeintersector example... Meanwhile "grep" is your friend. Peter Hrenka wrote: This exercise is about polygons not polytopes! Yes, I meant "testing this way for each primitive". Well... I fail to see an analogy here. The point of Polytopes is that they are convex which makes all kinds of tests very easy. If you want to modell something non-convex (something like Constructive Solid Geometry) then PolytopeIntersector will not help you as it is. Peter Hrenka wrote: As for the PolytopeIntersector: It will give you all points, lines, triangles and quads which truly intersect the polytope volume, given by the primitive index. Sorry, I'm not sure I really understand. It is possible to get the intersected triangle instead of just a list of intersections coordinates? The struct PolytopeIntersector::Intersection contains a int-member "primitiveIndex" which probably is what you want. There is code to output the primitiveIndex in the osgkeyboardmouse example. You can access the first intersection with PolytopeIntersector::getFirstIntersection() or the set of all Intersections with PolytopeIntersector::getIntersections(). Cheers, 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] PolytopeIntersector
Thank you very much Peter. Peter Hrenka wrote: > Hi Maxime, > > The plane uses the above plane equation. > (If you are familiar with projective spaces, the Vec4 can be seen > as the projective normal in homogenous coordinates: > (a,b,c,d) dot (x,y,z,w) = 0, where w=1 for affine points ) > > Note the the representation is only unique up to a > factor (you can always multiply the equation with a > factor != 0.0) > > The normal is given implicitly by the representation. Given the above > equation, the normal is (a,b,c). You can easily change the direction > of the plane normal unsing its flip()-method. > Ok ! Peter Hrenka wrote: > > No problem at all. PolytopeIntersector uses open polytopes internally > when the geometry lies to one side of a plane. > Great Peter Hrenka wrote: > > You call the method accept(osg::NodeVisitor&) of your model (which is a > osg::Node). > See the example osgkeyboardmouse. > My bad, I should have seen it. Peter Hrenka wrote: > > This exercise is about polygons not polytopes! > Yes, I meant "testing this way for each primitive". Peter Hrenka wrote: > > As for the PolytopeIntersector: It will give you all points, > lines, triangles and quads which truly intersect the polytope volume, > given by the primitive index. > Sorry, I'm not sure I really understand. It is possible to get the intersected triangle instead of just a list of intersections coordinates? Peter Hrenka wrote: > > > Cheers, > > 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 > thanks again, Max -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14090#14090 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector
Hi Maxime, Maxime BOUCHER schrieb: Hi, I have a lot of questions for you! But, there is one really more critical than the others. Let me just introduce the problem :). (I am sorry if I bother, but I searched on the net, in the doc and examples and didn't find answers. I apologize if this is because I badly searched.) I want to cut my primitives along the frustum of a camera. 1) To do this I first have to get my planes equations. I have found a page dealing about this problem in OpenGL: http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf I think I'll use it, replacing in OSG conventions. I also found this: http://markmail.org/message/eeolcuruqpsbgrgu#query:osg%20frustum+page:1+mid:eeolcuruqpsbgrgu+state:results From famous Paul ;). Well, it draws the frustum, but it can be used to get the planes equations. (for whom it may interest) 2) Then I have my equations. Thus I can declare many osg::Plane. Question If the plane is a Vec4d (a,b,c,d) does it well represent the equation ax+by+cz+d = 0 ? The plane uses the above plane equation. (If you are familiar with projective spaces, the Vec4 can be seen as the projective normal in homogenous coordinates: (a,b,c,d) dot (x,y,z,w) = 0, where w=1 for affine points ) Note the the representation is only unique up to a factor (you can always multiply the equation with a factor != 0.0) I would like to use a PolytopeIntersector. In the doc it's written planes normals have to point the inside of the polytope. Question How are the normals set when the plane is initialized? The normal is given implicitly by the representation. Given the above equation, the normal is (a,b,c). You can easily change the direction of the plane normal unsing its flip()-method. Question Is there any problem declaring a non-closed (also called opened) polytope? I don't mind about the far plane. No problem at all. PolytopeIntersector uses open polytopes internally when the geometry lies to one side of a plane. 3) Once I have a polytope, I would like to intersect the polytope with the scene. Thus I declare a PolytopeIntersector I associate to an IntersectionVisitor. The BIG Question How do I associate the IntersectionVisitor to a model? I saw for a LineIntersector it is possible to associate it to a view via computeIntersections(), but it doesn't seem possible to do the same with polytope. You call the method accept(osg::NodeVisitor&) of your model (which is a osg::Node). See the example osgkeyboardmouse. 4) Question Having the intersected points, is it possible to "easily" get the primitive or do I have to use this (it is in french, sorry): http://www.enseignement.polytechnique.fr/profs/informatique/Philippe.Chassignet/03-04/INF_431/td_16.html (exercise 4) This exercise is about polygons not polytopes! As for the PolytopeIntersector: It will give you all points, lines, triangles and quads which truly intersect the polytope volume, given by the primitive index. Thank you a lot! Cheers, Maxime Cheers, 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
[osg-users] PolytopeIntersector
Hi, I have a lot of questions for you! But, there is one really more critical than the others. Let me just introduce the problem :). (I am sorry if I bother, but I searched on the net, in the doc and examples and didn't find answers. I apologize if this is because I badly searched.) I want to cut my primitives along the frustum of a camera. 1) To do this I first have to get my planes equations. I have found a page dealing about this problem in OpenGL: http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf I think I'll use it, replacing in OSG conventions. I also found this: http://markmail.org/message/eeolcuruqpsbgrgu#query:osg%20frustum+page:1+mid:eeolcuruqpsbgrgu+state:results >From famous Paul ;). Well, it draws the frustum, but it can be used to get the planes equations. (for whom it may interest) 2) Then I have my equations. Thus I can declare many osg::Plane. Question If the plane is a Vec4d (a,b,c,d) does it well represent the equation ax+by+cz+d = 0 ? I would like to use a PolytopeIntersector. In the doc it's written planes normals have to point the inside of the polytope. Question How are the normals set when the plane is initialized? Question Is there any problem declaring a non-closed (also called opened) polytope? I don't mind about the far plane. 3) Once I have a polytope, I would like to intersect the polytope with the scene. Thus I declare a PolytopeIntersector I associate to an IntersectionVisitor. The BIG Question How do I associate the IntersectionVisitor to a model? I saw for a LineIntersector it is possible to associate it to a view via computeIntersections(), but it doesn't seem possible to do the same with polytope. 4) Question Having the intersected points, is it possible to "easily" get the primitive or do I have to use this (it is in french, sorry): http://www.enseignement.polytechnique.fr/profs/informatique/Philippe.Chassignet/03-04/INF_431/td_16.html (exercise 4) Thank you a lot! Cheers, Maxime -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=14070#14070 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PolytopeIntersector and occlusion
Hi Robert, The PolytopeIntersector just detects and records objects that intersect with the Polytope, there is no interrelation between the objects, there are all just independent intersections. So for the functionality you are after you'll need to post process the list of intersections. OK, that's what I thought. I'm not 100% clear from your description, but it I do wonder if what your after isn't a bit like what the ConvexPlanerOccluder support does when doing culling against occluders. The support for this you'll find in SceneView.cpp and the ocluder helper classes. Interesting, how well does that perform? It's a GUI operation (on mouse release) so it doesn't have to be lightning fast, but I'd still like it to be efficient. Thanks for giving me a path to investigate. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] 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] PolytopeIntersector and occlusion
Hi J-S, The PolytopeIntersector just detects and records objects that intersect with the Polytope, there is no interrelation between the objects, there are all just independent intersections. So for the functionality you are after you'll need to post process the list of intersections. I'm not 100% clear from your description, but it I do wonder if what your after isn't a bit like what the ConvexPlanerOccluder support does when doing culling against occluders. The support for this you'll find in SceneView.cpp and the ocluder helper classes. Robert. On Wed, Oct 22, 2008 at 2:26 PM, Jean-Sébastien Guay <[EMAIL PROTECTED]> wrote: > Hello all, > > I am implementing box-selection of objects using > osgUtil::PolytopeIntersector. When I use LineSegmentIntersector, I know that > the first intersection returned is the closest object that was intersected. > In the case of PolytopeIntersector, I need something more. > > Basically, I need to know if an object was visible in the polytope or if it > was completely behind some other object. For example, if object A is in > front and object B is completely behind object A (inside the polytope) then > I want to select only object A. But if part of object B was visible (inside > the polytope) then I want to select both. > > As I understand it, the intersections returned by the intersector are > ordered by depth but I can't see a way to find out if an intersected object > is visible or not. I want to be able to select multiple objects but only > those that are visible from the camera used to do the intersection. > > What I could think is if I had a list of the nodes that were hit for a given > intersection, I could check if the given node was the first to be hit for > some of its intersections. I so, then it was (at least partially) visible in > the polytope, and if not, then some other node was in front of it and > obscured it completely in the polytope. Is that information available in > some way? > > Thanks in advance, > > J-S > -- > __ > Jean-Sebastien Guay[EMAIL PROTECTED] > 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
[osg-users] PolytopeIntersector and occlusion
Hello all, I am implementing box-selection of objects using osgUtil::PolytopeIntersector. When I use LineSegmentIntersector, I know that the first intersection returned is the closest object that was intersected. In the case of PolytopeIntersector, I need something more. Basically, I need to know if an object was visible in the polytope or if it was completely behind some other object. For example, if object A is in front and object B is completely behind object A (inside the polytope) then I want to select only object A. But if part of object B was visible (inside the polytope) then I want to select both. As I understand it, the intersections returned by the intersector are ordered by depth but I can't see a way to find out if an intersected object is visible or not. I want to be able to select multiple objects but only those that are visible from the camera used to do the intersection. What I could think is if I had a list of the nodes that were hit for a given intersection, I could check if the given node was the first to be hit for some of its intersections. I so, then it was (at least partially) visible in the polytope, and if not, then some other node was in front of it and obscured it completely in the polytope. Is that information available in some way? Thanks in advance, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] 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] polytopeIntersector
Hi Gianloca, Gianluca Natale wrote: > Hi, > I went deeply in debug into my code, and I discovered that the problem > is in OSG v.2.2. > Actually it returns the object with the shortest node path among those > in the intersection vector. > Was it a known bug? No, I do not consider this a bug. As a polytope has no concept of "near" or "far" the order of the result is actually arbitrary. Of course the method-name "getFirstIntersection" is misleading... To overcome this shortcoming I introduced the concept of "ReferencePlane" to the PolytopeIntersector which probably does what you want but my modifications did not make it into OSG 2.2. If you must use 2.2, you could try to take the PolytopeIntersector from the current OSG dev Release, rename it to MyPolytopeIntersector and use with 2.2. > Thanks in advance > Gianluca Peter -- creating IT solutions Peter Hrenkascience + computing ag Software Solutions Hagellocher Weg 73 phone +49 7071 9457 263 72070 Tuebingen, Germany fax +49 7071 9457 511 [EMAIL PROTECTED] www.science-computing.de -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Florian Geyer, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Prof. Dr. Hanns Ruder 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] polytopeIntersector
Hi, I went deeply in debug into my code, and I discovered that the problem is in OSG v.2.2. Actually it returns the object with the shortest node path among those in the intersection vector. Was it a known bug? Thanks in advance Gianluca -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: Thursday, January 10, 2008 9:05 PM To: OpenSceneGraph Users Subject: Re: [osg-users] polytopeIntersector HI Gianluca, In the 2.3.x dev release and SVN of the OSG there are improvements to the PolytopeIntersector that might help you so it'd be worth trying out over using 2.2 Robert. On Jan 10, 2008 5:46 PM, Gianluca Natale <[EMAIL PROTECTED]> wrote: > > > > > Hi all! > > > > I'm trying to use a osgUtil::PolytopeIntersector > > to find the closest object in my 3D scene graph (with OSG ver.2.2). > > I read on the OSG QSG that it should return the closest object > > as the first in the list of intersections. > > But it is not like that! > > I mean that the array of intersections correctly contains all of > > the objects hit by the intersection volume, > > but the first of those is not necessary the closest. > > BTW, it seems to be the object with the shortest node path. Might it be? > > > > Any idea of my mistake? > > > > Thank you in advance. > > > > Gianluca > > > > P.S.=attached is the source file (look into the class PickHandler, > > in the method pick; first I tried getting directly the first > intersection in > > the list, picker->getFirstIntersection(); then I tried to sort > > the intersection on my own. But I pick always the background > rectangle!) > > > ___ > 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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] polytopeIntersector
HI Gianluca, In the 2.3.x dev release and SVN of the OSG there are improvements to the PolytopeIntersector that might help you so it'd be worth trying out over using 2.2 Robert. On Jan 10, 2008 5:46 PM, Gianluca Natale <[EMAIL PROTECTED]> wrote: > > > > > Hi all! > > > > I'm trying to use a osgUtil::PolytopeIntersector > > to find the closest object in my 3D scene graph (with OSG ver.2.2). > > I read on the OSG QSG that it should return the closest object > > as the first in the list of intersections. > > But it is not like that! > > I mean that the array of intersections correctly contains all of > > the objects hit by the intersection volume, > > but the first of those is not necessary the closest. > > BTW, it seems to be the object with the shortest node path. Might it be? > > > > Any idea of my mistake? > > > > Thank you in advance. > > > > Gianluca > > > > P.S.=attached is the source file (look into the class PickHandler, > > in the method pick; first I tried getting directly the first > intersection in > > the list, picker->getFirstIntersection(); then I tried to sort > > the intersection on my own. But I pick always the background > rectangle!) > > > ___ > 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] polytopeIntersector
Hi Gianluca You say you wish to get the nearest intersection with the PolytopeIntersector... I think the mistake is here: osg::NodePath& nodePath = /*picker->getFirstIntersection()*/closestIntersection.nodePath; If you want to have the nearest intersection, you must get the first intersection from the picker... osg::NodePath& nodePath = picker->getFirstIntersection(); We also use the Polytope Intersector in our Project. And it works great! Daniel Am Donnerstag, 10. Januar 2008 18.46:18 schrieb Gianluca Natale: > Hi all! > > > > I'm trying to use a osgUtil::PolytopeIntersector > > to find the closest object in my 3D scene graph (with OSG ver.2.2). > > I read on the OSG QSG that it should return the closest object > > as the first in the list of intersections. > > But it is not like that! > > I mean that the array of intersections correctly contains all of > > the objects hit by the intersection volume, > > but the first of those is not necessary the closest. > > BTW, it seems to be the object with the shortest node path. Might it be? > > > > Any idea of my mistake? > > > > Thank you in advance. > > > > Gianluca > > > > P.S.=attached is the source file (look into the class PickHandler, > > in the method pick; first I tried getting directly the first > intersection in > > the list, picker->getFirstIntersection(); then I tried to sort > > the intersection on my own. But I pick always the background > rectangle!) ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] polytopeIntersector
Hi all! I'm trying to use a osgUtil::PolytopeIntersector to find the closest object in my 3D scene graph (with OSG ver.2.2). I read on the OSG QSG that it should return the closest object as the first in the list of intersections. But it is not like that! I mean that the array of intersections correctly contains all of the objects hit by the intersection volume, but the first of those is not necessary the closest. BTW, it seems to be the object with the shortest node path. Might it be? Any idea of my mistake? Thank you in advance. Gianluca P.S.=attached is the source file (look into the class PickHandler, in the method pick; first I tried getting directly the first intersection in the list, picker->getFirstIntersection(); then I tried to sort the intersection on my own. But I pick always the background rectangle!) // Test 11: OSG 3D application with node callback to dynamically modify the graph, // changing the color of an object when it is picked by the user (and restoring // it to the original color once no object is selected any more). // It creates a scene graph, and shows it in a window created by the osgViewer::Viewer. // The camera is kept rotating around the scene to let it be seen from many different // points of view (that is accomplished by directly modifying the modelview matrix // of the camera in the main loop). // When the user picks a point onto the screen (picking is checked by deriving a class // from an osgGA::GUIEventHandler), a Polytope intersector is created and // passed to an IntersectionVisitor. So, at the end it will return the list of selected // objects, sorted from the nearest to the viewer up to the farthest. // Then the picker will attach a ChangeColor callback to the nearest selected node, in // order to change its current color to the 'selection' color in the next update traversal. // Note that the color is changed by changing the material properties of the object, // so changing the corresponding rendering state in the parent matrix transform of the node. // The scene graph shown in the window is made by these nodes: // //MRT MRT = main root node // | TMn = tranformation matrix n //+---++--+++ GPn = group n // TM1 GP1 TM6 TM7 TM8GEn = geode n //| ++--+--++ ||| LSn = light source n //| TM2 TM3 TM4 TM5 ||| //| ++--+--++ ||| // GE1 GE2 LS1 LS2 GE3 // // Specifically, in this graph we have: // GE1 = a rectangle // GE2 = a sphere // GE3 = a cube to show the position of the spot light source (LS2) // LS1 = a directional light (fixed in the scene) // LS2 = a localized spot light (moving with the scene) / #include// include the class osg::ref_ptr, to manage the smart osg ref_ptr // (a smart pointer to Referenced objects in OSG) #include // include the class osg::Geometry to manage the geometry of a drawable // (vertices, colors, normals) #include // include the class osg::geode (geode stands for GEOmetry noDE), // that is to say the node which stores the geometry of an object #include // for material properties, when an object is lit by a light source #include // for the generic shape drawable used to implement spheres, cylinders, etc... #include // to store a source of light in the scene graph, in order to lit the scene #include // to deal with transformation matrices #include // to store a group node, that is to say a node that can have child nodes #include // to store the shade model of an object (FLAT or SMOOTH) #include // to include the viewer, which creates a window and a rendering // context, to make it current for OpenGL drawing commands #include // for node callback, that allows a dynamic modification of the graph #include // (during the update traversal) #include // the base class to handle events from the user #include #include #include // to check intersection against a polytope and objects #include // in the scene #include #include using std::endl; /// // A class derived from NodeCallback to allow dynamic modification of a transformation // matrix (that is to say, the material properties associated with that matrix) class ChangeColorCB : public osg::NodeCallback { public: ChangeColorCB(osg::