2003-03-19 04:27:09 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* 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>
|
|
|
|
|
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
|
|
|
|
2003-02-25 20:28:16 +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; }
|
|
|
|
|
|
|
|
osg::ApplicationUsage* getApplicationUsage() { return _applicationUsage; }
|
|
|
|
|
|
|
|
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;}
|
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
void setSceneData( osg::Node *scene );
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
osg::Node *getSceneData() { return _scene_data.get(); }
|
|
|
|
|
|
|
|
const osg::Node *getSceneData() const { return _scene_data.get(); }
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
|
|
|
|
void setSceneDecorator( osg::Group* decorator);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
void setDisplaySettings( osg::DisplaySettings *ds ) { _ds = ds; }
|
|
|
|
|
|
|
|
osg::DisplaySettings *getDisplaySettings() { return _ds.get(); }
|
|
|
|
|
|
|
|
const osg::DisplaySettings *getDisplaySettings() const { return _ds.get(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); }
|
|
|
|
|
|
|
|
|
|
|
|
void setBackgroundColor( const osg::Vec4& backgroundColor );
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
osg::Vec4& getBackgroundColor() { return _background_color; }
|
|
|
|
|
|
|
|
const osg::Vec4& getBackgroundColor() const { return _background_color; }
|
|
|
|
|
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
|
|
|
|
|
|
|
void setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode,float value=1.0f);
|
|
|
|
|
|
|
|
|
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;
|
2003-03-19 20:06:29 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~RealizeCallback() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** 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(); }
|
|
|
|
|
|
|
|
/** 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-04-08 23:47:45 +08:00
|
|
|
virtual void setView(const osg::Matrix& matrix);
|
2003-04-06 06:24:48 +08:00
|
|
|
|
|
|
|
/** Get the model view martrix of the camera group,
|
|
|
|
* taking its value for camera 0.*/
|
|
|
|
const osg::Matrix getViewMatrix() const;
|
|
|
|
|
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();
|
2003-03-25 23:13:20 +08:00
|
|
|
|
|
|
|
|
2003-01-19 06:07:59 +08:00
|
|
|
|
|
|
|
protected :
|
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
void setUpSceneViewsWithData();
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
osg::Vec4 _background_color;
|
|
|
|
float _LODScale;
|
|
|
|
|
|
|
|
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode;
|
|
|
|
float _fusionDistanceValue;
|
|
|
|
|
|
|
|
SceneHandlerList _shvec;
|
2003-03-19 20:06:29 +08:00
|
|
|
|
|
|
|
osg::ref_ptr<RealizeCallback> _realizeCallback;
|
|
|
|
|
2003-01-21 21:14:29 +08:00
|
|
|
osg::ref_ptr<osg::DisplaySettings> _ds;
|
|
|
|
bool _initialized;
|
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
|