|
根据鼠标点击求出当前的位置的空间坐标,同时能计算出经纬度坐标,但是把再经纬度转换为空间坐标就不对了 不知道是上面原因转换错误 求指正!!!下面是主要的代码及效果图:
//如果没有发生交集运算,及鼠标没有点中物体
if (viewer->computeIntersections(x,y,intersections))//
{
//得到相交交集的交点
osgUtil:ineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
{
//输入流
os<<"Mouse in World X:"<< hitr->getWorldIntersectPoint().x()<<" Y: "<< hitr->getWorldIntersectPoint().y()<<" Z: "<< hitr->getWorldIntersectPoint().z()<<std::endl;
//设置经纬度
zz.convertXYZToLatLongHeight(hitr->getWorldIntersectPoint().x(), hitr->getWorldIntersectPoint().y(), hitr->getWorldIntersectPoint().z(),latitude,longitude,height);
os<<"latitude:"<< latitude*180/osg:I<<" longitude:"<<longitude*180/osg::PI<<" height:"<< height<<std::endl;
zz.convertLatLongHeightToXYZ(latitude*180/osg::PI,longitude*180/osg::PI,height,Posx,Posy,Posz);
}
}
double distance;
distance = sqrt(eye[0]*eye[0]+eye[1]*eye[1]+eye[2]*eye[2]);
图片中X、Y是鼠标的位置,g_vcenter是我要转到到的地方
[ 本帖最后由 zhufu0208 于 2009-6-10 10:55 编辑 ] |
|