Hi, Original coordinate of tif file is the longitude and latitude coordinates,Use gdalwarp converts to merctor projection: gdalwarp -t_srs “+proj=merc +datum=WGS84” 0-40.tif merctor.tif, merctor.tif, Then use osgdem to make merctor. tif generate planar model: osgdem --cs “+proj=merc +datum=WGS84” –xx 10 –yy 10 –v 0.5 –l 3 –o merctor.ive And then load the merctor.ive in osg appalication,and use osgpick to pick up the model as following: osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer; osg::ref_ptr<osg::Group>group=new osg::Group; osg::ref_ptr<osg::Node> node= osgDB::readNodeFile("merctor.ive"); osg::ref_ptr<osg::CoordinateSystemNode> csn=new osg::CoordinateSystemNode; csn->setEllipsoidModel(new osg::EllipsoidModel); csn->addChild(node); csn->setFormat("PROJ4"); csn->setCoordinateSystem("+proj=merc +datum=WGS84"); osg::ref_ptr<osgText::Text> updatetext = new osgText::Text(); CreateHUD *hudText= new CreateHUD(); csn->addChild(hudText->createHUD(updatetext.get())); viewer->setSceneData(csn); viewer->addEventHandler(new osgViewer::WindowSizeHandler); viewer->addEventHandler(new osgViewer::StatsHandler); viewer->addEventHandler(new CPickHandler(updatetext.get())); //pick as follows: if (viewer->computeIntersections(x,y,intersections)) { osg::ref_ptr<osg::CoordinateSystemNode> csn=dynamic_cast<osg::CoordinateSystemNode*>(viewer->getSceneData()->asGroup()); osg::EllipsoidModel* em=csn->getEllipsoidModel(); for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();hitr != intersections.end();++hitr) { os<<"Mouse in World X:"<< hitr->getWorldIntersectPoint().x()<<"Y: "<< hitr->getWorldIntersectPoint().y()<<"Z: "<< hitr->getWorldIntersectPoint().z()<<std::endl ;
double x,y,z; // Can also use EllipsoidModel obtain latitude and longitude coordinates to plane model? em->convertXYZToLatLongHeight(hitr->getWorldIntersectPoint().x(),hitr->getWorldIntersectPoint().y(),hitr->getWorldIntersectPoint().z(),y,x,z); os<<osg::RadiansToDegrees(x)<<" "<<osg::RadiansToDegrees(y)<<" "<<z<<std::endl; // The following can I get real projection coordinates as in the model tif? osg::Vec3 mercVec=csn->computeLocalUpVector(hitr->getWorldIntersectPoint()); os<<mercVec.x()<<mercVec.y()<<mercVec.z()<<std::endl; } } Is the Coordinatorsystem ,setform, setcoordiantorsystem correct above the code, with EillpsoidModel can obtain the actual latitude and longitude? If can not how to obtain real coordinates of a model as tif describe? Thank you! Cheers, SongMeng[/url] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53478#53478 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org