2001-01-11 00:32:10 +08:00
|
|
|
#ifndef OSGUTIL_CAMERAMANIPULATOR
|
|
|
|
#define OSGUTIL_CAMERAMANIPULATOR 1
|
|
|
|
|
|
|
|
#include <osg/Camera>
|
2001-09-20 05:08:56 +08:00
|
|
|
#include <osg/Node>
|
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
#include <osgUtil/Export>
|
2001-09-20 05:08:56 +08:00
|
|
|
#include <osgUtil/GUIEventHandler>
|
2001-01-11 00:32:10 +08:00
|
|
|
#include <osgUtil/GUIEventAdapter>
|
|
|
|
#include <osgUtil/GUIActionAdapter>
|
|
|
|
|
|
|
|
namespace osgUtil{
|
|
|
|
|
2001-09-20 05:08:56 +08:00
|
|
|
class OSGUTIL_EXPORT CameraManipulator : public GUIEventHandler
|
2001-01-11 00:32:10 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
CameraManipulator();
|
|
|
|
virtual ~CameraManipulator();
|
|
|
|
|
|
|
|
/** attach a camera to the manipulator to be used for specifying view.*/
|
|
|
|
virtual void setCamera(osg::Camera*);
|
|
|
|
|
|
|
|
/** get the attached a camera.*/
|
2001-09-20 05:08:56 +08:00
|
|
|
virtual const osg::Camera * getCamera() const;
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
/** Attach a node to the manipulator.
|
|
|
|
Automatically detaches previously attached node.
|
|
|
|
setNode(NULL) detaches previously nodes.
|
|
|
|
Is ignored by manipulators which do not require a reference model.*/
|
|
|
|
virtual void setNode(osg::Node*) {}
|
|
|
|
|
|
|
|
/** Return node if attached.*/
|
2001-09-20 05:08:56 +08:00
|
|
|
virtual const osg::Node* getNode() const { return NULL; }
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
/** Move the camera to the default position.
|
|
|
|
May be ignored by manipulators if home functionality is not appropriate.*/
|
2001-09-20 05:08:56 +08:00
|
|
|
virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
/** Start/restart the manipulator.*/
|
2001-09-20 05:08:56 +08:00
|
|
|
virtual void init(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
/** Handle events, return true if handled, false otherwise.*/
|
2001-09-20 05:08:56 +08:00
|
|
|
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
2001-01-11 00:32:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
// Reference pointer to a camera
|
|
|
|
osg::ref_ptr<osg::Camera> _camera;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|