|
我想在调用viewer.setCameraManipulator(new osgGA:riveManipulator);设置漫游器后调用viewer.getCamera()->setViewMatrix(temp1);改变照相机一开始出来的位置,但始终改不了,视点一直停在原来的地方不动。
还有,下面这段代码中,为什么我把换成- while (!viewer.done())
- viewer.frame();
复制代码 后场景就显示不出来了呢?- int _tmain(int argc, _TCHAR* argv[])
- {
- osg::ref_ptr<osg::Group> rootnode = new osg::Group;
- // load the sky dome
- osg::ref_ptr<osg::Node> sky = osgDB::readNodeFile("skydome.osg");
- // load the terrain
- osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("lz.osg");
- if (sky.get())
- rootnode->addChild(sky.get());
- osgViewer::Viewer viewer;
- viewer.getCamera()->setProjectionMatrixAsPerspective(80., 1., 1., 100. );
- // add a viewport to the viewer and attach the scene graph.
- viewer.setSceneData(rootnode.get());
- if (!viewer.getSceneData())
- return 1;
- const osg::BoundingSphere& boundingSphere=loadedModel->getBound();
- osg::MatrixList MLi=loadedModel->getWorldMatrices();
- osg::Matrix temp1;
- osg::Matrix temp2;
-
- temp1.makeTranslate(boundingSphere._center * MLi[0]);
- while (!viewer.done())
- {
- viewer.frame();
- }
- return 0;
- }
复制代码 |
|