void bimWorld::CameraManipulator::setViewerMode(ViewerMode viewerMode) { BIMCameraManipulator *manipulator = dynamic_cast<BIMCameraManipulator*>(getCameraManipulator()); if (manipulator != NULL) { manipulator->setMode(viewerMode); m_cameraManipulatorMode = viewerMode; } clearSelection(); m_host->_RenderingThreads()->updateSeveralTimes(1); }
osgGA::CameraManipulator* ViewerWidget::getCurrentManipulator() { osgGA::CameraManipulator* manip = getCameraManipulator(); osgGA::KeySwitchMatrixManipulator* kmanip = dynamic_cast< osgGA::KeySwitchMatrixManipulator* >( manip ); if ( kmanip ) { return kmanip->getCurrentMatrixManipulator(); } return manip; }
void QOSGWidget::computeHomePosition() { //using ews::app::drawable::CameraController; MANIP_INHERIT* mat = getCameraManipulator(); /* CameraController* ctrl; if(ctrl = dynamic_cast<CameraController*> (mat)) { ctrl->computeHomePosition(); }*/ WorldWindManipulatorNew *ctrl; if((ctrl = dynamic_cast<WorldWindManipulatorNew*> (mat))) { //qDebug() << "Actual ww manip"; ctrl->setNode(this->getSceneData()); ctrl->computeHomePosition(); } }
void OSGViewerWidget::centerSceneImpl(void) { osgGA::CameraManipulator* camera_manipulator = getCameraManipulator(); osg::BoundingSphere bounding_sphere = getBound(); double radius = bounding_sphere.radius(); osg::Vec3d eye_offset(0.0, 0.0, -2*radius); camera_manipulator->setHomePosition(bounding_sphere.center() + eye_offset, bounding_sphere.center(), osg::Vec3d(0.0f,-1.0f,0.0f)); camera_manipulator->home(0); double offset = radius/1.5; std::vector<osg::Vec3> offsets; offsets.push_back(osg::Vec3(0, 0, -offset)); offsets.push_back(osg::Vec3(0, 0, offset)); offsets.push_back(osg::Vec3(-offset, 0, 0)); offsets.push_back(osg::Vec3(offset, 0, 0)); offsets.push_back(osg::Vec3(0, -offset, 0)); offsets.push_back(osg::Vec3(0, offset, 0)); for (int i = 0; i < 6; ++ i) light_sources_[i]->init(bounding_sphere.center() + offsets[i]); return; }
ossimPlanetManipulator* ossimPlanetViewer::planetManipulator() { return dynamic_cast<ossimPlanetManipulator*>(getCameraManipulator()); }
void QOSGWidget::setSceneData(osg::Node* node) { osgViewer::Viewer::setSceneData(node); getCameraManipulator()->setNode(node); computeHomePosition(); }
bimWorld::BIMCameraManipulator* bimWorld::CameraManipulator::getBIMCameraManip() { auto manip = static_cast<bimWorld::BIMCameraManipulator*>(getCameraManipulator()); return manip; }
void bimWorld::CameraManipulator::updateModelSize() { auto manip = dynamic_cast<bimWorld::BIMCameraManipulator*>(getCameraManipulator()); manip->updateModelSize(); }
void bimWorld::CameraManipulator::switchMatrixManipulator(ManipulatorType emanip) { auto viewer = m_host->_ViewerData()->ModelViewer(); auto sceneRoot = m_host->_ViewerData()->getSceneRoot(); auto modelRoot = m_host->_ViewerData()->getModelRoot(); if (!viewer || !sceneRoot || !modelRoot) { return; } m_host->_RenderingThreads()->setIsExternalRendering(true); auto manip = viewer->getCameraManipulator(); osg::Vec3d eye, center, up; auto matrix = manip->getMatrix(); manip->getHomePosition(eye, center, up); switch (emanip) { case ManipulatorType::Default: sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT0, osg::StateAttribute::ON); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT1, osg::StateAttribute::ON); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT2, osg::StateAttribute::OFF); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT3, osg::StateAttribute::OFF); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT4, osg::StateAttribute::OFF); ((BIMCameraManipulator*)m_d.get())->setPosition(eye, center, up, matrix); //// BIMCameraManipulator* mat = (BIMCameraManipulator*)(m_d.get()); // ((BIMCameraManipulator*)m_d.get())->beginSetCameraMatrix(); // ((BIMCameraM-anipulator*)m_d.get())->setByMatrix(matrix); // ((BIMCameraManipulator*)m_d.get())->endSetCameraMatrix(); viewer->setCameraManipulator(((BIMCameraManipulator*)m_d.get()), false); break; case ManipulatorType::Person: { auto oldManip = static_cast<BIMCameraManipulator*>(manip); if (!oldManip) break; auto rotation = oldManip->getRotation(); auto dist = oldManip->getDistance(); auto personManip = static_cast<PersonManipulator*>(m_p.get()); if (!personManip) break; personManip->setScreenRotation(rotation); personManip->setScreenDistance(dist); personManip->setPosition(eye, center, up, matrix); viewer->setCameraManipulator(personManip, false); break; } case ManipulatorType::FirstPerson: { sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT0, osg::StateAttribute::OFF); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT1, osg::StateAttribute::OFF); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT2, osg::StateAttribute::ON); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT3, osg::StateAttribute::ON); sceneRoot->getOrCreateStateSet()->setMode(GL_LIGHT4, osg::StateAttribute::ON); osgGA::CameraManipulator* first = new BIMFirstPersonManipulator(m_host); viewer->setCameraManipulator(first, true); first->setHomePosition(modelRoot->getBound().center(), osg::Vec3(0, 0, 0), up); viewer->home(); break; } } m_host->_RenderingThreads()->setIsExternalRendering(false); return; // osgGA::KeySwitchMatrixManipulator *switchmanipulator = dynamic_cast<osgGA::KeySwitchMatrixManipulator*>(m_mViewer->getCameraManipulator()); // // //m_ptrKeySwitchMatrixManipulator=new osgGA::KeySwitchMatrixManipulator; // //m_ptrKeySwitchMatrixManipulator->addMatrixManipulator(1,"deflaut",createCameraManipulator()); // //m_ptrKeySwitchMatrixManipulator->addMatrixManipulator(2,"person",createPersonManipulator()); // switchmanipulator->selectMatrixManipulator((int)emanip); // if (emanip == deflaut) // { // BIMCameraManipulator* manipulator = dynamic_cast<BIMCameraManipulator*>(switchmanipulator->getCurrentMatrixManipulator()); // // zoomTo(m_modelRoot); // //if (manipulator) // //{ // // manipulator->setupFrameRateController(m_modelRoot.get()); // // manipulator->setModelRoot(m_modelRoot); // //} // } // else if (emanip == person) // { // PersonManipulator* manipulator = dynamic_cast<PersonManipulator*>(switchmanipulator->getCurrentMatrixManipulator()); // zoomTo(m_modelRoot); // //if (manipulator) // //{ // // manipulator->setupFrameRateController(m_modelRoot.get()); // // manipulator->setModelRoot(m_modelRoot); // //} // } m_host->_RenderingThreads()->updateSeveralTimes(1); }