osg键盘控制模型

使用 osgGA::GUIEventHandler ,从此继承出一个类,在里面添加响应键盘按键的代码;

#include 
#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 

class myGlider : public osgGA::GUIEventHandler
{
public:
	bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
	{
		osgViewer::Viewer* vw = dynamic_cast(&aa);
		if (vw)
		{
			osg::MatrixTransform* mt = dynamic_cast(vw->getSceneData());
			if (mt)
			{
				static float i = 0.1f;
				static float distup = 1.0f;
				static float distdown = -1.0f;
				static float disth = 1.0f;
				static float fdd = 1.05f; //放大度
				static float sxd = 0.95f; //缩小度

				switch (ea.getEventType())

你可能感兴趣的:(图形学和3D,VC++,OSG,GUIEventHandler)