If you're using a geocentric database, you can use the osgSim::GetHeightAboveTerrain(...) method to get the altitude of either the terrain itself or an altitude above the terrain at a given lat,lon. This method takes into account paged databases in extracting the correct value...
-Shayne -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of issam boughanmi Sent: Wednesday, January 12, 2011 1:46 AM To: [email protected] Subject: [osg-users] Calculating altitude with LineSegmentIntersector i have some trouble to calculate the altitude in my application i have - a pagedlod terrain - a runway - and an airplane model i have taken some of the osgearth code in elevationmanager.cpp as a starting point this code is called every frame : Code: Transform tr; mAirplane->GetTransform(tr); tr.GetTranslation(x,y,z); osg::Vec3d start, end, zero; start.x() = x; start.y() = y; start.z() = 50000; end.x() = x; end.y() = y; end.z() = -50000; zero.x() = x; zero.y() = y; zero.z() = 0; osgUtil::LineSegmentIntersector* i = new osgUtil::LineSegmentIntersector( start, end ); osgUtil::IntersectionVisitor iv; iv.setIntersector( i ); mTerrain->GetOSGNode()->accept( iv ); osgUtil::LineSegmentIntersector::Intersections& results = i->getIntersections(); if ( !results.empty() ) { const osgUtil::LineSegmentIntersector::Intersection& result = *results.begin(); osg::Vec3d isectPoint = result.getWorldIntersectPoint(); double out_elevation = (isectPoint-end).length2() > (zero-end).length2() ? (isectPoint-zero).length() : -(isectPoint-zero).length(); std::cout << distance <<std::endl; ps : i am using delta3D the problem is that the result out_elevation is always a static number and it don't change when i move the airplane what the simplest formula to calculate the altitude with the LineSegmentIntersector ? thanks and good day ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35567#35567 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

