osg提供了很多操控器,在src\osgGA目录下,cpp文件名含有Manipulator的都是操控器,每个这样的cpp表示一种类型的操控器。
名字带 Manipulator 的类都是操控器;
其中KeySwitchMatrixManipulator.cpp文件实现了键盘切换操控器;
操控器是指:操控相机运动,从而实现场景视图矩阵变化,反映到观察场景用户的感官上就是:人眼感觉场景变化了,但现实中的物体是没变化的,只是相机方位或距离远近在改变,从而给人视觉上的感觉;
键盘切换操控器是指可以通过按下键盘不同键,实现在多个操控器之间切换;
#include <Windows.h>
#include <osgViewer/Viewer>#include <osg/Node>
#include <osg/Geode>
#include <osg/Group>
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/TerrainManipulator>int main()
{osgViewer::Viewer* viewer = new osgViewer::Viewer();osg::Group* root = new osg::Grou