OpenSceneGraph/include/osgGA/KeySwitchCameraManipulator
Robert Osfield 8c0d510571 Several items of work related to adding a manual creation of occluders
option to the osgoccluder demo.

First the osgGA classes have been generalised a little to better support
new GUIEventHandler subclasses.

Second osgGLUT has a new option for registering a user defined event handler,
the allows the application to add externally extra options to the osgGLUT viewer.

Third, the osgoccluder demo now works in two modes. The original create
four occluder sides to wrap an loaded model, the second an interactive
mode which allows the users to add occluders to the model by pointing
to points and pressing 'a' to add a point, the 'e' to end the occluder
polygon, polygons must be convex, planer and be defined in an anitclockwise
order.  To start the osgoccluder in this mode one simple runs it with the
'-c' option.  Run osgoccluder with no parameter to get a list of options.
2002-07-17 10:00:50 +00:00

63 lines
1.8 KiB
Plaintext

//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSGUTIL_KEYSWITCCAMERAMANIPULATORHER
#define OSGUTIL_KEYSWITCHCAMERAMANIPULATORER 1
#include <osgGA/Export>
#include <osgGA/CameraManipulator>
#include <osgGA/GUIEventHandler>
#include <osgGA/GUIEventHandlerVisitor>
//#include <osgUtil/CallbackList>
namespace osgGA{
class GUIEventAdapter;
class GUIActionAdapter;
class OSGGA_EXPORT KeySwitchCameraManipulator : public CameraManipulator
{
public:
// Local methods
void addCameraManipulator(int key, std::string name, CameraManipulator *cm);
void addNumberedCameraManipulator(CameraManipulator *cm);
// Overrides from CameraManipulator...
virtual void setCamera(osg::Camera* c) { _current->setCamera(c); }
virtual const osg::Camera * getCamera() const { return _current->getCamera(); }
virtual osg::Camera * getCamera() { return _current->getCamera(); }
virtual void setNode(osg::Node* n) { _current->setNode(n); }
virtual const osg::Node* getNode() const { return _current->getNode(); }
virtual osg::Node* getNode() { return _current->getNode(); }
virtual void home(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->home(ee,aa); }
virtual void init(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->init(ee,aa); }
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
private:
typedef std::pair<std::string, osg::ref_ptr<CameraManipulator> > NamedManipulator;
typedef std::map<int, NamedManipulator> KeyManipMap;
KeyManipMap _manips;
osg::ref_ptr<CameraManipulator> _current;
};
};
#endif