Here's a way to place models on the VPB terrain that works pretty good. The drawback is that you must specify the highest point in the database region. Using osgSim will ensure that the models will sit on the terrain at that LOD...:)
double X,Y,Z; double maxElevation = 13000.0 / 3.281; // feet to meters... earth->convertLatLongHeightToXYZ(lat, lon, maxElevation, X, Y, Z); double hat = osgSim::HeightAboveTerrain::computeHeightAboveTerrain(terrain.get(), osg::Vec3d(X,Y,Z), -1); hot = maxElevation - hat; -Shayne -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Lv Qing Sent: Saturday, December 05, 2009 8:19 AM To: [email protected] Subject: [osg-users] [vpb] convertLatLongHeightToXYZ problem with ageocentric coordinate earth Hi, I have build a geocentric coordinate earth model using VPB and want to put a simple model on the suface of the earth. I use the convertLatLongHeightToXYZ function to convert the BLH(Lat,Long,Height) of the simple model to XYZ of the geocentric coordinate system.The result of X and Y seems OK,but the Z coordinate is always a bit higher above the earth suface(about 5000 m). Code: // load the earth model osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode; csn->setEllipsoidModel(new osg::EllipsoidModel()); osg::Node* TerrainNode= osgDB::readNodeFile("earth.osga"); csn->addChild(TerrainNode); //convert the BLH(50,130,0) to XYZ,I set height 0. osg::Vec3d m_surface; csn->getEllipsoidModel()->convertLatLongHeightToXYZ(osg:egreesToRadians(50.0 f),osg:egreesToRadians(130.0f),0.0f,double(m_surface.x()),double(m_surface.y ()),double(m_surface.z())); //draw a simple yellow line from center of the earth (osg::Vec3(0,0,0)) to the surface (osg::Vec3d m_surface); osg::Geode *geode_line = new osg::Geode; osg::Geometry *geom = new osg::Geometry(); geode_line->addDrawable(geom); csn->addChild(geode_line); osg::Vec3Array *v = new osg::Vec3Array(); v->push_back(osg::Vec3(0,0,0)); v->push_back(m_center); geom->setVertexArray(v); osg::Vec4Array *vc = new osg::Vec4Array(); vc->push_back(osg::Vec4(1.0f,0.5f,0.0f,1.0f)); geom->setColorArray(vc); geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE); geom->addPrimitiveSet(new osg:rawArrays(osg:rimitiveSet:INES,0,2)); As the result ,the end of the yellow line is obviously higher than the surface.Please tell me where I am wrong,THX! Thank you! Cheers, Lv ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=20950#20950 Attachments: http://forum.openscenegraph.org//files/getattachment1_418.jpg _______________________________________________ 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

