I've tried the following which seems to work pretty well for moving models
on the paging terrain surface. Perhaps you can leverage this to do what you
need.

double MissionFunctions::GetHeightOnTerrain(double lat, double lon)
{
        double X,Y,Z;
        double maxElevation = 13000.0 / 3.281; // make sure we're above the
highest point in the database (meters)
        earth->convertLatLongHeightToXYZ(osg::DegreesToRadians(lat),
        
osg::DegreesToRadians(lon),
                                                   maxElevation, X, Y, Z);
        double hat =
osgSim::HeightAboveTerrain::computeHeightAboveTerrain(terrain.get(),
osg::Vec3d(X,Y,Z), -1);
        return (maxElevation - hat);
}

-Shayne

-----Original Message-----
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
brettwiesner
Sent: Thursday, May 28, 2009 2:03 PM
To: OpenSceneGraph Users
Subject: [osg-users] Ground clamping to paging terrain

Hi,

I want to position something (let's say a building) to a terrain. 
Currently I'm getting the Z value for the building doing this with an 
osgUtil::IntersectVisitor and that works fine for static terrains. When 
I run on a paging terrain (like one from osgEarth) and I position the 
building, I get a Z value of the lowest LOD. Then more data pages in and 
the building gets "buried" underground as more accurate data comes 
available.

What's the most effiecient "ground clamp" things to paging terrain?

Thanks,
Brett
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to