91 lines
2.8 KiB
C++
91 lines
2.8 KiB
C++
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
*
|
|
* This library is open source and may be redistributed and/or modified under
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* OpenSceneGraph Public License for more details.
|
|
*/
|
|
|
|
#ifndef OSGGA_CAMERAMANIPULATOR
|
|
#define OSGGA_CAMERAMANIPULATOR 1
|
|
|
|
#include <osg/Camera>
|
|
#include <osg/Node>
|
|
|
|
#include <osgGA/Export>
|
|
#include <osgGA/GUIEventHandler>
|
|
#include <osgGA/GUIEventAdapter>
|
|
#include <osgGA/GUIActionAdapter>
|
|
|
|
namespace osgGA{
|
|
|
|
/**
|
|
|
|
CameraManipulator is an abstract base class defining the interface, and a certain
|
|
amount of default functionality, for classes which wish to control OSG cameras
|
|
in response to GUI events.
|
|
|
|
*/
|
|
class OSGGA_EXPORT CameraManipulator : public GUIEventHandler
|
|
{
|
|
public:
|
|
|
|
/** Attach a camera to the manipulator to be used for specifying view.*/
|
|
virtual void setCamera(osg::Camera*);
|
|
|
|
/** Get the attached camera.*/
|
|
virtual const osg::Camera * getCamera() const;
|
|
|
|
/** Get the attached camera.*/
|
|
virtual osg::Camera * getCamera();
|
|
|
|
/**
|
|
Attach a node to the manipulator, automatically detaching any previously attached node.
|
|
setNode(NULL) detaches previous nodes.
|
|
May be ignored by manipulators which do not require a reference model.
|
|
*/
|
|
virtual void setNode(osg::Node*) {}
|
|
|
|
/** Return const node if attached.*/
|
|
virtual const osg::Node* getNode() const { return NULL; }
|
|
|
|
/** Return node if attached.*/
|
|
virtual osg::Node* getNode() { return NULL; }
|
|
|
|
/**
|
|
Move the camera to the default position.
|
|
May be ignored by manipulators if home functionality is not appropriate.
|
|
*/
|
|
virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
|
|
|
/**
|
|
Start/restart the manipulator.
|
|
FIXME: what does this actually mean? Provide examples.
|
|
*/
|
|
virtual void init(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
|
|
|
/** Handle events, return true if handled, false otherwise. */
|
|
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
|
|
|
/** Handle visitations */
|
|
virtual void accept(GUIEventHandlerVisitor& v) { v.visit(*this); }
|
|
|
|
protected:
|
|
|
|
CameraManipulator();
|
|
virtual ~CameraManipulator();
|
|
|
|
// Reference pointer to a camera
|
|
osg::ref_ptr<osg::Camera> _camera;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|