|
osgViewer::Viewer viewer; osg::ref_ptr root=new osg::Group; osg::ref_ptr aChild=osgDB::readNodeFile("cow.osg"); root->addChild(aChild.get()); osg::ref_ptr ksmm=new KeySwitchManipulatorExt; osg::ref_ptr tmm=new TerrainManipulatorExt; osg::ref_ptr dmm=new osgGA::TrackballManipulator; ksmm->addMatrixManipulator('1',"Terrain",tmm.get()); ksmm->addMatrixManipulator('2',"Drive",dmm.get()); viewer.setCameraManipulator(ksmm.get()); viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet())) ; viewer.addEventHandler(new osgViewer::WindowSizeHandler); viewer.addEventHandler(new osgViewer::StatsHandler); viewer.setSceneData(root.get()); viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3d(5,0,-6),osg::Vec3d(0,0,0),osg::Vec3d(0,1,0)); viewer.realize(); //while(!viewer.done()) //{ // viewer.frame(); //} while(!viewer.done()) { viewer.frame(); }
这段代码中viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3d(5,0,-6),osg::Vec3d(0,0,0),osg::Vec3d(0,1,0)); 设置了Camera的视点,为什么改变不了视点的位置 |
|