diff --git a/src/ui/ModelBrowser/ModelTreeWidget.cpp b/src/ui/ModelBrowser/ModelTreeWidget.cpp index f310dc64..b4393516 100644 --- a/src/ui/ModelBrowser/ModelTreeWidget.cpp +++ b/src/ui/ModelBrowser/ModelTreeWidget.cpp @@ -339,9 +339,20 @@ void ModelTreeWidget::OnTrackEntity(Entity* entity) { if (nullptr != entity) { osg::MatrixTransform* mt = entity->GetRootComponent()->GetMatrixTransform(); ccm->setNode(mt); + ccm->getSettings()->setTetherMode(osgEarth::Util::EarthManipulator::TETHER_CENTER); + osgEarth::Util::Viewpoint newVP; + newVP.setNode(mt); + double range = mt->getBound().radius() * 10.0; + newVP.range()->set(range, osgEarth::Units::METERS); + + const osg::Vec3 rotation = entity->GetRootComponent()->GetTransform()->GetRotation(); + newVP.heading()->set(rotation.x(), osgEarth::Units::DEGREES); + newVP.pitch()->set(rotation.y() - 15.0, osgEarth::Units::DEGREES); + //newVP.roll()->set(rotation.z(), osgEarth::Units::DEGREES); + ccm->setViewpoint(newVP, 1.5); //ccm->setTetherMode(osgGA::CameraManipulator::TETHER_CENTER_AND_ROTATION); } else { - ccm->setNode(nullptr); + ccm->clearViewpoint(); } } }