Glenn Waldron wrote: > Lv, > > convertLatLongHeightToXYZ gives you a point on the surface of the ellipsoid, > but the actual polygons in the terrain model are just a tessellated > approximation of that ellipsoid. So if you want the point on the triangulated > surface, you have to convert to XYZ and then "clamp" down to the surface > (using the local up-vector at that point). > > Glenn Waldron : Pelican Mapping : http://pelicanmapping.com > (http://pelicanmapping.com) : +1.703.652.4791 > > > On Sat, Dec 5, 2009 at 10:19 AM, Lv Qing < ()> wrote: > > > 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.0f),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 > > (http://forum.openscenegraph.org/viewtopic.php?p=20950#20950) > > > > > > > > > > Attachments: > > http://forum.openscenegraph.org//files/getattachment1_418.jpg > > (http://forum.openscenegraph.org//files/getattachment1_418.jpg) > > > > > > _______________________________________________ > > osg-users mailing list > > () > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) > > > > > ------------------ > Post generated by Mail2Forum
Thank you !How can I use the local up-vector at that point? Is that? Code: osg::Vec3d m_center; csn->getEllipsoidModel()->convertLatLongHeightToXYZ(osg::inDegrees(40.0f),osg::inDegrees(120.0f),0.0f,double(m_center.x()),double(m_center.y()),double(m_center.z())); osg::Vec3d center; center.set(csn->getEllipsoidModel()->computeLocalUpVector(m_center.x(),m_center.y(),m_center.z())); ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=20973#20973 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org