Checked in migration from osgUtil based GUIAdapter code to Neil Salter's
osgGA (Gui Abstraction). This may break users code, but all it should require to fix the builds should be a change from osgUtil::CameraManipulator (etc) to osgGA::CameraManipulator and include <osgUtil/CameraManipulator (etc) to osgGA/CameraManipulator and the extra dependency of the link line.
This commit is contained in:
@@ -73,7 +73,7 @@ class GUIEventAdapter : public osg::Referenced
|
||||
virtual unsigned int getButtonMask() const = 0;
|
||||
|
||||
/** time in seconds of event. */
|
||||
virtual float time() const = 0;
|
||||
virtual double time() const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#ifndef OSGGLUT_GLUTEVENTADAPTER
|
||||
#define OSGGLUT_GLUTEVENTADAPTER 1
|
||||
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
|
||||
#include <osgGLUT/Export>
|
||||
|
||||
namespace osgGLUT{
|
||||
|
||||
/** Class for adapting GLUT events so that they can be used as input to osgUtil::CameraManipulators.*/
|
||||
class OSGGLUT_EXPORT GLUTEventAdapter : public osgUtil::GUIEventAdapter
|
||||
/** Class for adapting GLUT events so that they can be used as input to osgGA::CameraManipulators.*/
|
||||
class OSGGLUT_EXPORT GLUTEventAdapter : public osgGA::GUIEventAdapter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
#include <osg/Timer>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgUtil/CameraManipulator>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <osgGA/CameraManipulator>
|
||||
|
||||
#include <osgUtil/SceneView>
|
||||
|
||||
#include <osgGLUT/Window>
|
||||
@@ -28,7 +29,7 @@ namespace osgGLUT
|
||||
* but shouldn't be viewed as the be all and end of osg viewer classes.
|
||||
* Someone please rewrite it :-)
|
||||
*/
|
||||
class OSGGLUT_EXPORT Viewer : public Window, public osgUtil::GUIActionAdapter
|
||||
class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -75,12 +76,12 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgUtil::GUIActionAdapter
|
||||
void help(std::ostream& fout);
|
||||
|
||||
// handle multiple camera.
|
||||
unsigned int registerCameraManipulator(osgUtil::CameraManipulator* cm,
|
||||
unsigned int registerCameraManipulator(osgGA::CameraManipulator* cm,
|
||||
unsigned int viewport = 0);
|
||||
void selectCameraManipulator(unsigned int pos,
|
||||
unsigned int viewport = 0);
|
||||
|
||||
// derived from osgUtil::GUIActionAdapter
|
||||
// derived from osgGA::GUIActionAdapter
|
||||
virtual void requestRedraw() {} // redraw always by idle callback done.
|
||||
virtual void requestContinuousUpdate(bool /*needed*/) {} // continuous update always
|
||||
virtual void requestWarpPointer(int x,int y);
|
||||
@@ -92,7 +93,7 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgUtil::GUIActionAdapter
|
||||
osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); }
|
||||
const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
|
||||
|
||||
typedef std::vector<osg::ref_ptr<osgUtil::CameraManipulator> > CameraManipList;
|
||||
typedef std::vector<osg::ref_ptr<osgGA::CameraManipulator> > CameraManipList;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -112,13 +113,14 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgUtil::GUIActionAdapter
|
||||
|
||||
static Viewer* s_theViewer;
|
||||
|
||||
typedef std::vector<osg::ref_ptr<osgGA::CameraManipulator> > CameraManipList;
|
||||
|
||||
struct ViewportDef
|
||||
{
|
||||
osg::ref_ptr<osgUtil::SceneView> sceneView;
|
||||
float viewport[4]; // Win-size-relative [0,1]
|
||||
|
||||
osg::ref_ptr<osgUtil::CameraManipulator> _cameraManipulator;
|
||||
osg::ref_ptr<osgGA::CameraManipulator> _cameraManipulator;
|
||||
CameraManipList _cameraManipList;
|
||||
};
|
||||
|
||||
@@ -144,7 +146,6 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgUtil::GUIActionAdapter
|
||||
} times[3]; // store up to 3 frames worth of times
|
||||
bool _useDisplayLists;
|
||||
|
||||
|
||||
osg::Timer _timer;
|
||||
osg::Timer_t _tickRatePerSecond;
|
||||
osg::Timer_t _initialTick;
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
//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
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
//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_DRIVEMANIPULATOR
|
||||
#define OSGUTIL_DRIVEMANIPULATOR 1
|
||||
|
||||
#include <osgUtil/CameraManipulator>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
class OSGUTIL_EXPORT DriveManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
DriveManipulator();
|
||||
virtual ~DriveManipulator();
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Move the camera to the default position.
|
||||
May be ignored by manipulators if home functionality is not appropriate.*/
|
||||
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
/** Start/restart the manipulator.*/
|
||||
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
/** handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
private:
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const GUIEventAdapter& ea);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
bool calcMovement();
|
||||
|
||||
// Internal event stack comprising last three mouse events.
|
||||
osg::ref_ptr<const GUIEventAdapter> _ga_t1;
|
||||
osg::ref_ptr<const GUIEventAdapter> _ga_t0;
|
||||
|
||||
osg::ref_ptr<osg::Node> _node;
|
||||
|
||||
float _modelScale;
|
||||
float _velocity;
|
||||
float _height;
|
||||
float _buffer;
|
||||
|
||||
enum SpeedControlMode {
|
||||
USE_MOUSE_Y_FOR_SPEED,
|
||||
USE_MOUSE_BUTTONS_FOR_SPEED
|
||||
};
|
||||
|
||||
SpeedControlMode _speedMode;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
//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_FLIGHTMANIPULATOR
|
||||
#define OSGUTIL_FLIGHTMANIPULATOR 1
|
||||
|
||||
#include <osgUtil/CameraManipulator>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
class OSGUTIL_EXPORT FlightManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
FlightManipulator();
|
||||
virtual ~FlightManipulator();
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Move the camera to the default position.
|
||||
May be ignored by manipulators if home functionality is not appropriate.*/
|
||||
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
/** Start/restart the manipulator.*/
|
||||
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
/** handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
enum YawControlMode {
|
||||
YAW_AUTOMATICALLY_WHEN_BANKED,
|
||||
NO_AUTOMATIC_YAW
|
||||
};
|
||||
|
||||
/** Set the yaw control between no yaw and yawing when banked.*/
|
||||
void setYawControlMode(YawControlMode ycm) { _yawMode = ycm; }
|
||||
|
||||
private:
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const GUIEventAdapter& ea);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
bool calcMovement();
|
||||
|
||||
// Internal event stack comprising last three mouse events.
|
||||
osg::ref_ptr<const GUIEventAdapter> _ga_t1;
|
||||
osg::ref_ptr<const GUIEventAdapter> _ga_t0;
|
||||
|
||||
osg::ref_ptr<osg::Node> _node;
|
||||
|
||||
float _modelScale;
|
||||
float _velocity;
|
||||
|
||||
YawControlMode _yawMode;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
//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_GUIACTIONADAPTER
|
||||
#define OSGUTIL_GUIACTIONADAPTER 1
|
||||
|
||||
#include <osgUtil/Export>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
|
||||
/** Pure virtual base class for adapting the GUI actions requested by CameraManipulators
|
||||
* into actions which are handled by the GUI toolkit of the users application.
|
||||
*
|
||||
* There are several was of using the ActionAdapter either inheriting it as
|
||||
* done with osgGLUT::Viewer class or passing a simple struct to the camera
|
||||
* manipulator then unpacking the results and working out what to do to respond
|
||||
* to the requests.
|
||||
*
|
||||
* Also there are several ways to run your app and handle the updating of
|
||||
* the window. osgGLUT::Viewer always has a idle callback registered which does a
|
||||
* redraw all the time. osgGLUT::Viewer can safely ignore both requestRedraw() and
|
||||
* requestContinousUpdate() as these are happening all the time anyway.
|
||||
*
|
||||
* Other apps will probably want to respond to the requestRedraw() and
|
||||
* requestContinousUpdate(bool) and again there is more than one way to handle it.
|
||||
* You can override requestRedraw() and implement to call your own window
|
||||
* redraw straight away. Or you can implement so that a flag is set and
|
||||
* then you then respond the flag being set in your own leisure.
|
||||
*
|
||||
* requestContinousUpdate(bool) is for enabling a throw or idle
|
||||
* callback to be requested by the camera manipulator. Again you can respond
|
||||
* to this immediately by registering a idle callback or a timed callback, or
|
||||
* you can delay setting the callback and do at you own leisure.
|
||||
*
|
||||
* requestWarpPointer(int,int) is requesting a respositioning of a mouse pointer
|
||||
* to a specified x,y location on the window. Used by some camera manipulators
|
||||
* to initialize the mouse pointer when mouse position relative to a controls
|
||||
* neutral mouse position is required, i.e when mimicking a aircrafts joystick.
|
||||
*/
|
||||
class GUIActionAdapter
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void requestRedraw() = 0;
|
||||
virtual void requestContinuousUpdate(bool needed=true) = 0;
|
||||
virtual void requestWarpPointer(int x,int y) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
//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_GUIEVENTADAPTER
|
||||
#define OSGUTIL_GUIEVENTADAPTER 1
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osgUtil/Export>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
|
||||
/** Pure virtual base class for adapting platform specific events into
|
||||
* generic keyboard and mouse events.
|
||||
*
|
||||
* Used as GUI toolkit independent input into the osgUtil::CameraManipualor's.
|
||||
* For an example of how GUIEventAdapter is specialised for a particular GUI
|
||||
* Toolkit see osgGLUT::GLUTEventAdapter.
|
||||
*/
|
||||
class GUIEventAdapter : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
GUIEventAdapter() {}
|
||||
|
||||
|
||||
enum MouseButtonMask {
|
||||
LEFT_MOUSE_BUTTON=1,
|
||||
MIDDLE_MOUSE_BUTTON=2,
|
||||
RIGHT_MOUSE_BUTTON=4
|
||||
};
|
||||
|
||||
enum EventType {
|
||||
PUSH,
|
||||
RELEASE,
|
||||
DRAG,
|
||||
MOVE,
|
||||
KEYBOARD,
|
||||
FRAME,
|
||||
RESIZE,
|
||||
NONE
|
||||
};
|
||||
|
||||
/** Get the EventType of the GUI event.*/
|
||||
virtual EventType getEventType() const = 0;
|
||||
|
||||
/** key pressed, return -1 if inappropriate for this event. */
|
||||
virtual int getKey() const = 0;
|
||||
|
||||
/** button pressed/released, return -1 if inappropriate for this event.*/
|
||||
virtual int getButton() const = 0;
|
||||
|
||||
/** window minimum x. */
|
||||
virtual int getXmin() const = 0;
|
||||
|
||||
/** window maximum x. */
|
||||
virtual int getXmax() const = 0;
|
||||
|
||||
/** window minimum y. */
|
||||
virtual int getYmin() const = 0;
|
||||
|
||||
/** window maximum y. */
|
||||
virtual int getYmax() const = 0;
|
||||
|
||||
/** current mouse x position.*/
|
||||
virtual int getX() const = 0;
|
||||
|
||||
/** current mouse y position.*/
|
||||
virtual int getY() const = 0;
|
||||
|
||||
/** current mouse button state */
|
||||
virtual unsigned int getButtonMask() const = 0;
|
||||
|
||||
/** time in seconds of event. */
|
||||
virtual double time() const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** Force users to create on heap, so that multiple referencing is safe.*/
|
||||
virtual ~GUIEventAdapter() {}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
//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_GUIEVENTHANDLER
|
||||
#define OSGUTIL_GUIEVENTHANDLER 1
|
||||
|
||||
#include <osg/Referenced>
|
||||
|
||||
#include <osgUtil/Export>
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgUtil/GUIActionAdapter>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
class OSGUTIL_EXPORT GUIEventHandler : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
/** Handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us)=0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,66 +0,0 @@
|
||||
//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_SceneViewManipulator
|
||||
#define OSGUTIL_SceneViewManipulator 1
|
||||
|
||||
#include <osgUtil/Export>
|
||||
#include <osgUtil/SceneView>
|
||||
#include <osgUtil/CameraManipulator>
|
||||
#include <osgUtil/StateSetManipulator>
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgUtil/GUIActionAdapter>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
class OSGUTIL_EXPORT SceneViewManipulator : public GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
SceneViewManipulator();
|
||||
virtual ~SceneViewManipulator();
|
||||
|
||||
/** attach a scene view to the manipulator. */
|
||||
virtual void setSceneView(SceneView*);
|
||||
|
||||
/** get the attached a scene view.*/
|
||||
virtual SceneView * getSceneView();
|
||||
|
||||
/** get the attached a const scene view.*/
|
||||
virtual const SceneView * getSceneView() const;
|
||||
|
||||
/** Set the camera manipulator on the object.*/
|
||||
virtual void setCameraManipulator(CameraManipulator *cm) {_cm=cm;}
|
||||
|
||||
/** Get the camera manipulator on the object */
|
||||
virtual CameraManipulator *getCameraManipulator() {return _cm.get();}
|
||||
|
||||
/** Get the const camera manipulator on the object */
|
||||
virtual const CameraManipulator *getCameraManipulator() const {return _cm.get();}
|
||||
|
||||
/** Set the geostate manipulator on the object.*/
|
||||
virtual void setStateSetManipulator(StateSetManipulator *cm) {_gm=cm;}
|
||||
|
||||
/** Get the geostate manipulator on the object */
|
||||
virtual StateSetManipulator *getStateSetManipulator() { return _gm.get();}
|
||||
|
||||
/** Get the geostate manipulator on the object */
|
||||
virtual const StateSetManipulator *getStateSetManipulator() const {return _gm.get();}
|
||||
|
||||
/** Handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
protected:
|
||||
|
||||
// Reference pointer to our scene view
|
||||
osg::ref_ptr<SceneView> _sv;
|
||||
|
||||
osg::ref_ptr<CameraManipulator> _cm;
|
||||
osg::ref_ptr<StateSetManipulator> _gm;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,48 +0,0 @@
|
||||
//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_GEOSTATE_MANIPULATOR
|
||||
#define OSGUTIL_GEOSTATE_MANIPULATOR 1
|
||||
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgUtil/Export>
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgUtil/GUIActionAdapter>
|
||||
#include <osgUtil/GUIEventHandler>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
class OSGUTIL_EXPORT StateSetManipulator : public GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
StateSetManipulator();
|
||||
virtual ~StateSetManipulator();
|
||||
|
||||
/** attach a geostate to the manipulator to be used for specifying view.*/
|
||||
virtual void setStateSet(osg::StateSet*);
|
||||
|
||||
/** get the attached a geostate.*/
|
||||
virtual osg::StateSet * getStateSet();
|
||||
|
||||
/** get the attached a geostate.*/
|
||||
virtual const osg::StateSet * getStateSet() const;
|
||||
|
||||
/** Handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
protected:
|
||||
|
||||
// Reference pointer to a geostate
|
||||
osg::ref_ptr<osg::StateSet> _drawState;
|
||||
|
||||
bool _backface;
|
||||
bool _lighting;
|
||||
bool _texture;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,74 +0,0 @@
|
||||
//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_TRACKBALLMANIPULATOR
|
||||
#define OSGUTIL_TRACKBALLMANIPULATOR 1
|
||||
|
||||
#include <osgUtil/CameraManipulator>
|
||||
|
||||
namespace osgUtil{
|
||||
|
||||
class OSGUTIL_EXPORT TrackballManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
TrackballManipulator();
|
||||
virtual ~TrackballManipulator();
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Move the camera to the default position.
|
||||
May be ignored by manipulators if home functionality is not appropriate.*/
|
||||
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
/** Start/restart the manipulator.*/
|
||||
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
|
||||
/** handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
private:
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const GUIEventAdapter& ea);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
bool calcMovement();
|
||||
|
||||
void trackball(osg::Vec3& axis,float& angle, float p1x, float p1y, float p2x, float p2y);
|
||||
float tb_project_to_sphere(float r, float x, float y);
|
||||
|
||||
|
||||
/** Check the speed at which the mouse is moving.
|
||||
If speed is below a threshold then return false, otherwise return true.*/
|
||||
bool isMouseMoving();
|
||||
|
||||
// Internal event stack comprising last three mouse events.
|
||||
osg::ref_ptr<const GUIEventAdapter> _ga_t1;
|
||||
osg::ref_ptr<const GUIEventAdapter> _ga_t0;
|
||||
|
||||
osg::ref_ptr<osg::Node> _node;
|
||||
|
||||
float _modelScale;
|
||||
float _minimumZoomScale;
|
||||
|
||||
bool _thrown;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user