|
在多视图相机渲染实例中 我把书中的 牛,和飞机的模型该成了我需要的 ive格式的模型 为什么会有断点出现?
osg::ref_ptr<osgViewer::CompositeViewer>viewer=new osgViewer::CompositeViewer();
//读取模型
osg::ref_ptr<osg::Node>Scense=osgDB::readNodeFile("changjing.IVE");
osg::ref_ptr<osg::Node>time=osgDB::readNodeFile("time.IVE");
/*osg::ref_ptr<osg::Node>hand=osgDB::readNodeFile("glider.osg");
hand->setNodeMask(1);
time->setNodeMask(1);
osg::ref_ptr<osg::Group>root=new osg::Group();
root->addChild(hand.get());
root->addChild(time.get());*/
//优化场景数据
osgUtil::Optimizer optimizer;
optimizer.optimize(Scense.get());
optimizer.optimize(time.get());
//设置图像环境特性
osg::ref_ptr<osg::GraphicsContext::Traits>traits=new osg::GraphicsContext::Traits();
traits->x=100;
traits->y=100;
traits->width=900;
traits->height=700;
traits->windowDecoration=true;
traits->doubleBuffer=true;
traits->sharedContext=0;
//创建图像环境特性
osg::ref_ptr<osg::GraphicsContext>gc=osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc->valid())
{
osg::notify(osg::INFO)<<"GraphicsWindow has been created successfully."<<std::endl;
//清除窗口颜色及颜色和深度缓冲
gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f));
gc->setClearMask(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
}
else
{
osg::notify(osg::NOTICE)<<"GraphicsWindow has not been created successfully."<<std::endl;
}
// 视图一
{
osg::ref_ptr<osgViewer::View>view=new osgViewer::View;
viewer->addView(view.get());
//设置视图场景数据
view->setSceneData(Scense.get());
//设置相机视口及图像环境
view->getCamera()->setViewport(new osg::Viewport(0,0,traits->width,traits->height));
view->getCamera()->setGraphicsContext(gc.get());
view->setCameraManipulator(new osgGA::TrackballManipulator);
//添加时间处理程序
}
//视图二
{
osg::ref_ptr<osgViewer::View>view=new osgViewer::View;
viewer->addView(view.get());
view->setSceneData(time.get());
view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0,traits->width/2,traits
->height/2));
view->getCamera()->setGraphicsContext(gc.get());
view->setCameraManipulator(new osgGA::TrackballManipulator);
}
viewer->realize();
viewer->run();
return 0;
}
断点出现在 最后一行代码中 [img]file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/SQZCX%7D@84DZ8SO)%603~@[Z[9.jpg[/img] |
|