|
楼主 |
发表于 2009-5-18 21:32:39
|
显示全部楼层
我又试了一遍,发现问题并不是全是我上面描述的样子,当程序运行后,不进行任何操作(默认显示最精的模型),发现帧频率就在不停的减少到十几后稳定。
将部分代码简写如下:
osg::ref_ptr<osg::Switch> RootScenedata = new osg::Switch;
osg:agedLOD* part = new osg::PagedLOD;
std::string temppartpath = partpath + firstName;
std::string strSign = "\\";
temppartpath += strSign;
for (int h =0; h < 10; h++)
{
char temp[64];
sprintf(temp,"%d",10 + h*10);
std::string LodName = temppartpath + firstName + underline + temp + underline +
lastName + partFormatOsg;
osg::Node* Lod = osgDB::readNodeFile(LodName);
part->addChild(Lod,float(9 - h), float(10 - h));
part->setFileName(h,LodName);
}
part->setName(tempPartName);
RootScenedata->addChild((osg::Node*)part);
osgViewer::Viewer myviewer;
osg::ref_ptr<osgGA::TrackballManipulator> trackball;
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator;
trackball = new osgGA::TrackballManipulator();
keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator();
keyswitchManipulator->addMatrixManipulator(1,"trackball",trackball.get());
keyswitchManipulator->selectMatrixManipulator(0);
myviewer.setCameraManipulator(keyswitchManipulator.get());
osg::CullFace* groupCullFace = new osg::CullFace;
groupCullFace->setMode(osg::CullFace::BACK);
osg::Group* ScenceData = new osg::Group;
ScenceData->getOrCreateStateSet()->setAttributeAndModes (groupCullFace,osg::StateAttribute::ON);
myviewer.setSceneData((osg::Node*)RootScenedata.get());
myviewer.addEventHandler(new osgViewer::StatsHandler);
myviewer.getCamera()->setCullingMode(osg::CullSettings::VIEW_FRUSTUM_SIDES_CULLING);
while (!myviewer.done())
{
myviewer.frame();
}
[ 本帖最后由 ghczhaolei 于 2009-5-18 21:42 编辑 ] |
|