Hi All
I am trying to set up a map view using a TerrainManipulator. But when my
aplication is running I nead to press "space" in order to get somhing in the
view that makes sense. Whene I remove the TerrainManipulator the view shows me
what it is supose to. I gues that Im using the TerreinManipulator wrong in som
sens but I can not figure out what.
I have the folowing code running when the view is initialized:
osg::ref_ptr<osgViewer::View> pViewC2 = new osgViewer::View;
osg::Camera* pCamera = new osg::Camera;
pViewC2->setCamera(pCameraC2);
pViewC2->getCamera()->setComputeNearFarMode(osgUtil::CullVisitor::ComputeNearFarMode::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
pViewC2->getCamera()->setGraphicsContext(m_pCanvasC2);
pViewC2->getCamera()->setViewport(0, 0, nWidth, nHeight);
pViewC2->addEventHandler(new osgViewer::StatsHandler);
m_pRootC2 = new osg::Group;
m_pRootC2->setDataVariance(osg::Object::DYNAMIC);
m_pRootC2->addChild(getScene()->getMapRoot().get());
pViewC2->setSceneData(m_pRootC2);
osgGA::TerrainManipulator* pCameraManipulator = newosgGA::TerrainManipulator();
pViewC2->addEventHandler(pCameraManipulator);
pViewC2->setCameraManipulator(pCameraManipulator);
osg::Viewport* pViewportC2 = pViewC2->getCamera()->getViewport();
double dAspectRatio = pViewportC2->aspectRatio();
pViewC2->getCamera()->setProjectionMatrixAsPerspective(45.0,dAspectRatio,
100.0, 100000.0);
osg::Vec3d eyePos, centerPos, upVec;
//Get hold of the vectors from our system
pTerrain->getInitialMapCamViewAsLookat(eyePos, centerPos, upVec);
osg::Matrixd mapCamViewMatrix;
mapCamViewMatrix.makeLookAt(
eyePos, centerPos, upVec);
pViewC2->getCamera()->setViewMatrix(mapCamViewMatrix);
pCameraManipulator->setByMatrix(mapCamViewMatrix);
pCameraManipulator->setNode(m_pRootC2);
pCameraManipulator->setHomePosition(
eyePos, centerPos, upVec);
Regards.
Ragnar Hammarqvist @ FOI
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org