Moved the managing of frame stamp from osgProducer::Viewer into
osgProducer::OsgCamaraGroup. Added setting of trackball in osgcameragroup so its starts in the correct place for different models.
This commit is contained in:
parent
f759f7e69e
commit
fd262554ac
@ -146,8 +146,13 @@ int main( int argc, char **argv )
|
||||
// set the scene to render
|
||||
cg.setSceneData(loadedModel.get());
|
||||
|
||||
|
||||
const osg::BoundingSphere& bs = loadedModel->getBound();
|
||||
|
||||
Producer::Trackball tb;
|
||||
tb.setOrientation( Producer::Trackball::Z_UP );
|
||||
tb.setDistance(bs.radius()*3.0f);
|
||||
tb.translate(-bs.center().x(),-bs.center().y(),-bs.center().z());
|
||||
|
||||
// create the windows and run the threads.
|
||||
cg.realize();
|
||||
|
@ -152,6 +152,8 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
const osg::Matrix getViewMatrix() const;
|
||||
|
||||
|
||||
virtual void sync();
|
||||
|
||||
/** Dispatch the cull and draw for each of the Camera's for this frame.*/
|
||||
virtual void frame();
|
||||
|
||||
@ -180,6 +182,10 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
|
||||
osg::ref_ptr<osg::DisplaySettings> _ds;
|
||||
bool _initialized;
|
||||
|
||||
unsigned int _frameNumber;
|
||||
osg::Timer _timer;
|
||||
osg::Timer_t _start_tick;
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
|
||||
void _init();
|
||||
|
@ -83,8 +83,6 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
|
||||
|
||||
virtual bool realize();
|
||||
|
||||
virtual void sync();
|
||||
|
||||
virtual void update();
|
||||
|
||||
/** Dispatch the cull and draw for each of the Camera's for this frame.*/
|
||||
@ -143,10 +141,6 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
|
||||
|
||||
bool _done;
|
||||
|
||||
unsigned int _frameNumber;
|
||||
osg::Timer _timer;
|
||||
osg::Timer_t _start_tick;
|
||||
|
||||
osgProducer::KeyboardMouseCallback* _kbmcb;
|
||||
|
||||
EventHandlerList _eventHandlerList;
|
||||
|
@ -19,8 +19,8 @@ osgwindows glider.osg
|
||||
echo osgviewer --stereo cessna.osg
|
||||
osgviewer --stereo cessna.osg
|
||||
|
||||
echo osgviewer cessnafire.osg
|
||||
osgviewer cessnafire.osg
|
||||
echo osgcameragroup cessnafire.osg
|
||||
osgcameragroup cessnafire.osg
|
||||
|
||||
echo osgviewer spaceship.osg
|
||||
osgviewer spaceship.osg
|
||||
|
@ -126,6 +126,10 @@ void OsgCameraGroup::_init()
|
||||
|
||||
_initialized = false;
|
||||
|
||||
// set up the time and frame counter.
|
||||
_frameNumber = 0;
|
||||
_start_tick = _timer.tick();
|
||||
|
||||
if (!_frameStamp) _frameStamp = new osg::FrameStamp;
|
||||
|
||||
// set up the maximum number of graphics contexts, before loading the scene graph
|
||||
@ -133,6 +137,7 @@ void OsgCameraGroup::_init()
|
||||
osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts( getNumberOfCameras() );
|
||||
|
||||
_applicationUsage = osg::ApplicationUsage::instance();
|
||||
|
||||
}
|
||||
|
||||
void OsgCameraGroup::setSceneData( osg::Node *scene )
|
||||
@ -404,12 +409,21 @@ const osg::Matrix OsgCameraGroup::getViewMatrix() const
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void OsgCameraGroup::sync()
|
||||
{
|
||||
CameraGroup::sync();
|
||||
|
||||
// set the frame stamp for the new frame.
|
||||
double time_since_start = _timer.delta_s(_start_tick,_timer.tick());
|
||||
_frameStamp->setFrameNumber(_frameNumber++);
|
||||
_frameStamp->setReferenceTime(time_since_start);
|
||||
}
|
||||
|
||||
void OsgCameraGroup::frame()
|
||||
{
|
||||
osg::Node* node = getTopMostSceneData();
|
||||
if (node) node->getBound();
|
||||
|
||||
CameraGroup::frame();
|
||||
_frameStamp->setFrameNumber( _frameStamp->getFrameNumber() + 1 );
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,6 @@ private:
|
||||
//
|
||||
Viewer::Viewer():
|
||||
_done(0),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0),
|
||||
_recordingAnimationPath(false)
|
||||
{
|
||||
@ -134,7 +133,6 @@ Viewer::Viewer():
|
||||
Viewer::Viewer(Producer::CameraConfig *cfg):
|
||||
OsgCameraGroup(cfg),
|
||||
_done(false),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0),
|
||||
_recordingAnimationPath(false)
|
||||
{
|
||||
@ -143,7 +141,6 @@ Viewer::Viewer(Producer::CameraConfig *cfg):
|
||||
Viewer::Viewer(const std::string& configFile):
|
||||
OsgCameraGroup(configFile),
|
||||
_done(false),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0),
|
||||
_recordingAnimationPath(false)
|
||||
{
|
||||
@ -152,7 +149,6 @@ Viewer::Viewer(const std::string& configFile):
|
||||
Viewer::Viewer(osg::ArgumentParser& arguments):
|
||||
OsgCameraGroup(arguments),
|
||||
_done(false),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0),
|
||||
_recordingAnimationPath(false)
|
||||
{
|
||||
@ -187,9 +183,6 @@ void Viewer::setUpViewer(unsigned int options)
|
||||
(new Producer::KeyboardMouse(ia)) :
|
||||
(new Producer::KeyboardMouse(getCamera(0)->getRenderSurface()));
|
||||
|
||||
// set up the time and frame counter.
|
||||
_frameNumber = 0;
|
||||
_start_tick = _timer.tick();
|
||||
|
||||
// set the keyboard mouse callback to catch the events from the windows.
|
||||
if (!_kbmcb)
|
||||
@ -338,15 +331,6 @@ bool Viewer::realize()
|
||||
return _realized;
|
||||
}
|
||||
|
||||
void Viewer::sync()
|
||||
{
|
||||
OsgCameraGroup::sync();
|
||||
|
||||
// set the frame stamp for the new frame.
|
||||
double time_since_start = _timer.delta_s(_start_tick,_timer.tick());
|
||||
_frameStamp->setFrameNumber(_frameNumber++);
|
||||
_frameStamp->setReferenceTime(time_since_start);
|
||||
}
|
||||
|
||||
void Viewer::update()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user