|
class SwitchViewEyeHandler:public osgGA::GUIEventHandler
{
public:
SwitchViewEyeHandler()
{
iNum=0;
ViewPoint=new osg::Vec3Array();
}
~SwitchViewEyeHandler(){}
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
// if (viewer==NULL)
// return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
osg::ref_ptr<osgViewer::Viewer>viewer=dynamic_cast<osgViewer::Viewer*>(&aa);
viewer->getCamera()->getViewMatrixAsLookAt(position,center,up);
if (ea.getKey()=='a')//a
{
//ViewPoint->push_back(position);
//ViewPoint->push_back(center);
//ViewPoint->push_back(up);
iNum+=1;
}
}
break;
default:
break;
}
return true;
}
public:
osg::Vec3 position,center,up;
osg::Vec3 position1,center1,up1;
osg::ref_ptr<osg::Vec3Array>ViewPoint;
int iNum;
};
在MFCosg.cpp中的void MFCosg::InitCameraConfig(void){}中添加事件处理器
mViewer->addEventHandler(new SwitchViewEyeHandler());
出现如下图的错误:
|
|