Updates, from Neil Salter, to comments etc to osgGA which add better
explanations of how each of the classes operates.
This commit is contained in:
10
NEWS
10
NEWS
@@ -6,12 +6,19 @@ OSG News (most significant items from ChangeLog)
|
||||
the deprecates the original osg::Texture. All Texture class, including
|
||||
TextureCubeMap are derived from new base class for textures - osg::TextureBase.
|
||||
|
||||
New osgtexture1D and osgtexture3D demos demonstrate the new texture classes in
|
||||
action.
|
||||
|
||||
New PROTECTED mode for protecting local state mode and attributes from be
|
||||
overriden from state above it in the scene graph.
|
||||
|
||||
Support for fog coord and secondary colors extensions added to osg::Geometry.
|
||||
|
||||
Support for HP_UX.
|
||||
|
||||
New Inventor and VRML1.0 loader added.
|
||||
|
||||
Support added to lwo plugin for loading the new lwo2 format.
|
||||
|
||||
Support for OpenFlight15.7 added, DOFTransforms and general enhancements and
|
||||
bug fixes.
|
||||
@@ -25,7 +32,7 @@ OSG News (most significant items from ChangeLog)
|
||||
|
||||
osg::TexEnv texture_env_add added.
|
||||
|
||||
osg::Sequence implemented.
|
||||
osg::Sequence implemented, and osgsequence demo added.
|
||||
|
||||
osg::DOFTransformNode implemented.
|
||||
|
||||
@@ -33,6 +40,7 @@ OSG News (most significant items from ChangeLog)
|
||||
|
||||
Support for writing osg::Image's to .rgb format added.
|
||||
|
||||
|
||||
July 2002 - OpenSceneGraph-0.9.0.tar.gz
|
||||
|
||||
>>> OpenSceneGraph goes beta - Multitexturing, Occlusion Culling, Particles and much more added!
|
||||
|
||||
@@ -15,56 +15,67 @@
|
||||
|
||||
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:
|
||||
public:
|
||||
|
||||
CameraManipulator();
|
||||
virtual ~CameraManipulator();
|
||||
/** Attach a camera to the manipulator to be used for specifying view.*/
|
||||
virtual void setCamera(osg::Camera*);
|
||||
|
||||
/** 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 const osg::Camera * getCamera() const;
|
||||
/** Get the attached camera.*/
|
||||
virtual osg::Camera * getCamera();
|
||||
|
||||
/** get the attached camera.*/
|
||||
virtual osg::Camera * getCamera();
|
||||
|
||||
/** 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.*/
|
||||
/**
|
||||
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 node if attached.*/
|
||||
/** 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.*/
|
||||
/**
|
||||
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.*/
|
||||
|
||||
/**
|
||||
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 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:
|
||||
|
||||
protected:
|
||||
CameraManipulator();
|
||||
virtual ~CameraManipulator();
|
||||
|
||||
// Reference pointer to a camera
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
// Reference pointer to a camera
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -9,44 +9,43 @@
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
/**
|
||||
DriveManipulator is a camera manipulator which provides drive-like
|
||||
functionality. By default, the left mouse button accelerates, the right
|
||||
mouse button decelerates, and the middle mouse button (or left and
|
||||
right simultaneously) stops dead.
|
||||
*/
|
||||
|
||||
class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
DriveManipulator();
|
||||
virtual ~DriveManipulator();
|
||||
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*);
|
||||
virtual ~DriveManipulator();
|
||||
|
||||
/** Return node if attached.*/
|
||||
virtual const osg::Node* getNode() const;
|
||||
virtual void setNode(osg::Node*);
|
||||
|
||||
/** Return node if attached.*/
|
||||
virtual osg::Node* getNode();
|
||||
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);
|
||||
virtual osg::Node* getNode();
|
||||
|
||||
/** handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
private:
|
||||
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
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.*/
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
bool calcMovement();
|
||||
|
||||
// Internal event stack comprising last three mouse events.
|
||||
@@ -61,8 +60,8 @@ class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
float _buffer;
|
||||
|
||||
enum SpeedControlMode {
|
||||
USE_MOUSE_Y_FOR_SPEED,
|
||||
USE_MOUSE_BUTTONS_FOR_SPEED
|
||||
USE_MOUSE_Y_FOR_SPEED,
|
||||
USE_MOUSE_BUTTONS_FOR_SPEED
|
||||
};
|
||||
|
||||
SpeedControlMode _speedMode;
|
||||
@@ -72,4 +71,3 @@ class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
|
||||
# ifdef OSGGA_LIBRARY
|
||||
# define OSGGA_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define OSGGA_EXPORT __declspec(dllimport)
|
||||
#endif /* OSGUTIL_LIBRARY */
|
||||
# ifdef OSGGA_LIBRARY
|
||||
# define OSGGA_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define OSGGA_EXPORT __declspec(dllimport)
|
||||
#endif /* OSGUTIL_LIBRARY */
|
||||
#else
|
||||
#define OSGGA_EXPORT
|
||||
#define OSGGA_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -55,3 +55,89 @@ environemnt via the GUIActionAdapter. The viewer writer should then honour these
|
||||
requests, translating them into calls to the windowing API.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
\namespace osgGA::CmdLineArgs
|
||||
|
||||
A collection of utilities for processing command line arguments.
|
||||
|
||||
An osgGA::CmdLineArgs::Processor class is provided, which implements a chain
|
||||
of responsibilty for handline command line arguments. Each item in the chain
|
||||
is a subclass of the abstract osgGA::CmdLineArgs::ArgHandler. A number
|
||||
of ArgHandlers are provided, though the user if free to implement their
|
||||
own subclasses for specific needs (e.g. to validate an argument which
|
||||
takes an integer which must be in a specific range).
|
||||
|
||||
Let's look at an example...
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
\code
|
||||
|
||||
#include <osgGA/CmdLineArgs>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
using namespace osg;
|
||||
using namespace osgGA::CmdLineArgs;
|
||||
|
||||
// Create some handlers
|
||||
ref_ptr<BoolHandler> helpSwitch(new BoolHandler("[-h]","\t\tPrint this help and exit","-h"));
|
||||
ref_ptr<BoolHandler> verboseSwitch(new BoolHandler("[-v]","\t\tActivate verbose output","-v"));
|
||||
ref_ptr<SwitchStringHandler> configFile(
|
||||
new SwitchStringHandler("[-config <configfile>",
|
||||
"\t\tSpecify a config file to load"), "-config");
|
||||
|
||||
Processor clp;
|
||||
clp.push_back(helpSwitch.get());
|
||||
clp.push_back(verboseSwitch.get());
|
||||
clp.push_back(configFile.get());
|
||||
|
||||
try{
|
||||
clp.process(argc,argv);
|
||||
}
|
||||
catch(ArgHandlerX& e){
|
||||
cerr<<e.what()<<endl;
|
||||
clp.printUsage(cerr);
|
||||
exit(1);
|
||||
}
|
||||
catch(...){
|
||||
cerr<<"Unknown exception caught while processing command line arguments."<<endl;
|
||||
clp.printUsage(cerr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(helpSwitch->wasSpecified()){
|
||||
clp.printHelp(cerr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(verboseSwitch->wasSpecified()){
|
||||
// Activate verbosity...
|
||||
}
|
||||
|
||||
if(configFile->wasSpecified()){
|
||||
loadConfigFile(configFile->getString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
\endcode
|
||||
|
||||
The processor takes each argument on the command line in turn, and passes it
|
||||
to the ArgHandler chain. Each ArgHandler is given the opportunity to handle
|
||||
an argument and - if it requires - any subsequent arguments until the
|
||||
end of the argument list (it can do this by incrementing the ArgIterator
|
||||
passed to it. If an ArgHandler handles an argument (e.g. it's looking for
|
||||
and recognises the argument '-h'), it returns true and further processing of
|
||||
the argument stops. If an argument is not handled it is passed to the next
|
||||
handler in the chain, and so on, until it is either handled, or it drops off
|
||||
the end of the chain.
|
||||
|
||||
A number of pre-written ArgHandlers are supplied. User's may use these
|
||||
directly, may write their own, or may extend a pre-written ArgHandler to
|
||||
customise it for their specific needs.
|
||||
|
||||
*/
|
||||
|
||||
@@ -9,44 +9,41 @@
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
/**
|
||||
FlightManipulator is a CameraManipulator which provides flight simulator-like
|
||||
updating of the camera position & orientation. By default, the left mouse
|
||||
button accelerates, the right mouse button decelerates, and the middle mouse
|
||||
button (or left and right simultaneously) stops dead.
|
||||
*/
|
||||
|
||||
class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
FlightManipulator();
|
||||
virtual ~FlightManipulator();
|
||||
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;
|
||||
|
||||
/** Return node if attached.*/
|
||||
virtual osg::Node* getNode();
|
||||
|
||||
/** 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);
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
enum YawControlMode {
|
||||
YAW_AUTOMATICALLY_WHEN_BANKED,
|
||||
NO_AUTOMATIC_YAW
|
||||
YAW_AUTOMATICALLY_WHEN_BANKED,
|
||||
NO_AUTOMATIC_YAW
|
||||
};
|
||||
|
||||
/** Set the yaw control between no yaw and yawing when banked.*/
|
||||
/** Configure the Yaw control for the flight model. */
|
||||
void setYawControlMode(YawControlMode ycm) { _yawMode = ycm; }
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
/** Reset the internal GUIEvent stack.*/
|
||||
void flushMouseEventStack();
|
||||
@@ -65,7 +62,7 @@ class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
|
||||
float _modelScale;
|
||||
float _velocity;
|
||||
|
||||
|
||||
YawControlMode _yawMode;
|
||||
|
||||
};
|
||||
|
||||
@@ -9,43 +9,64 @@
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
/**
|
||||
Abstract base class defining the interface by which GUIEventHandlers may request
|
||||
actions of the GUI system in use. These requests for actions should then be honoured
|
||||
by the GUI toolkit of the user's application.
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
To provide more detail, when a GUIEventHandler (e.g. a TrackballManipulator)
|
||||
handles an incoming event, such as a mouse event, it may wish to make
|
||||
a request of the GUI. E.g. if a model is 'thrown', the trackball manipulator
|
||||
may wish to start a timer, and be repeatedly called, to continuously refresh the
|
||||
camera's position and orientation. However, it has no way of doing this, as it
|
||||
knows nothing of the window system in which it's operating. Instead, the
|
||||
GUIEventHandler issues it's request via a GUIActionAdapter, and the viewer
|
||||
in use should honour the request, using the GUI system in play.
|
||||
|
||||
There is more than one way of using the GUIActionAdapter. E.g. it may be inherited
|
||||
into a Viewer class, as is done with osgGLUT::Viewer. Alternatively, a simple
|
||||
subclass of GUIActionAdapter (e.g. osgQt::QtActionAdapter) may be passed to
|
||||
the GUIEventHandler::handle() function; once the function has returned, the viewer
|
||||
will then unpack the results and work 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.
|
||||
|
||||
*/
|
||||
class GUIActionAdapter
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
virtual void requestRedraw() = 0;
|
||||
virtual void requestContinuousUpdate(bool needed=true) = 0;
|
||||
virtual void requestWarpPointer(int x,int y) = 0;
|
||||
/**
|
||||
requestRedraw() requests a single redraw.
|
||||
*/
|
||||
virtual void requestRedraw() = 0;
|
||||
|
||||
/**
|
||||
requestContinousUpdate(bool) is for en/disabling a throw or idle
|
||||
callback to be requested by a GUIEventHandler (typically a CameraManipulator,
|
||||
though other GUIEventHandler's may also provide functionality).
|
||||
GUI toolkits can respond to this immediately by registering an idle/timed
|
||||
callback, or can delay setting the callback and update at their own leisure.
|
||||
*/
|
||||
virtual void requestContinuousUpdate(bool needed=true) = 0;
|
||||
|
||||
/**
|
||||
requestWarpPointer(int,int) is requesting a repositioning of the mouse pointer
|
||||
to a specified x,y location on the window. This is used by some camera manipulators
|
||||
to initialise the mouse pointer when mouse position relative to a controls
|
||||
neutral mouse position is required, i.e when mimicking a aircrafts joystick.
|
||||
*/
|
||||
virtual void requestWarpPointer(int x,int y) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -11,41 +11,40 @@
|
||||
namespace osgGA{
|
||||
|
||||
|
||||
/** 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
|
||||
/**
|
||||
Pure virtual base class for adapting platform specific events into
|
||||
generic keyboard and mouse events.
|
||||
|
||||
Used as GUI toolkit-independent input into GUIEventAdapters. Viewer
|
||||
writers should subclass this base class to implement the functionality
|
||||
to translate one of their GUI events, e.g. a Qt Event or an MFC Event,
|
||||
as appropriate.
|
||||
*/
|
||||
class OSGGA_EXPORT GUIEventAdapter : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
GUIEventAdapter() {}
|
||||
|
||||
public:
|
||||
|
||||
enum MouseButtonMask {
|
||||
LEFT_MOUSE_BUTTON=1,
|
||||
MIDDLE_MOUSE_BUTTON=2,
|
||||
RIGHT_MOUSE_BUTTON=4
|
||||
LEFT_MOUSE_BUTTON=1,
|
||||
MIDDLE_MOUSE_BUTTON=2,
|
||||
RIGHT_MOUSE_BUTTON=4
|
||||
};
|
||||
|
||||
enum EventType {
|
||||
PUSH,
|
||||
RELEASE,
|
||||
DRAG,
|
||||
MOVE,
|
||||
KEYBOARD,
|
||||
FRAME,
|
||||
RESIZE,
|
||||
NONE
|
||||
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. */
|
||||
/** key pressed, return -1 if inappr opriate for this event. */
|
||||
virtual int getKey() const = 0;
|
||||
|
||||
/** button pressed/released, return -1 if inappropriate for this event.*/
|
||||
@@ -60,7 +59,7 @@ class GUIEventAdapter : public osg::Referenced
|
||||
/** window minimum y. */
|
||||
virtual int getYmin() const = 0;
|
||||
|
||||
/** window maximum y. */
|
||||
/** window maximum y. */
|
||||
virtual int getYmax() const = 0;
|
||||
|
||||
/** current mouse x position.*/
|
||||
@@ -75,9 +74,10 @@ class GUIEventAdapter : public osg::Referenced
|
||||
/** time in seconds of event. */
|
||||
virtual double time() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
GUIEventAdapter() {}
|
||||
|
||||
protected:
|
||||
|
||||
/** Force users to create on heap, so that multiple referencing is safe.*/
|
||||
virtual ~GUIEventAdapter() {}
|
||||
|
||||
@@ -86,4 +86,3 @@ class GUIEventAdapter : public osg::Referenced
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,21 +38,19 @@ This request is made via the GUIActionAdapter class.
|
||||
|
||||
class OSGGA_EXPORT GUIEventHandler : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
/** Handle events, return true if handled, false otherwise.*/
|
||||
/** Handle events, return true if handled, false otherwise. */
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us)=0;
|
||||
|
||||
/** Is this const GUIEventHandler a composite? */
|
||||
/** Returns 0 if this GUIEventHandler is not a CompositeGUIEventHandler. */
|
||||
virtual const CompositeGUIEventHandler* getComposite() const { return 0; }
|
||||
|
||||
/** Is this non-const GUIEventHandler a composite? */
|
||||
/** Returns 0 if this GUIEventHandler is not a CompositeGUIEventHandler. */
|
||||
virtual CompositeGUIEventHandler* getComposite() { return 0; }
|
||||
|
||||
/** Accept visits from GUIEventHandler visitors */
|
||||
virtual void accept(GUIEventHandlerVisitor&) = 0;
|
||||
//virtual void accept(GUIEventHandlerVisitor&) { }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +60,7 @@ CompositeGUIEventHandler allows GUIEventHandlers to be composed into hierarchies
|
||||
|
||||
class OSGGA_EXPORT CompositeGUIEventHandler : public GUIEventHandler
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef std::vector< osg::ref_ptr<GUIEventHandler> > ChildList;
|
||||
|
||||
@@ -74,9 +72,7 @@ class OSGGA_EXPORT CompositeGUIEventHandler : public GUIEventHandler
|
||||
|
||||
virtual void accept(GUIEventHandlerVisitor& v) { v.visit(*this); }
|
||||
|
||||
|
||||
|
||||
/* Composite-specific methods below */
|
||||
// Composite-specific methods below
|
||||
|
||||
virtual bool addChild(GUIEventHandler *geh);
|
||||
|
||||
@@ -90,28 +86,27 @@ class OSGGA_EXPORT CompositeGUIEventHandler : public GUIEventHandler
|
||||
|
||||
bool containsNode( const GUIEventHandler* node ) const
|
||||
{
|
||||
|
||||
for (ChildList::const_iterator itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->get()==node) return true;
|
||||
}
|
||||
return false;
|
||||
for (ChildList::const_iterator itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->get()==node) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ChildList::iterator findChild( const GUIEventHandler* node )
|
||||
{
|
||||
for (ChildList::iterator itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->get()==node) return itr;
|
||||
}
|
||||
return _children.end();
|
||||
for (ChildList::iterator itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->get()==node) return itr;
|
||||
}
|
||||
return _children.end();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
ChildList _children;
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ class CompositeGUIEventHandler;
|
||||
class CameraManipulator;
|
||||
class StateSetManipulator;
|
||||
|
||||
/** Base class primarily for visiting GUIEventHandlers.
|
||||
/**
|
||||
Base class for visiting GUIEventHandlers.
|
||||
|
||||
A Default Visitor, (Might want to make it an Extrinsic Visitor at some point).
|
||||
By default, it does nothing to the things it visits. Sub classes of this Visitor
|
||||
|
||||
@@ -9,31 +9,40 @@
|
||||
#include <osgGA/CameraManipulator>
|
||||
#include <osgGA/GUIEventHandler>
|
||||
#include <osgGA/GUIEventHandlerVisitor>
|
||||
//#include <osgUtil/CallbackList>
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
class GUIEventAdapter;
|
||||
class GUIActionAdapter;
|
||||
|
||||
/**
|
||||
KeySwitchCameraManipulator is a decorator which allows the type of camera manipulator
|
||||
being used to be switched by pressing a key. E.g. '1' for a TrackballManipultor,
|
||||
'2' for a DriveManipulator, '3' for a FlightManipulator. The manipulators available,
|
||||
and the associated switch keys, can be configured.
|
||||
*/
|
||||
class OSGGA_EXPORT KeySwitchCameraManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
// Local methods
|
||||
public:
|
||||
|
||||
/**
|
||||
Add a camera manipulator with an associated name, and a key to
|
||||
trigger the switch,
|
||||
*/
|
||||
void addCameraManipulator(int key, std::string name, CameraManipulator *cm);
|
||||
|
||||
/**
|
||||
Add a camera manipulator with an autogenerated keybinding which is '1' + previous number of camera's registerd.
|
||||
*/
|
||||
void addNumberedCameraManipulator(CameraManipulator *cm);
|
||||
|
||||
|
||||
// Overrides from CameraManipulator...
|
||||
|
||||
virtual void setCamera(osg::Camera* c) { _current->setCamera(c); }
|
||||
virtual void setCamera(osg::Camera* c) { _current->setCamera(c); }
|
||||
|
||||
virtual const osg::Camera * getCamera() const { return _current->getCamera(); }
|
||||
virtual const osg::Camera * getCamera() const { return _current->getCamera(); }
|
||||
|
||||
virtual osg::Camera * getCamera() { return _current->getCamera(); }
|
||||
virtual osg::Camera * getCamera() { return _current->getCamera(); }
|
||||
|
||||
virtual void setNode(osg::Node* n) { _current->setNode(n); }
|
||||
|
||||
@@ -47,14 +56,13 @@ class OSGGA_EXPORT KeySwitchCameraManipulator : public CameraManipulator
|
||||
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
typedef std::pair<std::string, osg::ref_ptr<CameraManipulator> > NamedManipulator;
|
||||
typedef std::map<int, NamedManipulator> KeyManipMap;
|
||||
KeyManipMap _manips;
|
||||
|
||||
osg::ref_ptr<CameraManipulator> _current;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -14,10 +14,11 @@ namespace osgGA{
|
||||
class GUIEventHandler;
|
||||
class CameraManipulator;
|
||||
|
||||
/** SetSceneViewGUIEventHandlerVisitor which visits various types of GUIEventHandler and
|
||||
sets them up appropriately, given a new scene view.
|
||||
. */
|
||||
|
||||
/**
|
||||
SetSceneViewGUIEventHandlerVisitor which visits various types of
|
||||
GUIEventHandler and sets them up appropriately, given a new scene
|
||||
view.
|
||||
*/
|
||||
class OSGGA_EXPORT SetSceneViewVisitor: public GUIEventHandlerVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -14,32 +14,36 @@
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
/**
|
||||
Experimental class, not been looked at for a while, but which will
|
||||
be returned to at some point :-\
|
||||
*/
|
||||
class OSGGA_EXPORT StateSetManipulator : public GUIEventHandler
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
StateSetManipulator();
|
||||
virtual ~StateSetManipulator();
|
||||
StateSetManipulator();
|
||||
virtual ~StateSetManipulator();
|
||||
|
||||
/** attach a stateset to the manipulator to be used for specifying view.*/
|
||||
virtual void setStateSet(osg::StateSet*);
|
||||
/** attach a geostate to the manipulator to be used for specifying view.*/
|
||||
virtual void setStateSet(osg::StateSet*);
|
||||
|
||||
/** get the attached a stateset.*/
|
||||
virtual osg::StateSet * getStateSet();
|
||||
/** get the attached a geostate.*/
|
||||
virtual osg::StateSet * getStateSet();
|
||||
|
||||
/** get the attached a stateset.*/
|
||||
virtual const osg::StateSet * getStateSet() const;
|
||||
/** 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);
|
||||
/** Handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
/** Handle visitations */
|
||||
virtual void accept(GUIEventHandlerVisitor&);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
// Reference pointer to a geostate
|
||||
osg::ref_ptr<osg::StateSet> _drawState;
|
||||
// Reference pointer to a geostate
|
||||
osg::ref_ptr<osg::StateSet> _drawState;
|
||||
|
||||
bool _backface;
|
||||
bool _lighting;
|
||||
|
||||
@@ -13,8 +13,8 @@ class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
TrackballManipulator();
|
||||
virtual ~TrackballManipulator();
|
||||
TrackballManipulator();
|
||||
virtual ~TrackballManipulator();
|
||||
|
||||
/** Attach a node to the manipulator.
|
||||
Automatically detaches previously attached node.
|
||||
@@ -37,7 +37,7 @@ class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
|
||||
|
||||
/** handle events, return true if handled, false otherwise.*/
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user