add track

This commit is contained in:
jiegeaiai 2025-01-06 01:05:41 +08:00
parent f821d99b45
commit a04b8ac769

View File

@ -339,9 +339,20 @@ void ModelTreeWidget::OnTrackEntity(Entity* entity) {
if (nullptr != entity) { if (nullptr != entity) {
osg::MatrixTransform* mt = entity->GetRootComponent()->GetMatrixTransform(); osg::MatrixTransform* mt = entity->GetRootComponent()->GetMatrixTransform();
ccm->setNode(mt); 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); //ccm->setTetherMode(osgGA::CameraManipulator::TETHER_CENTER_AND_ROTATION);
} else { } else {
ccm->setNode(nullptr); ccm->clearViewpoint();
} }
} }
} }