|
#include<osg/ref_ptr>
#include <osgDB/Registry>
#include<osgDB/ReadFile>
#include<osg/Notify>
#include<iostream>
#include <osgViewer\Viewer>
#include<osgViewer\ViewerEventHandlers>
#include <osgUtil\Optimizer>
#include<osgGA/StateSetManipulator>
#include<osgGA/TrackballManipulator>
#include<osgGA/FlightManipulator>
#include<osgGA/DriveManipulator>
#include<osgGA/KeySwitchMatrixManipulator>
#include<osgGA/AnimationPathManipulator>
#include<osgGA/TerrainManipulator>
int main(int,char**)
{
//创建Viewer对象,场景浏览器
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
viewer->setSceneData(osgDB::readNodeFile("glider.osg"));
//添加状态时间
viewer->addEventHandler(new osgGA::StateSetManipulator(viewer->getCamera()->getOrCreateStateSet()));
//窗口大小变化事件
viewer->addEventHandler(new osgViewer::WindowSizeHandler);
//添加一些常用状态设置
viewer->addEventHandler(new osgViewer::StatsHandler);
//添加一些操作器
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator>keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator('1',"Trackball",new osgGA::TrackballManipulator());
keyswitchManipulator->addMatrixManipulator('2',"Flight",new osgGA::FlightManipulator());
keyswitchManipulator->addMatrixManipulator('3',"Drive",new osgGA:riveManipulator());
keyswitchManipulator->addMatrixManipulator('4',"Terrain",new osgGA::TerrainManipulator());
viewer->setCameraManipulator(keyswitchManipulator.get());
}
viewer->addEventHandler(new osgViewer::RecordCameraPathHandler);
viewer->realize();
viewer->run();
return 0;
}
在vs2010中运行产生死机:
0x00F17E93(osg131-osgGAd.dll)处理有未经处理的异常。
读取位置 时发生访问冲突。
|
|