From Leandro Motta Barros, Doxygen comments for OsgCameraGroup and Viewer.

With a few small ammendments/additions from Robert Osfield.
This commit is contained in:
Robert Osfield 2005-01-22 15:41:03 +00:00
parent c99903497a
commit 0fd06a93ec
2 changed files with 131 additions and 73 deletions

View File

@ -59,9 +59,17 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
const SceneHandlerList& getSceneHandlerList() const { return _shvec;} const SceneHandlerList& getSceneHandlerList() const { return _shvec;}
/** Set the scene data to be rendered. The scene graph traversal during
* rendering will start at the node passed as parameter.
* @param scene The node to be used as the starting point during the
* rendering traversal of the scene graph.
*/
void setSceneData( osg::Node *scene ); void setSceneData( osg::Node *scene );
/** Get the scene data being used for rendering.
* @return The node being used as the starting point during the
* rendering traversal of the scene graph.
*/
osg::Node *getSceneData() { return _scene_data.get(); } osg::Node *getSceneData() { return _scene_data.get(); }
const osg::Node *getSceneData() const { return _scene_data.get(); } const osg::Node *getSceneData() const { return _scene_data.get(); }
@ -80,7 +88,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
const osg::Node* getTopMostSceneData() const; const osg::Node* getTopMostSceneData() const;
/** update internal structures w.r.t updated scene data.*/ /** Update internal structures w.r.t updated scene data.*/
virtual void updatedSceneData(); virtual void updatedSceneData();
@ -90,7 +98,6 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
const osg::DisplaySettings *getDisplaySettings() const { return _ds.get(); } const osg::DisplaySettings *getDisplaySettings() const { return _ds.get(); }
void setCullSettings( const osg::CullSettings& cs) { _cullSettings = cs; } void setCullSettings( const osg::CullSettings& cs) { _cullSettings = cs; }
osg::CullSettings& getCullSettings() { return _cullSettings; } osg::CullSettings& getCullSettings() { return _cullSettings; }
@ -183,7 +190,6 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
virtual void frame(); virtual void frame();
protected : protected :

View File

