[osg-users] Calculate latitude, longitude, height with intersection point

2010-07-22 Thread lucie lemonnier
Hi,

I want to obtain the latitude, longitude and height when I click with the 
mouse. Here is my code :

osgGA::GUIEventAdapter ea;

osgUtil::LineSegmentIntersector::Intersections intersections;
std::string gdlist=;
float x = ea.getX();
float y = ea.getY();

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)
{
std::ostringstream os;
if (!hitr-nodePath.empty()  
!(hitr-nodePath.back()-getName().empty()))
{
// the geodes are identified by name.
osObject 
\hitr-nodePath.back()-getName()\std::endl;
}
else if (hitr-drawable.valid())
{
osObject 
\hitr-drawable-className()\std::endl;
}


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


oslocal coords vertex( 
hitr-getLocalIntersectPoint())std::endl;
osworld coords vertex( 
hitr-getWorldIntersectPoint())std::endl;

osg::Vec3 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);

oslat,long,height( latitude  ,  longitude 
 ,  height  ) std::endl;

gdlist += os.str();

}
}


This works well when I don't make a translation or rotation on the terrain.
But when I make a translation for example : 

TerrainNode= osgDB::readNodeFile(geo.osg);
osg::ref_ptrosg::Group group = new osg::Group;
osg::ref_ptrosg::MatrixTransform mat = new osg::MatrixTransform;
group-addChild(mat);
mat-addChild(TerrainNode);

osg::Matrix trans;
trans.makeTranslate(osg::Vec3f(1000,5000,1500));
mat-preMult(trans);


the values of latitude, longitude and height are false  and it's normal.
I would prefer to use local point hitr-getLocalIntersectPoint(), which does 
not change when I make a translation, to calculate the latitude, longitude and 
height but I don't how to do this.
Can you help me?

Thank you!

Cheers,
lucie

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





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


Re: [osg-users] Calculate latitude, longitude, height with intersection point

2010-07-22 Thread lucie lemonnier
Hi,

Can you help me please?
I am blocked on my project.
I just want to know how to obtain the latitude, longitude and height from the 
local coordinates of the point of intersection.

Thank you!

Cheers,
lucie

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





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


Re: [osg-users] Calculate latitude, longitude, height with intersection point

2010-07-22 Thread Robert Osfield
Hi Lucie,

The CoordinateSystemNode can map between Earth Center Earth Fixed
coordinate frame and lats/longs.  If you have local coordinates then
you need to accumulate the model transforms to move the local coord
into world coords.

The LineSegmentInersector will accumulate the transforms for you and
provide you LineSegmentInersector::Intersection::getWorldIntersectPoint()
convinience method which does the transform on the intersection point
for you.

Robert.

On Thu, Jul 22, 2010 at 4:44 PM, lucie lemonnier
lucielemonn...@hotmail.fr wrote:
 Hi,

 Can you help me please?
 I am blocked on my project.
 I just want to know how to obtain the latitude, longitude and height from the 
 local coordinates of the point of intersection.

 Thank you!

 Cheers,
 lucie

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





 ___
 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] Calculate latitude, longitude, height with intersection point

2010-07-22 Thread lucie lemonnier
Hi,

I also have wrong values when I use the world coordinates of the intersection 
when I make a translation.
It's normal?

Thank you!

Cheers,
lucie

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





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