2003-01-22 00:45:36 +08:00
|
|
|
/* -*-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.
|
|
|
|
*/
|
2002-05-09 18:31:03 +08:00
|
|
|
|
|
|
|
#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{
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/**
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2002-05-09 18:31:03 +08:00
|
|
|
class OSGGA_EXPORT CameraManipulator : public GUIEventHandler
|
|
|
|
{
|
2002-08-28 22:27:18 +08:00
|
|
|
public:
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2003-03-26 20:50:30 +08:00
|
|
|
|
2003-03-30 06:07:03 +08:00
|
|
|
virtual const char* className() const { return "CameraManipulator"; }
|
2003-03-26 20:50:30 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** Attach a camera to the manipulator to be used for specifying view.*/
|
|
|
|
virtual void setCamera(osg::Camera*);
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** Get the attached camera.*/
|
|
|
|
virtual const osg::Camera * getCamera() const;
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** Get the attached camera.*/
|
|
|
|
virtual osg::Camera * getCamera();
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2002-05-09 18:31:03 +08:00
|
|
|
virtual void setNode(osg::Node*) {}
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** Return const node if attached.*/
|
2002-05-09 18:31:03 +08:00
|
|
|
virtual const osg::Node* getNode() const { return NULL; }
|
|
|
|
|
|
|
|
/** Return node if attached.*/
|
|
|
|
virtual osg::Node* getNode() { return NULL; }
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/**
|
|
|
|
Move the camera to the default position.
|
|
|
|
May be ignored by manipulators if home functionality is not appropriate.
|
|
|
|
*/
|
2002-05-09 18:31:03 +08:00
|
|
|
virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
2002-08-28 22:27:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
Start/restart the manipulator.
|
|
|
|
FIXME: what does this actually mean? Provide examples.
|
|
|
|
*/
|
2002-05-09 18:31:03 +08:00
|
|
|
virtual void init(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** Handle events, return true if handled, false otherwise. */
|
|
|
|
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
2002-05-09 18:31:03 +08:00
|
|
|
|
|
|
|
/** Handle visitations */
|
|
|
|
virtual void accept(GUIEventHandlerVisitor& v) { v.visit(*this); }
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
protected:
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
CameraManipulator();
|
|
|
|
virtual ~CameraManipulator();
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
// Reference pointer to a camera
|
|
|
|
osg::ref_ptr<osg::Camera> _camera;
|
2002-05-09 18:31:03 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|