[osg-users] PolytopeIntersector LIMIT_NEAREST (or LIMIT_ONE) different distances for different groupnodes

Robert Osfield robert.osfield at gmail.com
Wed Jun 1 08:08:26 PDT 2016


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 <David.Knipp at gmx.net> 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<float>(x);
> float _y = static_cast<float>(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 at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



More information about the osg-users mailing list