Re: [osg-users] Intersection with a ray

2011-02-11 Thread Geoff Rhodes
Hi,

I know this is old, but I was wondering what your solution was? I need to do a 
similar task.

... 

Thank you!

Cheers,
Geoff

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36571#36571





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Intersection with a ray

2010-07-26 Thread lucie lemonnier
Hi,
I use osgUtil::LineSegmentIntersector to obtain the intersections between a 
mouse or a ray starting from a wand and a terrain generated with 
VirtualPlanetBuilder and to display the latitude, longitude and height of the 
intersection point. 
When I use the LineSegmentIntersector with the mouse and I use the camera which 
accept the IntersectionVisitor, the values of latitude, longitude and height 
are correct.
Here is my code : 


 osg::ref_ptr osgUtil::LineSegmentIntersector  picker = new 
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y);
osgUtil::IntersectionVisitor iv(picker.get());
view-getCamera()-accept(iv); 
if (picker-containsIntersections())
{
intersections = picker-getIntersections();


for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = 
intersections.begin();
hitr != intersections.end();
++hitr)
{

osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
csn-setEllipsoidModel(new osg::EllipsoidModel());
csn-addChild(group);


point = hitr-getWorldIntersectPoint();


double latitude;
double longitude;
double height;



csn-getEllipsoidModel()-convertXYZToLatLongHeight(point.x(),point.y(),point.z(),latitude,longitude,height);

latitude = osg::RadiansToDegrees(latitude);
longitude = osg::RadiansToDegrees(longitude);

std::cout lat,long,height( latitude  ,  
longitude  ,  height  )  std::endl;

}
}

But, my goal is to obtain the intersections of the terrain with a ray starting 
from a wand. I use here LineSegmentIntersector with the start point of a wand 
and the end point and I use the rootNode which accept the IntersectionVisitor. 
But in this case, the values of latitude, longitude and height are false.
Here is my code : 

osg::Vec3 wandp1;
osg::Vec3 wandp2;

osg::ref_ptr osgUtil::LineSegmentIntersector  picker = new 
osgUtil::LineSegmentIntersector(wandp1,wandp2);

osgUtil::LineSegmentIntersector::Intersections intersections;
osgUtil::IntersectionVisitor iv(line.get());
rootNode-accept(iv);

if(picker-containsIntersections()){
//same code as before

}

In red are the differences between the two methods.
I don't understand what is the problem.
Can you help me, please?

Thank you!

Cheers,
lucie

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30262#30262





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with a ray

2010-07-26 Thread Tom Pearce
Hi Lucie,

When you make a line segment intersector with just two Vec3s as input 
arguments, the line segment runs from one point to the other in model 
coordinates.  How are you finding wandp1 and wandp2?  In your code it looks 
like they are uninitialized in which case they are both (0, 0, 0).  If you 
actually do have the values for the two points, would you expect that line to 
intersect your terrain?

Cheers,
Tom

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30273#30273





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Intersection with a ray

2010-07-26 Thread lucie lemonnier
Hi,

Thank you for your reply. I have initialized my two points depending on the 
position of my wand into space so the error was not this. In fact, I found an 
error in my code and now it works.

Cheers,
lucie

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30283#30283





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org