Tony,

Along with Robert's suggestion, you can use the following code snippet to
place a vehicle on a spheroid that has VPB terrain, into the scenegraph.
You'll need osgSim and osg::EllipsoidModel to do this.

Entity->lat = 36.4;
Entity->lon = -115.015;
Entity->alt = GetHeightOnTerrain(Entity->lat, Entity->lon);
entityGrp->addChild(Entity->transform);

double GetHeightOnTerrain(double lat, double lon)
{
        double X,Y,Z;
        double maxElevation = 13000 / 3.281;
        earth->convertLatLongHeightToXYZ(osg::DegreesToRadians(lat),
osg::DegreesToRadians(lon),maxElevation, X,Y,Z);
        double hat =
osgSim::HeightAboveTerrain::computeHeightAboveTerrain(terrain.get(),
osg::Vec3(X,Y,Z), -1);
        return (maxElevation - hat);
}

The "earth" is an osg::EllipsoidModel object and the "terrain" is a node
loaded in from the ive file build by VPB. The entity group node is simply
added to your scenegraph and you're ready to go.

Hopefully this will get you started...:)

-Shayne

-----Original Message-----
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Tony Vasile
Sent: Wednesday, February 03, 2010 5:13 PM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] Example of geographical position

Hi,
   I'm a newbie and trying to find as many examples as I can. What I am
looking for is an example of using a vehicle in latitude, longitude and
altitude and placing it in the scene graph. Unfortunately most of the
applications I have found programs such as Flightgear and Simgear and they
just have far too much code to understand the general ideas quickly.
Any help would be most appreciated.


Another problem I have is with VPB. I have some level 1 DTED data that I
wish to use in my scene graph for collision and occlusion events. Do I need
to have an image overlayed on the DTED data before I can see anything with
osgviewer?

Tony Vasile

CSC Australia

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