c49c62ee15
include change the CameraManipulators so they work with double for time instead of float. Also added support for DataType to osg::StateAttribute and StateSet so that they can be set to either STATIC or DYNAMIC, this allows the optimizer to know whether that an attribute can be optimized or not.
77 lines
2.1 KiB
Plaintext
77 lines
2.1 KiB
Plaintext
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
//as published by the Free Software Foundation.
|
|
|
|
#ifndef OSGUTIL_CAMERAMANIPULATOR
|
|
#define OSGUTIL_CAMERAMANIPULATOR 1
|
|
|
|
#include <osg/Camera>
|
|
#include <osg/Node>
|
|
|
|
#include <osgUtil/Export>
|
|
#include <osgUtil/GUIEventHandler>
|
|
#include <osgUtil/GUIEventAdapter>
|
|
#include <osgUtil/GUIActionAdapter>
|
|
|
|
namespace osgUtil{
|
|
|
|
class OSGUTIL_EXPORT CameraManipulator : public GUIEventHandler
|
|
{
|
|
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.*/
|
|
virtual const osg::Camera * getCamera() const;
|
|
|
|
/** 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.*/
|
|
virtual const osg::Node* getNode() const { return NULL; }
|
|
|
|
|
|
void setHomeToUseNode() { _homeToUseNode=true; }
|
|
void setHome(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up)
|
|
{
|
|
_eyeHome = eye;
|
|
_centerHome = center;
|
|
_upHome = up;
|
|
_homeToUseNode = false;
|
|
}
|
|
|
|
/** 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.*/
|
|
virtual void init(const GUIEventAdapter& ,GUIActionAdapter&) {}
|
|
|
|
/** Handle events, return true if handled, false otherwise.*/
|
|
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
|
|
|
|
|
protected:
|
|
|
|
// Reference pointer to a camera
|
|
osg::ref_ptr<osg::Camera> _camera;
|
|
|
|
bool _homeToUseNode;
|
|
osg::Vec3 _eyeHome;
|
|
osg::Vec3 _centerHome;
|
|
osg::Vec3 _upHome;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
|
|