@ -33,6 +33,15 @@
namespace osgProducer { namespace osgProducer {
/** A Producer-based viewer. Just like OpenGL, the core of OSG is independent of
* windowing system. The integration between OSG and some windowing system is
* delegated to other, non-core parts of OSG (users are also allowed to
* integrate OSG with any exotic windowing system they happen to use).
* \c Viewer implements the integration between OSG and Producer, AKA Open
* Producer (http://www.andesengineering.com/Producer), thus offering an
* out-of-the-box, scalable and multi-platform abstraction of the windowing
* system.
*/
class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIActionAdapter class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIActionAdapter
{ {
public : public :
@ -47,20 +56,69 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
virtual ~Viewer(); virtual ~Viewer();
/** Specifies options to control some aspects of the
* \c Viewer behavior (using the \c setUpViewer() member
* function).
*/
enum ViewerOptions enum ViewerOptions
{ {
/** Do not activate any standard event handlers.
* If no event handlers are selected then the users would typically
* register their own custom event handlers to add user interaction via
* getEventHandlerList().push_back(myEventHandler) or addCameraManipulator(myCameraManipualtor).*/
NO_EVENT_HANDLERS = 0, NO_EVENT_HANDLERS = 0,
/** Add an \c osgGA::TrackballManipulator to manipulate the camera
* interactively.
*/
TRACKBALL_MANIPULATOR = 1, TRACKBALL_MANIPULATOR = 1,
/** Add an \c osgGA::DriveManipulator to manipulate the camera
* interactively.
*/
DRIVE_MANIPULATOR = 2, DRIVE_MANIPULATOR = 2,
/** Add an \c osgGA::FlightManipulator to manipulate the camera
* interactively.
*/
FLIGHT_MANIPULATOR = 4, FLIGHT_MANIPULATOR = 4,
/** Add an \c osgGA::TerrainManipulator to manipulate the camera
* interactively.
*/
TERRAIN_MANIPULATOR = 8, TERRAIN_MANIPULATOR = 8,
/** Add an \c osgGA::StateSetManipulator to interactively toggle
* some bits of the renderer state (texturing, lightning...)
*/
STATE_MANIPULATOR = 32, STATE_MANIPULATOR = 32,
/** Add a light source some point near the camera. */
HEAD_LIGHT_SOURCE = 64, HEAD_LIGHT_SOURCE = 64,
/** Add a light source above the scene; does nothing if
* \c HEAD_LIGHT_SOURCE is also used.
*/
SKY_LIGHT_SOURCE = 128, SKY_LIGHT_SOURCE = 128,
/** Add peformance statistics reporting, currently implemented via VIEWER_MANPULATOR. */
STATS_MANIPULATOR = 256, STATS_MANIPULATOR = 256,
/** Add an \c osgProducer::ViewerEventHandler that enables lots of
* tricks like performance statistics and writing the scene to a
* file.
*/
VIEWER_MANIPULATOR = 512, VIEWER_MANIPULATOR = 512,
/** Finish the viewer execution when the ESC key is pressed. */
ESCAPE_SETS_DONE = 1024, ESCAPE_SETS_DONE = 1024,
/** Enable a set of standard settings (\c TRACKBALL_MANIPULATOR,
* \c DRIVE_MANIPULATOR, \c FLIGHT_MANIPULATOR,
* \c TERRAIN_MANIPULATOR, \c STATE_MANIPULATOR,
* \c HEAD_LIGHT_SOURCE, \c STATS_MANIPULATOR,
* \c VIEWER_MANIPULATOR, \c ESCAPE_SETS_DONE).
*/
STANDARD_SETTINGS = TRACKBALL_MANIPULATOR| STANDARD_SETTINGS = TRACKBALL_MANIPULATOR|
DRIVE_MANIPULATOR | DRIVE_MANIPULATOR |
FLIGHT_MANIPULATOR | FLIGHT_MANIPULATOR |
@ -72,9 +130,13 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
ESCAPE_SETS_DONE ESCAPE_SETS_DONE
}; };
/** Set up the viewer, allowing to control some aspects of its behavior.
* @param options One or more of the options defined by the
* \c ViewerOptions enumeration, combined using the bitwise OR
* operator (``<tt>|</tt>'').
*/
void setUpViewer(unsigned int options=STANDARD_SETTINGS); void setUpViewer(unsigned int options=STANDARD_SETTINGS);
/** Set the viewer so it sets done to true once the refrence time equals or exceeds specified elapsed time. /** Set the viewer so it sets done to true once the refrence time equals or exceeds specified elapsed time.
* Automatically does a setDoneAtElapsedTimeEnabled(true). */ * Automatically does a setDoneAtElapsedTimeEnabled(true). */
void setDoneAtElapsedTime(double elapsedTime) { _setDoneAtElapsedTimeEnabled = true; _setDoneAtElapsedTime = elapsedTime; } void setDoneAtElapsedTime(double elapsedTime) { _setDoneAtElapsedTimeEnabled = true; _setDoneAtElapsedTime = elapsedTime; }
@ -88,8 +150,6 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
/** Get whether to use a elapsed time to limit the run of the viewer.*/ /** Get whether to use a elapsed time to limit the run of the viewer.*/
bool getDoneAtElapsedTimeEnabled() const { return _setDoneAtElapsedTimeEnabled; } bool getDoneAtElapsedTimeEnabled() const { return _setDoneAtElapsedTimeEnabled; }
/** Set the viewer so it sets done to true once the frame number equals or exceeds specified frame number. /** Set the viewer so it sets done to true once the frame number equals or exceeds specified frame number.
* Automatically does a setDoneAtFrameNumberEnabled(true). */ * Automatically does a setDoneAtFrameNumberEnabled(true). */
void setDoneAtFrameNumber(unsigned int frameNumber) { _setDoneAtFrameNumberEnabled = true; _setDoneAtFrameNumber = frameNumber; } void setDoneAtFrameNumber(unsigned int frameNumber) { _setDoneAtFrameNumberEnabled = true; _setDoneAtFrameNumber = frameNumber; }
@ -103,25 +163,21 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
/** Get whether to use a frame number to limit the run of the viewer.*/ /** Get whether to use a frame number to limit the run of the viewer.*/
bool getDoneAtFrameNumberEnabled() const { return _setDoneAtFrameNumberEnabled; } bool getDoneAtFrameNumberEnabled() const { return _setDoneAtFrameNumberEnabled; }
/** Set the done flag signalling that the viewer exit.*/ /** Set the done flag signalling that the viewer exit.*/
void setDone(bool done) { _done = done; } void setDone(bool done) { _done = done; }
/** Get the done flag which signals that the viewer exit.*/ /** Get the done flag which signals that the viewer exit.*/
bool getDone() const { return _done; } bool getDone() const { return _done; }
/** return true if the application is done and should exit.*/ /** Return true if the application is done and should exit.*/
virtual bool done() const; virtual bool done() const;
/** Set the viewer to take an image snapshot on the last frame() when done is enabled.*/ /** Set the viewer to take an image snapshot on the last frame() when done is enabled.*/
void setWriteImageWhenDone(bool enabled) { _writeImageWhenDone = enabled; } void setWriteImageWhenDone(bool enabled) { _writeImageWhenDone = enabled; }
/** Set the viewer to take an image snapshot on the last frame() when done is enabled.*/ /** Set the viewer to take an image snapshot on the last frame() when done is enabled.*/
bool getWriteImageWhenDone() const { return _writeImageWhenDone; } bool getWriteImageWhenDone() const { return _writeImageWhenDone; }
/** Set the filename to write to when the viewer takes an image snapshot on the last frame() when done is enabled.*/ /** Set the filename to write to when the viewer takes an image snapshot on the last frame() when done is enabled.*/
void setWriteImageFileName(const std::string& filename); void setWriteImageFileName(const std::string& filename);
@ -129,7 +185,6 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
const std::string& getWriteImageFileName() const; const std::string& getWriteImageFileName() const;
/** Override the Producer::CameraGroup::setViewByMatrix to catch all changes to view.*/ /** Override the Producer::CameraGroup::setViewByMatrix to catch all changes to view.*/
virtual void setViewByMatrix( const Producer::Matrix & pm); virtual void setViewByMatrix( const Producer::Matrix & pm);
@ -141,16 +196,15 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
/** Updated the scene. Handle any queued up events, do an update traversal and set the CameraGroup's setViewByMatrix if any camera manipulators are active.*/ /** Updated the scene. Handle any queued up events, do an update traversal and set the CameraGroup's setViewByMatrix if any camera manipulators are active.*/
virtual void update(); virtual void update();
/** set the update visitor which does the update traversal of the scene graph. Automatically called by the update() method.*/ /** Set the update visitor which does the update traversal of the scene graph. Automatically called by the update() method.*/
void setUpdateVisitor(osg::NodeVisitor* nv) { _updateVisitor = nv; } void setUpdateVisitor(osg::NodeVisitor* nv) { _updateVisitor = nv; }
/** get the update visitor.*/ /** Get the update visitor.*/
osg::NodeVisitor* getUpdateVisitor() { return _updateVisitor.get(); } osg::NodeVisitor* getUpdateVisitor() { return _updateVisitor.get(); }
/** get the const update visitor.*/ /** Get the const update visitor.*/
const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); } const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); }
void computeActiveCoordindateSystemNodePath(); void computeActiveCoordindateSystemNodePath();
void setCoordindateSystemNodePath(const osg::RefNodePath& nodePath) { _coordinateSystemNodePath = nodePath; } void setCoordindateSystemNodePath(const osg::RefNodePath& nodePath) { _coordinateSystemNodePath = nodePath; }
@ -167,22 +221,22 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
virtual void requestWarpPointer(float x,float y); virtual void requestWarpPointer(float x,float y);
/** compute, from normalized mouse coords, for sepecified Camera, the pixel coords relative to that Camera's RenderSurface.*/ /** Compute, from normalized mouse coords, for sepecified Camera, the pixel coords relative to that Camera's RenderSurface.*/
bool computePixelCoords(float x,float y,unsigned int cameraNum,float& pixel_x,float& pixel_y); bool computePixelCoords(float x,float y,unsigned int cameraNum,float& pixel_x,float& pixel_y);
/** compute, from normalized mouse coords, for sepecified Camera, the near and far points in worlds coords.*/ /** Compute, from normalized mouse coords, for sepecified Camera, the near and far points in worlds coords.*/
bool computeNearFarPoints(float x,float y,unsigned int cameraNum,osg::Vec3& near, osg::Vec3& far); bool computeNearFarPoints(float x,float y,unsigned int cameraNum,osg::Vec3& near, osg::Vec3& far);
/** compute, from normalized mouse coords, for all Cameras, intersections with the specified subgraph.*/ /** Compute, from normalized mouse coords, for all Cameras, intersections with the specified subgraph.*/
bool computeIntersections(float x,float y,unsigned int cameraNum,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff); bool computeIntersections(float x,float y,unsigned int cameraNum,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
/** compute, from normalized mouse coords, for sepecified Camera, intersections with the scene.*/ /** Compute, from normalized mouse coords, for sepecified Camera, intersections with the scene.*/
bool computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff); bool computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
/** compute, from normalized mouse coords, for all Cameras, intersections with specified subgraph.*/ /** Compute, from normalized mouse coords, for all Cameras, intersections with specified subgraph.*/
bool computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff); bool computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
/** compute, from normalized mouse coords, for all Cameras, intersections with the scene.*/ /** Compute, from normalized mouse coords, for all Cameras, intersections with the scene.*/
bool computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff); bool computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
void setKeyboardMouse(Producer::KeyboardMouse* kbm); void setKeyboardMouse(Producer::KeyboardMouse* kbm);
@ -193,8 +247,6 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
osgProducer::KeyboardMouseCallback* getKeyboardMouseCallback() { return _kbmcb.get(); } osgProducer::KeyboardMouseCallback* getKeyboardMouseCallback() { return _kbmcb.get(); }
const osgProducer::KeyboardMouseCallback* getKeyboardMouseCallback() const { return _kbmcb.get(); } const osgProducer::KeyboardMouseCallback* getKeyboardMouseCallback() const { return _kbmcb.get(); }
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList; typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList;
EventHandlerList& getEventHandlerList() { return _eventHandlerList; } EventHandlerList& getEventHandlerList() { return _eventHandlerList; }
const EventHandlerList& getEventHandlerList() const { return _eventHandlerList; } const EventHandlerList& getEventHandlerList() const { return _eventHandlerList; }
@ -222,7 +274,7 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
/** Get the keyboard and mouse usage of this viewer.*/ /** Get the keyboard and mouse usage of this viewer.*/
virtual void getUsage(osg::ApplicationUsage& usage) const; virtual void getUsage(osg::ApplicationUsage& usage) const;
/** update internal structures w.r.t updated scene data.*/ /** Update internal structures w.r.t updated scene data.*/
virtual void updatedSceneData(); virtual void updatedSceneData();
protected : protected :