Hi Folks,

 

I am having trouble with Coordinate transformations when using the
LineSegmentIntersector. I  made a VERY simple one rectangular polygon
test VRML model.  I can load this fine into OSG and even save it as an
.osg model and then reload it.  The simple VRML code shown below at the
bottom.  Note I did not use any transformations (all comented out)..

 

I'm assuming the rectangle is in the X-Y Plane and is longer in the X
direction.

 

In my test code, I call the LineSegmentIntersector simply as shown below
with start and end points defined as

 

osg::Vec3 start(  0, 0, -50);

osg::Vec3 end(  0, 0,50 );

 

So I assume this should create a line that runs in the +- Z direction
and cuts through the center of the plane.

here's the code snippet to call the lineSegmentIntersector

 

 

  osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = 

        new osgUtil::LineSegmentIntersector(start, end);

 

  osgUtil::IntersectionVisitor intersectVisitor( intersector.get(), 

    new MyReadCallback );

 

  root->accept(intersectVisitor);

  if ( intersector->containsIntersections() ){

        std:: cout << "INTERSECTS!\n";

    return true;

  }

  else{

        std:: cout << "no intersects\n";

    return false;

  }

 

HERE'S THE PROBLEM.  IN THE DISPLAY, THE PLANE AND INTERSECTING LINE
LOOK CORRECT.  HOWEVER THE INTERSECTOR RETURNS "NO INTERSECTION".  

HOWEVER IF I REVERSE THE Y AND Z COORDINATES IN THE START AND END
POINTS, THEN IT RETURNS "INTERSECTION" AS IT SHOULD BUT THE DISPLAY
LOOKS WRONG.  

THE LINE IS NOW PARALLEL TO THE PLANE AND NOT INTERSECTING.  This leads
me to think that the coordinate frame assumed by the
LineSegmentIntersector to interpret the start,end points is different
than the coordinate frame used for displaying the model.

 

Can anyone shed some light as to why there would be a discrepancy
between the coordinates used for display and those used by the
intersector?? I could not find any details on coordinate frames in the
documentation..

 

Thanks in advance!

Paul

 

Here's the simple VRML model code..

 

#VRML V2.0 utf8

 

# Produced by 3D Studio MAX VRML97 exporter

# modified by Bitmanagement Software GmbH,  H. Grahn,  Andrea Fasce,
Version 5.01,  Revision 0

# MAX File: 1.10.2008-buildings.max,  Date: Thu Jan 10 13:18:53 2008

 

DEF bld_610_2 Transform {

#  translation 0 0 0

#  translation -2153.17 7.11304 -375.004

#  rotation 0 1 0 0

#  scale 0.0261872 0.0172898 0.0258266

#  scaleOrientation 1 0 0 0

#  rotation 0 0 1 -1.70056

#  scale 0.0261872 0.0172898 0.0258266

#  scale 1 1 1

  children [

    Shape {

      #Material 02 - Default

      appearance DEF MAT-_2___Default Appearance {

        material Material {

          diffuseColor 0.588 0.588 0.588

          ambientIntensity 1.0

          specularColor 0.95 0.95 0.95

          shininess 0.9

        }

        texture 

DEF _T-_10_2all ImageTexture {

              url "610-2all.jpg" }

      }

## render mesh bld_610_2 

      geometry DEF bld_610_2-FACES IndexedFaceSet {

                coord DEF bld_610_2-COORD Coordinate { point [

          100 -50 0, 100 50 0, -100 50 0, -100 -50 0 ]

        }

        texCoord DEF bld_610_2-TEXCOORD TextureCoordinate { point [

          .1 0, 0 .1, .2 0,.3 0 ]

        } 

        coordIndex [

          0, 1, 2, 3, -1, ]

        texCoordIndex [

          0, 1, 2, 3,-1, ]

      }

    }

  ]

}

 

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to