Several items of work related to adding a manual creation of occluders
option to the osgoccluder demo. First the osgGA classes have been generalised a little to better support new GUIEventHandler subclasses. Second osgGLUT has a new option for registering a user defined event handler, the allows the application to add externally extra options to the osgGLUT viewer. Third, the osgoccluder demo now works in two modes. The original create four occluder sides to wrap an loaded model, the second an interactive mode which allows the users to add occluders to the model by pointing to points and pressing 'a' to add a point, the 'e' to end the occluder polygon, polygons must be convex, planer and be defined in an anitclockwise order. To start the osgoccluder in this mode one simple runs it with the '-c' option. Run osgoccluder with no parameter to get a list of options.
This commit is contained in:
@@ -9,6 +9,7 @@ namespace osgGA{
|
||||
|
||||
// Some forward declarations
|
||||
class GUIActionAdapter;
|
||||
class GUIEventHandler;
|
||||
class CompositeGUIEventHandler;
|
||||
class CameraManipulator;
|
||||
class StateSetManipulator;
|
||||
@@ -26,6 +27,7 @@ class OSGGA_EXPORT GUIEventHandlerVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void visit(GUIEventHandler&) {}
|
||||
virtual void visit(CompositeGUIEventHandler&);
|
||||
virtual void visit(CameraManipulator&) {};
|
||||
virtual void visit(StateSetManipulator&) {};
|
||||
|
||||
@@ -24,17 +24,8 @@ class OSGGA_EXPORT KeySwitchCameraManipulator : public CameraManipulator
|
||||
|
||||
void addCameraManipulator(int key, std::string name, CameraManipulator *cm);
|
||||
|
||||
//typedef void (* Callback)(KeySwitchCameraManipulator *);
|
||||
void addNumberedCameraManipulator(CameraManipulator *cm);
|
||||
|
||||
// class Callback: public osgUtil::CallbackList<KeySwitchCameraManipulator>::Callback {
|
||||
// public:
|
||||
// virtual ~Callback() {};
|
||||
// virtual void operator()(KeySwitchCameraManipulator *) = 0;
|
||||
// };
|
||||
//
|
||||
// void addCallback(Callback*);
|
||||
//
|
||||
// void removeCallback(Callback*);
|
||||
|
||||
// Overrides from CameraManipulator...
|
||||
|
||||
@@ -64,9 +55,6 @@ class OSGGA_EXPORT KeySwitchCameraManipulator : public CameraManipulator
|
||||
|
||||
osg::ref_ptr<CameraManipulator> _current;
|
||||
|
||||
// Callbacks
|
||||
//CallbackList<KeySwitchCameraManipulator> _cameraManipChangeCallbacks;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -81,6 +81,8 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
|
||||
void selectCameraManipulator(unsigned int pos,
|
||||
unsigned int viewport = 0);
|
||||
|
||||
void setEventHandler(osgGA::GUIEventHandler* handler,unsigned int viewport = 0);
|
||||
|
||||
// derived from osgGA::GUIActionAdapter
|
||||
virtual void requestRedraw() {} // redraw always by idle callback done.
|
||||
virtual void requestContinuousUpdate(bool /*needed*/) {} // continuous update always
|
||||
@@ -119,8 +121,11 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
|
||||
osg::ref_ptr<osgUtil::SceneView> sceneView;
|
||||
float viewport[4]; // Win-size-relative [0,1]
|
||||
|
||||
osg::ref_ptr<osgGA::CameraManipulator> _cameraManipulator;
|
||||
osg::ref_ptr<osgGA::CameraManipulator> _cameraManipulator;
|
||||
CameraManipList _cameraManipList;
|
||||
|
||||
osg::ref_ptr<osgGA::GUIEventHandler> _eventHandler;
|
||||
|
||||
};
|
||||
|
||||
typedef std::vector<ViewportDef> ViewportList;
|
||||
|
||||
Reference in New Issue
Block a user