|
while(!viewer->done(){
viewer->frame();}实现仿真循环 为什么场景会崩溃啊
原代码:
void main(int argc, char* argv[])
{
while (!viewer.done())
{
osg::ref_ptr<osg::Group> root = new osg::Group;
osg::ref_ptr<osg::Node> axes = osgDB::readNodeFile("axes.osgt");
osg::ref_ptr<osg::MatrixTransform> mtMove = new osg::MatrixTransform;
mtMove->setMatrix(osg::Matrix::translate(2, 0, 1));
mtMove->addChild(axes.get());
root->addChild(mtMove.get());
viewer.setSceneData(root.get());
//viewer.setCameraManipulator(NULL);
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
osg::Camera* camera = viewer.getCamera();
osg::Vec3 eye(0, -10, 0);
osg::Vec3 center(0, 0, 0);
osg::Vec3 up(0, 0, 1);
camera->setViewMatrixAsLookAt(eye, center, up);
viewer.setUpViewInWindow(0, 0, 800, 600);
viewer.realize();
viewer.frame();
}
}
|
|