2005-04-15 05:41:28 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
2003-01-21 21:14:29 +08:00
|
|
|
*
|
2005-01-22 23:41:03 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-01-21 21:14:29 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2005-01-22 23:41:03 +08:00
|
|
|
*
|
2003-01-21 21:14:29 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-01-22 23:41:03 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-01-21 21:14:29 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
#ifndef OSGPRODUCER_OSGCAMERAGROUP_H
|
|
|
|
#define OSGPRODUCER_OSGCAMERAGROUP_H 1
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include <Producer/CameraGroup>
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-04-17 23:27:17 +08:00
|
|
|
#include <osg/Timer>
|
2003-02-19 00:36:42 +08:00
|
|
|
#include <osg/ArgumentParser>
|
2003-03-25 23:13:20 +08:00
|
|
|
#include <osg/ApplicationUsage>
|
2003-01-21 21:14:29 +08:00
|
|
|
#include <osg/Group>
|
2003-01-18 02:34:35 +08:00
|
|
|
#include <osg/StateSet>
|
|
|
|
#include <osg/FrameStamp>
|
|
|
|
#include <osg/DisplaySettings>
|
2004-10-06 03:12:46 +08:00
|
|
|
#include <osg/CullSettings>
|
2003-09-06 06:35:34 +08:00
|
|
|
#include <osg/Matrixd>
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
#include <osgProducer/OsgSceneHandler>
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
namespace osgProducer {
|
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
2003-01-18 02:34:35 +08:00
|
|
|
{
|
|
|
|
public :
|
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
OsgCameraGroup();
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
OsgCameraGroup(Producer::CameraConfig *cfg);
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
OsgCameraGroup(const std::string& configFile);
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-02-25 20:28:16 +08:00
|
|
|
OsgCameraGroup(osg::ArgumentParser& arguments);
|
2003-02-19 00:36:42 +08:00
|
|
|
|
2004-07-23 17:15:22 +08:00
|
|
|
virtual ~OsgCameraGroup();
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-03-25 23:13:20 +08:00
|
|
|
void setApplicationUsage(osg::ApplicationUsage* au) { _applicationUsage = au; }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-03-25 23:13:20 +08:00
|
|
|
osg::ApplicationUsage* getApplicationUsage() { return _applicationUsage; }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-03-25 23:13:20 +08:00
|
|
|
const osg::ApplicationUsage* getApplicationUsage() const { return _applicationUsage; }
|
2003-02-24 01:01:05 +08:00
|
|
|
|
|
|
|
|
2003-06-24 23:40:09 +08:00
|
|
|
typedef std::vector < Producer::ref_ptr<osgProducer::OsgSceneHandler> > SceneHandlerList;
|
2003-03-25 23:13:20 +08:00
|
|
|
|
2003-02-24 01:01:05 +08:00
|
|
|
SceneHandlerList& getSceneHandlerList() { return _shvec;}
|
|
|
|
|
|
|
|
const SceneHandlerList& getSceneHandlerList() const { return _shvec;}
|
|
|
|
|
2005-01-22 23:41:03 +08:00
|
|
|
/** 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.
|
|
|
|
*/
|
2003-01-19 06:07:59 +08:00
|
|
|
void setSceneData( osg::Node *scene );
|
2005-01-22 23:41:03 +08:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
2003-01-19 06:07:59 +08:00
|
|
|
osg::Node *getSceneData() { return _scene_data.get(); }
|
|
|
|
|
|
|
|
const osg::Node *getSceneData() const { return _scene_data.get(); }
|
|
|
|
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
|
|
|
|
void setSceneDecorator( osg::Group* decorator);
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
osg::Group* getSceneDecorator() { return _scene_decorator.get(); }
|
|
|
|
|
|
|
|
const osg::Group* getSceneDecorator() const { return _scene_decorator.get(); }
|
|
|
|
|
|
|
|
|
2003-01-31 00:11:39 +08:00
|
|
|
osg::Node* getTopMostSceneData();
|
|
|
|
|
|
|
|
const osg::Node* getTopMostSceneData() const;
|
|
|
|
|
2004-05-03 20:04:25 +08:00
|
|
|
|
2005-01-22 23:41:03 +08:00
|
|
|
/** Update internal structures w.r.t updated scene data.*/
|
2004-05-03 20:04:25 +08:00
|
|
|
virtual void updatedSceneData();
|
|
|
|
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
void setDisplaySettings( osg::DisplaySettings *ds ) { _ds = ds; }
|
|
|
|
|
|
|
|
osg::DisplaySettings *getDisplaySettings() { return _ds.get(); }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
const osg::DisplaySettings *getDisplaySettings() const { return _ds.get(); }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2004-10-06 03:12:46 +08:00
|
|
|
void setCullSettings( const osg::CullSettings& cs) { _cullSettings = cs; }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2004-10-06 03:12:46 +08:00
|
|
|
osg::CullSettings& getCullSettings() { return _cullSettings; }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2004-10-06 03:12:46 +08:00
|
|
|
const osg::CullSettings& getCullSettings() const { return _cullSettings; }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
void setFrameStamp( osg::FrameStamp* fs );
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
osg::FrameStamp *getFrameStamp() { return _frameStamp.get(); }
|
|
|
|
|
|
|
|
const osg::FrameStamp *getFrameStamp() const { return _frameStamp.get(); }
|
|
|
|
|
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
void setGlobalStateSet( osg::StateSet *sset );
|
|
|
|
|
|
|
|
osg::StateSet *getGlobalStateSet() { return _global_stateset.get(); }
|
|
|
|
|
|
|
|
const osg::StateSet *getGlobalStateSet() const { return _global_stateset.get(); }
|
|
|
|
|
|
|
|
|
2004-08-05 18:01:32 +08:00
|
|
|
#ifdef USE_DEPRECATED_API
|
|
|
|
void setBackgroundColor( const osg::Vec4& backgroundColor) { setClearColor(backgroundColor); }
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2004-08-05 18:01:32 +08:00
|
|
|
const osg::Vec4& getBackgroundColor() const { return getClearColor(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void setClearColor( const osg::Vec4& clearColor );
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2004-08-05 18:01:32 +08:00
|
|
|
const osg::Vec4& getClearColor() const;
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
void setLODScale( float scale );
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2004-10-19 02:56:26 +08:00
|
|
|
float getLODScale() const;
|
2004-01-11 05:29:15 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
void setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode,float value=1.0f);
|
|
|
|
|
|
|
|
|
2004-07-20 18:17:22 +08:00
|
|
|
/** Set the options to set up SceneView with, see osgUtil::SceneView::Options for available options.*/
|
|
|
|
void setRealizeSceneViewOptions(unsigned int options) { _realizeSceneViewOptions = options; }
|
|
|
|
|
|
|
|
unsigned int getRealizeSceneViewOptions() { return _realizeSceneViewOptions; }
|
|
|
|
|
|
|
|
|
2003-03-19 20:06:29 +08:00
|
|
|
/** RealizeCallback class one should override to provide an the implemention of realize callbacks.
|
|
|
|
* Note, this callback overrides the normal call to OsgSceneHandler::init() so it become the your
|
|
|
|
* responisibility to call this within your callback if required, it is a safe assumption to
|
|
|
|
* always call OsgSceneHandler::init() within your callback..*/
|
|
|
|
class OSGPRODUCER_EXPORT RealizeCallback : public osg::Referenced
|
|
|
|
{
|
|
|
|
public:
|
2003-03-26 20:50:30 +08:00
|
|
|
virtual void operator()( OsgCameraGroup& cg, OsgSceneHandler& sh, const Producer::RenderSurface & rs) = 0;
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-03-19 20:06:29 +08:00
|
|
|
protected:
|
2004-08-02 17:11:31 +08:00
|
|
|
virtual ~RealizeCallback(); // {}
|
2003-03-19 20:06:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Set the realize callback to use when once the render surfaces are realized.*/
|
|
|
|
void setRealizeCallback( RealizeCallback* cb) { _realizeCallback = cb; }
|
|
|
|
|
|
|
|
/** Get the realize callback.*/
|
|
|
|
RealizeCallback* getRealizeCallback() { return _realizeCallback.get(); }
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-03-19 20:06:29 +08:00
|
|
|
/** Get the const realize callback.*/
|
|
|
|
const RealizeCallback* getRealizeCallback() const { return _realizeCallback.get(); }
|
|
|
|
|
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
void advance();
|
|
|
|
|
2003-04-08 23:18:45 +08:00
|
|
|
/** Set the threading model and then call realize().*/
|
|
|
|
virtual bool realize(ThreadingModel thread_model );
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-03-19 20:06:29 +08:00
|
|
|
/** Realize the render surfaces (OpenGL graphics) and various threads, and call any realize callbacks.*/
|
2003-04-08 23:18:45 +08:00
|
|
|
virtual bool realize();
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-04-06 06:24:48 +08:00
|
|
|
/** Set the model view matrix of the camera group,
|
|
|
|
* by individually set all the camera groups's camera.*/
|
2003-09-06 06:35:34 +08:00
|
|
|
virtual void setView(const osg::Matrixd& matrix);
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-04-06 06:24:48 +08:00
|
|
|
/** Get the model view martrix of the camera group,
|
|
|
|
* taking its value for camera 0.*/
|
2003-09-06 06:35:34 +08:00
|
|
|
osg::Matrixd getViewMatrix() const;
|
2003-04-06 06:24:48 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-04-17 19:14:25 +08:00
|
|
|
virtual void sync();
|
|
|
|
|
2003-03-19 20:06:29 +08:00
|
|
|
/** Dispatch the cull and draw for each of the Camera's for this frame.*/
|
2003-01-19 06:07:59 +08:00
|
|
|
virtual void frame();
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
|
|
|
|
protected :
|
|
|
|
|
2004-05-03 20:04:25 +08:00
|
|
|
|
|
|
|
virtual void setUpSceneViewsWithData();
|
2003-01-21 21:14:29 +08:00
|
|
|
|
|
|
|
|
2003-03-25 23:13:20 +08:00
|
|
|
osg::ApplicationUsage* _applicationUsage;
|
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
osg::ref_ptr<osg::Node> _scene_data;
|
|
|
|
osg::ref_ptr<osg::Group> _scene_decorator;
|
2003-01-19 06:07:59 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
osg::ref_ptr<osg::StateSet> _global_stateset;
|
2004-08-05 18:01:32 +08:00
|
|
|
osg::Vec4 _clear_color;
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode;
|
|
|
|
float _fusionDistanceValue;
|
2004-07-20 18:17:22 +08:00
|
|
|
|
|
|
|
unsigned int _realizeSceneViewOptions;
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
SceneHandlerList _shvec;
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-03-19 20:06:29 +08:00
|
|
|
osg::ref_ptr<RealizeCallback> _realizeCallback;
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
osg::ref_ptr<osg::DisplaySettings> _ds;
|
|
|
|
bool _initialized;
|
2005-01-22 23:41:03 +08:00
|
|
|
|
2004-10-06 03:12:46 +08:00
|
|
|
osg::CullSettings _cullSettings;
|
2003-04-17 19:14:25 +08:00
|
|
|
|
|
|
|
unsigned int _frameNumber;
|
|
|
|
osg::Timer _timer;
|
|
|
|
osg::Timer_t _start_tick;
|
2003-01-21 21:14:29 +08:00
|
|
|
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
void _init();
|
2003-01-18 02:34:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|