在以前的版本中,可以很简单的使用setTetherNode进行视点跟踪设置。 以前的方法:
osg::ref_ptr<osg::Group> mRoot = new osg::Group();
osgViewer::Viewer * pViewer = new osgViewer::Viewer();
osg::MatrixTransform* mtFly = new osg::MatrixTransform;
mRoot->addChild(mtFly);
osg::ref_ptr<osgEarth::Util::EarthManipulator> em = new osgEarth::Util::EarthManipulator;
pViewer->setCameraManipulator(em.get());
pViewer->setSceneData(mRoot.get());
pViewer->realize();
mtFly->setUpdateCallback(new osg::AnimationPathCallback(apc,0.0,1.0));
em->setTetherNode(mtFly);
现在的方法:
osg::ref_ptr<osg::Group> mRoot = new osg::Group();
osgViewer::Viewer * pViewer = new osgViewer::Viewer();
osg::MatrixTransform* mtFly = new osg::MatrixTransform;
mRoot->addChild(mtFly);
osg::ref_ptr<osgEarth::Util::EarthManipulator> em = new osgEarth::Util::EarthManipulator;
pViewer->setCameraManipulator(em.get());
pViewer->setSceneData(mRoot.get());
pViewer->realize();
mtFly->setUpdateCallback(new osg::AnimationPathCallback(apc,0.0,1.0));
osgEarth::Viewpoint vp = m_em->getViewpoint();
vp.setNode(mtFly);
vp.range()->set(250000.0, osgEarth::Units::METERS);
vp.pitch()->set(-45.0, osgEarth::Units::DEGREES);
em->setViewpoint(vp, 1.0);
另外,视点必须在viewer执行senScenceData之后才会有效。
|