我正在用OSGEarth做一个无人机模拟器。我从来没有使用过OSG,所以我有一些麻烦,以了解相机。我试图移动一个相机到一个特定的位置(lat/lon)与一个特定的滚动,俯仰和偏航在OSG地球。
我需要多个摄像头,所以我使用了一个复合查看器。但我不知道怎么移动特定的摄像机。目前,我有一个与EarthManipulator工作良好。
class NovaManipulator : publicosgGA::CameraManipulator { osg::Matrixd NovaManipulator::getMatrix() const //drone_ is only a struct which contains updated infomations float roll = drone_->roll(), pitch = drone_->pitch(), yaw = drone_->yaw(); auto position = drone_->position(); osg::Vec3d world_position; position.toWorld(world_position); cam_view_->setPosition(world_position); const osg::Vec3d rollAxis(0.0, 1.0, 0.0); const osg::Vec3d pitchAxis(1.0, 0.0, 0.0); const osg::Vec3d yawAxis(0.0, 0.0, 1.0); //if found this code : // https://stackoverflow.com/questions/32595198/controling-openscenegraph-camera-with-cartesian-coordinates-and-euler-angles osg::Quat rotationQuat; rotationQuat.makeRotate( osg::DegreesToRadians(pitch + 90), pitchAxis, osg::DegreesToRadians(roll), rollAxis, osg::DegreesToRadians(yaw), yawAxis); cam_view_->setAttitude(rotationQuat); // I don't really understand this also auto nodePathList = cam_view_->getParentalNodePaths(); return osg::computeLocalToWorld(nodePathList[0]);