[osg-users] Unable to place model on vpb terrain. How To ?

Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC Shayne.Tueller at hill.af.mil
Fri Apr 8 16:11:45 PDT 2011


Sanat,

You have to use the osgSim class to achieve your objective. In
particular, use the method

osgSim::HeightAboveTerrain::computeHeightAboveTerrain(terrain_node,
osg::Vec3d(X,Y,Z))

where X,Y,Z is the geocentric coordinates (earth centered) calculated
from a given lat,lon,alt. 

The method to calculate X,Y,Z from a given lat,lon,alt is in the
EllipsoidModel class. You can extract the height on terrain from the
above HAT calculation to place your models on the terrain surface.

The reason why you want to use the osgSim class is that it accounts for
VPB pagedLOD databases when determining HAT/HOT and LOS calculations.

-Shayne

-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Sanat
Talmaki
Sent: Friday, April 08, 2011 12:10 PM
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] Unable to place model on vpb terrain. How To ?

Hi,

I am trying to place a model on a vpb terrain by supplying the lat-long
coordinates. 

I followed a couple of threads in the forum that suggested to use the
CoordinateSystemNode and ellipsoid model. But that didn't work for me
(or maybe I am not following it right). 

I have attached the terrain along with my post.

So far this is what I am doing:


Code:
osg::ref_ptr<osg::Group> root = new osg::Group();
  
  osg::ref_ptr<osg::CoordinateSystemNode> csn = new
osg::CoordinateSystemNode();
  csn->setEllipsoidModel(new osg::EllipsoidModel());  
  osg::ref_ptr<osg::Group> terrainGroup = new osg::Group();
  //osg::ref_ptr<osg::Node> terrain =
osgDB::readNodeFile("NorthCampus6Levels.osg"); 
  osg::ref_ptr<osg::Node> terrain =
osgDB::readNodeFile("NorthCampus6LevelsNoCS.osg");
  terrainGroup->addChild(terrain);

  osg::Vec3d m_surface;
 
csn->getEllipsoidModel()->convertLatLongHeightToXYZ(osg::DegreesToRadian
s(42.291966f), osg::DegreesToRadians(-83.715645f), 0.0f,
 
double(m_surface.x()),double(m_surface.y()),double(m_surface.z())
                                                     ); 



I tried using a visitor to find the CoordSystNode in my scenegraph but
when I checked getEllipsoidModel I got a null.

I have used osgEarth in the past and was able to place a model on that.
But I presently need to use vpb. If anyone can point me in the right
direction, it would be great. 

Thank You.

Sincerely,
Sanat

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




Attachments: 
http://forum.openscenegraph.org//files/northcampus6levels_171.osg


_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



More information about the osg-users mailing list