diff --git a/examples/osganimate/osganimate.cpp b/examples/osganimate/osganimate.cpp index e5a6b4b70..a30ff9a31 100644 --- a/examples/osganimate/osganimate.cpp +++ b/examples/osganimate/osganimate.cpp @@ -233,5 +233,15 @@ int main( int argc, char **argv ) // set the scene to render viewer.setSceneData(rootnode); - return viewer.run(); + viewer.setCameraManipulator(new osgGA::TrackballManipulator()); + + viewer.realize(); + + double simulationTime = 100.0; + + while (!viewer.done()) + { + viewer.frame(simulationTime); + simulationTime -= 0.01; + } } diff --git a/examples/osgcluster/osgcluster.cpp b/examples/osgcluster/osgcluster.cpp index 83089c8fa..66497e056 100644 --- a/examples/osgcluster/osgcluster.cpp +++ b/examples/osgcluster/osgcluster.cpp @@ -236,12 +236,14 @@ class DataConverter writeUInt(fs.getFrameNumber()); writeDouble(fs.getReferenceTime()); + writeDouble(fs.getSimulationTime()); } void read(osg::FrameStamp& fs) { fs.setFrameNumber(readUInt()); fs.setReferenceTime(readDouble()); + fs.setSimulationTime(readDouble()); osg::notify(osg::NOTICE)<<"readFramestamp = "<getFrameStamp(); if (!fs) return; // not frame stamp, no handle on the time so can't move. - double new_time = fs->getReferenceTime(); + double new_time = fs->getSimulationTime(); if (nv->getTraversalNumber() != _previous_traversal_number) { _angle += _angular_velocity * (new_time - _previous_time); diff --git a/examples/osgfxbrowser/osgfxbrowser.cpp b/examples/osgfxbrowser/osgfxbrowser.cpp index 71e74faf6..7f9d804bb 100644 --- a/examples/osgfxbrowser/osgfxbrowser.cpp +++ b/examples/osgfxbrowser/osgfxbrowser.cpp @@ -34,7 +34,7 @@ public: { osg::MatrixTransform *xform = dynamic_cast(node); if (xform && enabled_) { - double t = nv->getFrameStamp()->getReferenceTime(); + double t = nv->getFrameStamp()->getSimulationTime(); xform->setMatrix(osg::Matrix::rotate(t, osg::Vec3(0, 0, 1))); } traverse(node, nv); diff --git a/examples/osggeometry/osggeometry.cpp b/examples/osggeometry/osggeometry.cpp index b19eebf37..56f9c24fd 100644 --- a/examples/osggeometry/osggeometry.cpp +++ b/examples/osggeometry/osggeometry.cpp @@ -524,7 +524,7 @@ class MyTransformCallback : public osg::NodeCallback osg::MatrixTransform* transform = dynamic_cast(node); if (nv && transform && nv->getFrameStamp()) { - double time = nv->getFrameStamp()->getReferenceTime(); + double time = nv->getFrameStamp()->getSimulationTime(); transform->setMatrix(osg::Matrix::translate(0.0f,1.0f+cosf(time*_angular_velocity),0.0f)); } diff --git a/examples/osglight/osglight.cpp b/examples/osglight/osglight.cpp index 2984e667b..a6f75f524 100644 --- a/examples/osglight/osglight.cpp +++ b/examples/osglight/osglight.cpp @@ -41,10 +41,10 @@ class ModelTransformCallback : public osg::NodeCallback { if (_firstTime==0.0) { - _firstTime = frameStamp->getReferenceTime(); + _firstTime = frameStamp->getSimulationTime(); } - double phase = (frameStamp->getReferenceTime()-_firstTime)/_period; + double phase = (frameStamp->getSimulationTime()-_firstTime)/_period; phase -= floor(phase); phase *= (2.0 * osg::PI); diff --git a/examples/osgmotionblur/osgmotionblur.cpp b/examples/osgmotionblur/osgmotionblur.cpp index 6a34f6b6f..9dc556682 100644 --- a/examples/osgmotionblur/osgmotionblur.cpp +++ b/examples/osgmotionblur/osgmotionblur.cpp @@ -26,7 +26,7 @@ public: virtual void operator () (osg::GraphicsContext* gc) { - double t = gc->getState()->getFrameStamp()->getReferenceTime(); + double t = gc->getState()->getFrameStamp()->getSimulationTime(); if (!cleared_) { diff --git a/examples/osgparametric/osgparametric.cpp b/examples/osgparametric/osgparametric.cpp index bd563ef17..252d41918 100644 --- a/examples/osgparametric/osgparametric.cpp +++ b/examples/osgparametric/osgparametric.cpp @@ -82,7 +82,7 @@ class UniformVarying : public osg::Uniform::Callback virtual void operator () (osg::Uniform* uniform, osg::NodeVisitor* nv) { const osg::FrameStamp* fs = nv->getFrameStamp(); - float value = sinf(fs->getReferenceTime()); + float value = sinf(fs->getSimulationTime()); uniform->set(osg::Vec4(value,-value,-value,value)); } }; diff --git a/examples/osgphotoalbum/osgphotoalbum.cpp b/examples/osgphotoalbum/osgphotoalbum.cpp index 32ed46fbc..a0f76015b 100644 --- a/examples/osgphotoalbum/osgphotoalbum.cpp +++ b/examples/osgphotoalbum/osgphotoalbum.cpp @@ -424,7 +424,7 @@ void Page::traverse(osg::NodeVisitor& nv) const osg::FrameStamp* framestamp = nv.getFrameStamp(); if (framestamp) { - double t = framestamp->getReferenceTime(); + double t = framestamp->getSimulationTime(); if (_rotation!=_targetRotation) { diff --git a/examples/osgprecipitation/osgprecipitation.cpp b/examples/osgprecipitation/osgprecipitation.cpp index e948e85d4..ddd6dd722 100644 --- a/examples/osgprecipitation/osgprecipitation.cpp +++ b/examples/osgprecipitation/osgprecipitation.cpp @@ -32,7 +32,7 @@ class MyGustCallback : public osg::NodeCallback { osgParticle::PrecipitationEffect* pe = dynamic_cast(node); - float value = sin(nv->getFrameStamp()->getReferenceTime()); + float value = sin(nv->getFrameStamp()->getSimulationTime()); if (value<-0.5) { pe->snow(1.0); diff --git a/examples/osgprerender/osgprerender.cpp b/examples/osgprerender/osgprerender.cpp index efac15fab..d574fce56 100644 --- a/examples/osgprerender/osgprerender.cpp +++ b/examples/osgprerender/osgprerender.cpp @@ -49,14 +49,14 @@ class MyGeometryCallback : virtual void update(osg::NodeVisitor* nv,osg::Drawable* drawable) { const osg::FrameStamp* fs = nv->getFrameStamp(); - double referenceTime = fs->getReferenceTime(); + double simulationTime = fs->getSimulationTime(); if (_firstCall) { _firstCall = false; - _startTime = referenceTime; + _startTime = simulationTime; } - _time = referenceTime-_startTime; + _time = simulationTime-_startTime; drawable->accept(*this); drawable->dirtyBound(); diff --git a/examples/osgshaders/GL2Scene.cpp b/examples/osgshaders/GL2Scene.cpp index 09a1b2a1c..94e8a53fb 100644 --- a/examples/osgshaders/GL2Scene.cpp +++ b/examples/osgshaders/GL2Scene.cpp @@ -247,7 +247,7 @@ class AnimateCallback: public osg::Uniform::Callback { if( _enabled ) { - float angle = 2.0 * nv->getFrameStamp()->getReferenceTime(); + float angle = 2.0 * nv->getFrameStamp()->getSimulationTime(); float sine = sinf( angle ); // -1 -> 1 float v01 = 0.5f * sine + 0.5f; // 0 -> 1 float v10 = 1.0f - v01; // 1 -> 0 diff --git a/examples/osgshaderterrain/osgshaderterrain.cpp b/examples/osgshaderterrain/osgshaderterrain.cpp index ce879c29d..6d537e29c 100644 --- a/examples/osgshaderterrain/osgshaderterrain.cpp +++ b/examples/osgshaderterrain/osgshaderterrain.cpp @@ -130,7 +130,6 @@ osg::Node* createScene() /////////////////////////////////////////////////////////////////// // vertex shader using just Vec4 coefficients char vertexShaderSource[] = - "uniform float osg_FrameTime;\n" "uniform sampler2D terrainTexture;\n" "uniform vec3 terrainOrigin;\n" "uniform vec3 terrainScaleDown;\n" diff --git a/examples/osgshadow/osgshadow.cpp b/examples/osgshadow/osgshadow.cpp index 609f192e8..53e38358d 100644 --- a/examples/osgshadow/osgshadow.cpp +++ b/examples/osgshadow/osgshadow.cpp @@ -260,19 +260,14 @@ class SwitchHandler : public osgGA::GUIEventHandler public: SwitchHandler(): - _childNum(0), - _frameNum(0) {} + _childNum(0) {} - virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv) + virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object* object, osg::NodeVisitor* /*nv*/) { osg::Switch* sw = dynamic_cast(object); if (!sw) return false; - - if (nv->getFrameStamp()) - { - if (nv->getFrameStamp()->getFrameNumber()==_frameNum) return false; - _frameNum = nv->getFrameStamp()->getFrameNumber(); - } + + if (ea.getHandled()) return false; switch(ea.getEventType()) { @@ -280,12 +275,9 @@ public: { if (ea.getKey()=='n') { - ++_childNum; if (_childNum >= sw->getNumChildren()) _childNum = 0; - osg::notify(osg::NOTICE)<<"selecting "<<_childNum<setSingleChildOn(_childNum); return true; } @@ -301,7 +293,6 @@ protected: virtual ~SwitchHandler() {} unsigned int _childNum; - int _frameNum; }; @@ -320,6 +311,50 @@ osg::Node* createTestModel() return sw; } + + +class ShadowCallback : public osg::NodeCallback +{ +public: + ShadowCallback() {} + + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + osg::notify(osg::NOTICE)<<"We're in callback"<(nv); + if (!cv) + { + traverse(node,nv); + return; + } + + osgUtil::RenderBin* original_bin = cv->getCurrentRenderBin(); + + osgUtil::RenderBin* new_bin = original_bin->find_or_insert(999,"RenderBin"); + + cv->setCurrentRenderBin(new_bin); + + traverse(node,nv); + + osg::notify(osg::NOTICE)<<"new_bin->getStateGraphList().size()= "<getStateGraphList().size()<getRenderBinList().size()= "<getRenderBinList().size()<getRenderLeafList().size()= "<getRenderLeafList().size()<getRenderBinList().begin(); + itr != new_bin->getRenderBinList().end(); + ++itr) + { + osg::notify(osg::NOTICE)<<"bin num = "<first<setCurrentRenderBin(original_bin); + + } +}; + + + int main(int argc, char** argv) { // use an ArgumentParser object to manage the program arguments. @@ -367,6 +402,9 @@ int main(int argc, char** argv) bool doShadow = true; while (arguments.read("--noShadow")) doShadow = false; + bool cullCallback = false; + while (arguments.read("-c")) cullCallback = true; + int screenNum = -1; while (arguments.read("--screen", screenNum)) viewer.setUpViewOnSingleScreen(screenNum); @@ -501,6 +539,66 @@ int main(int argc, char** argv) ss->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); } + else if (cullCallback) + { + + int shadowVolumeBin = 1000; + + group->setCullCallback(new ShadowCallback()); + + group->addChild(model.get()); + + { + osg::ref_ptr geode = new osg::Geode; + group->addChild(geode.get()); + + occluder->computeShadowVolumeGeometry(lightpos, *shadowVolume); + shadowVolume->setDrawMode(drawMode); + + + if (drawMode == osgShadow::ShadowVolumeGeometry::STENCIL_TWO_SIDED) + { + osg::notify(osg::NOTICE)<<"STENCIL_TWO_SIDED seleteced"<setFunction(osg::StencilTwoSided::BACK, osg::StencilTwoSided::ALWAYS,0,~0u); + stencil->setOperation(osg::StencilTwoSided::BACK, osg::StencilTwoSided::KEEP, osg::StencilTwoSided::KEEP, osg::StencilTwoSided::DECR_WRAP); + stencil->setFunction(osg::StencilTwoSided::FRONT, osg::StencilTwoSided::ALWAYS,0,~0u); + stencil->setOperation(osg::StencilTwoSided::FRONT, osg::StencilTwoSided::KEEP, osg::StencilTwoSided::KEEP, osg::StencilTwoSided::INCR_WRAP); + + + osg::ColorMask* colourMask = new osg::ColorMask(false, false, false, false); + + osg::StateSet* ss_sv1 = geode->getOrCreateStateSet(); + ss_sv1->setRenderBinDetails(shadowVolumeBin, "RenderBin"); + ss_sv1->setAttributeAndModes(stencil,osg::StateAttribute::ON); + ss_sv1->setAttribute(colourMask); + ss_sv1->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); + + + } + else + { + osg::notify(osg::NOTICE)<<"STENCIL_TWO_PASSES seleteced"<setFunction(osg::Stencil::ALWAYS,0,~0u); + stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP); + + osg::ColorMask* colourMask = new osg::ColorMask(false, false, false, false); + + osg::StateSet* ss_sv1 = geode->getOrCreateStateSet(); + ss_sv1->setRenderBinDetails(shadowVolumeBin, "RenderBin"); + ss_sv1->setAttributeAndModes(stencil,osg::StateAttribute::ON); + ss_sv1->setAttribute(colourMask); + ss_sv1->setMode(GL_CULL_FACE,osg::StateAttribute::ON); + + geode->addDrawable(shadowVolume.get()); + } + + } + + } else { osg::Vec4 ambient(0.2,0.2,0.2,1.0); @@ -651,7 +749,7 @@ int main(int argc, char** argv) { if (updateLightPosition) { - float t = viewer.getFrameStamp()->getReferenceTime(); + float t = viewer.getFrameStamp()->getSimulationTime(); if (postionalLight) { lightpos.set(bb.center().x()+sinf(t)*bb.radius(), bb.center().y() + cosf(t)*bb.radius(), bb.zMax() + bb.radius() ,1.0f); diff --git a/examples/osgstereoimage/osgstereoimage.cpp b/examples/osgstereoimage/osgstereoimage.cpp index ad3d352f8..609630242 100644 --- a/examples/osgstereoimage/osgstereoimage.cpp +++ b/examples/osgstereoimage/osgstereoimage.cpp @@ -208,7 +208,7 @@ void SlideEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv) { if (_autoSteppingActive && nv->getFrameStamp()) { - double time = nv->getFrameStamp()->getReferenceTime(); + double time = nv->getFrameStamp()->getSimulationTime(); if (_firstTraversal) { diff --git a/examples/osgtexture1D/osgtexture1D.cpp b/examples/osgtexture1D/osgtexture1D.cpp index c01dc3162..55e550b20 100644 --- a/examples/osgtexture1D/osgtexture1D.cpp +++ b/examples/osgtexture1D/osgtexture1D.cpp @@ -127,7 +127,7 @@ class AnimateStateCallback : public osg::NodeCallback if (stateset && nv->getFrameStamp()) { // we have an exisitng stateset, so lets animate it. - animateState(stateset,nv->getFrameStamp()->getReferenceTime()); + animateState(stateset,nv->getFrameStamp()->getSimulationTime()); } // note, callback is repsonsible for scenegraph traversal so diff --git a/examples/osgtexture2D/osgtexture2D.cpp b/examples/osgtexture2D/osgtexture2D.cpp index fe597d7df..40fdddc18 100644 --- a/examples/osgtexture2D/osgtexture2D.cpp +++ b/examples/osgtexture2D/osgtexture2D.cpp @@ -63,7 +63,7 @@ public: { if (nv->getFrameStamp()) { - double currTime = nv->getFrameStamp()->getReferenceTime(); + double currTime = nv->getFrameStamp()->getSimulationTime(); if (currTime-_prevTime>_delay) { // update filter modes and text. @@ -222,7 +222,7 @@ public: { if (nv->getFrameStamp()) { - double currTime = nv->getFrameStamp()->getReferenceTime(); + double currTime = nv->getFrameStamp()->getSimulationTime(); if (currTime-_prevTime>_delay) { // update filter modes and text. @@ -379,7 +379,7 @@ public: { if (nv->getFrameStamp()) { - double currTime = nv->getFrameStamp()->getReferenceTime(); + double currTime = nv->getFrameStamp()->getSimulationTime(); if (currTime-_prevTime>_delay) { // update filter modes and text. @@ -532,7 +532,7 @@ public: { if (nv->getFrameStamp()) { - double currTime = nv->getFrameStamp()->getReferenceTime(); + double currTime = nv->getFrameStamp()->getSimulationTime(); if (currTime-_prevTime>_delay) { // update filter modes and text. diff --git a/examples/osgtexturerectangle/osgtexturerectangle.cpp b/examples/osgtexturerectangle/osgtexturerectangle.cpp index 8d7024bef..38f917149 100644 --- a/examples/osgtexturerectangle/osgtexturerectangle.cpp +++ b/examples/osgtexturerectangle/osgtexturerectangle.cpp @@ -58,7 +58,7 @@ public: return; if (nv->getFrameStamp()) { - double currTime = nv->getFrameStamp()->getReferenceTime(); + double currTime = nv->getFrameStamp()->getSimulationTime(); if (currTime - _prevTime > _delay) { float rad = osg::DegreesToRadians(currTime); diff --git a/include/osg/FrameStamp b/include/osg/FrameStamp index 678678a93..f03b507e6 100644 --- a/include/osg/FrameStamp +++ b/include/osg/FrameStamp @@ -46,6 +46,9 @@ class OSG_EXPORT FrameStamp : public Referenced void setReferenceTime(double refTime) { _referenceTime = refTime; } double getReferenceTime() const { return _referenceTime; } + void setSimulationTime(double refTime) { _simulationTime = refTime; } + double getSimulationTime() const { return _simulationTime; } + void setCalendarTime(const tm& calendarTime); void getCalendarTime(tm& calendarTime) const; @@ -62,7 +65,7 @@ class OSG_EXPORT FrameStamp : public Referenced int _frameNumber; double _referenceTime; - + double _simulationTime; // member variables of time.h's tm structure, copied here to // ensure that all data is not dynamic. The tm structure itself diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index 0f6064ee2..a9ca660cc 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -133,14 +133,18 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings enum ActiveUniforms { - FRAME_NUMBER_UNIFORM = 0x1, - FRAME_TIME_UNIFORM = 0x2, - DELTA_FRAME_TIME_UNIFORM = 0x4, - VIEW_MATRIX_UNIFORM = 0x8, - VIEW_MATRIX_INVERSE_UNIFORM = 0x10, + FRAME_NUMBER_UNIFORM = 1, + FRAME_TIME_UNIFORM = 2, + DELTA_FRAME_TIME_UNIFORM = 4, + SIMULATION_TIME_UNIFORM = 8, + DELTA_SIMULATION_TIME_UNIFORM = 16, + VIEW_MATRIX_UNIFORM = 32, + VIEW_MATRIX_INVERSE_UNIFORM = 64, DEFAULT_UNIFORMS = FRAME_NUMBER_UNIFORM | FRAME_TIME_UNIFORM | DELTA_FRAME_TIME_UNIFORM | + SIMULATION_TIME_UNIFORM | + DELTA_SIMULATION_TIME_UNIFORM | VIEW_MATRIX_UNIFORM | VIEW_MATRIX_INVERSE_UNIFORM, ALL_UNIFORMS = 0xFFFFFFFF @@ -505,6 +509,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings int _activeUniforms; double _previousFrameTime; + double _previousSimulationTime; bool _redrawInterlacedStereoStencilMask; int _interlacedStereoStencilWidth; diff --git a/include/osgViewer/CompositeViewer b/include/osgViewer/CompositeViewer index bbebe7d67..f5ca58f76 100644 --- a/include/osgViewer/CompositeViewer +++ b/include/osgViewer/CompositeViewer @@ -19,8 +19,6 @@ namespace osgViewer { -// WARNING ** Under development do not use, yet :-) - /** CompsiteViewer holds a or more views to a one more scenes.*/ class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced { @@ -113,9 +111,9 @@ class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced /** Render a complete new frame. * Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). */ - virtual void frame(); + virtual void frame(double simulationTime=USE_REFERENCE_TIME); - virtual void advance(); + virtual void advance(double simulationTime=USE_REFERENCE_TIME); virtual void eventTraversal(); diff --git a/include/osgViewer/Export b/include/osgViewer/Export index 7e90a25ed..33c065d0a 100644 --- a/include/osgViewer/Export +++ b/include/osgViewer/Export @@ -15,6 +15,8 @@ #ifndef OSGVIEWER_EXPORT_ #define OSGVIEWER_EXPORT_ 1 +#define USE_REFERENCE_TIME DBL_MAX + #if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) diff --git a/include/osgViewer/SimpleViewer b/include/osgViewer/SimpleViewer index b2db9abb0..57911449a 100644 --- a/include/osgViewer/SimpleViewer +++ b/include/osgViewer/SimpleViewer @@ -61,9 +61,9 @@ class OSGVIEWER_EXPORT SimpleViewer : public virtual osgViewer::GraphicsWindow /** Render a complete new frame. * Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameCullTraversal() and frameDrawTraversal(). * Note, no internal makeCurrent() is issued before, or swap buffers called after frame(), these operations are the responsibility of the calling code.*/ - virtual void frame(); + virtual void frame(double simulationTime=USE_REFERENCE_TIME); - virtual void advance(); + virtual void advance(double simulationTime=USE_REFERENCE_TIME); virtual void eventTraversal(); virtual void updateTraversal(); virtual void renderingTraversal(); diff --git a/include/osgViewer/Viewer b/include/osgViewer/Viewer index ff66e8380..cce614c4d 100644 --- a/include/osgViewer/Viewer +++ b/include/osgViewer/Viewer @@ -103,9 +103,9 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View /** Render a complete new frame. * Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). */ - virtual void frame(); + virtual void frame(double simulationTime=USE_REFERENCE_TIME); - virtual void advance(); + virtual void advance(double simulationTime=USE_REFERENCE_TIME); virtual void eventTraversal(); diff --git a/src/osg/AnimationPath.cpp b/src/osg/AnimationPath.cpp index ef7ea37a0..19995cb1a 100644 --- a/src/osg/AnimationPath.cpp +++ b/src/osg/AnimationPath.cpp @@ -230,7 +230,7 @@ void AnimationPathCallback::operator()(Node* node, NodeVisitor* nv) nv->getVisitorType()==NodeVisitor::UPDATE_VISITOR && nv->getFrameStamp()) { - double time = nv->getFrameStamp()->getReferenceTime(); + double time = nv->getFrameStamp()->getSimulationTime(); _latestTime = time; if (!_pause) diff --git a/src/osg/FrameStamp.cpp b/src/osg/FrameStamp.cpp index ce253de34..66506e6b1 100644 --- a/src/osg/FrameStamp.cpp +++ b/src/osg/FrameStamp.cpp @@ -18,6 +18,7 @@ FrameStamp::FrameStamp():Referenced() { _frameNumber=0; _referenceTime=0; + _simulationTime=0; tm_sec=0; /* Seconds. [0-60] (1 leap second) */ tm_min=0; /* Minutes. [0-59] */ diff --git a/src/osg/Sequence.cpp b/src/osg/Sequence.cpp index aa914eaac..cfcf55116 100644 --- a/src/osg/Sequence.cpp +++ b/src/osg/Sequence.cpp @@ -127,7 +127,7 @@ void Sequence::traverse(NodeVisitor& nv) if (framestamp) { - double t = framestamp->getReferenceTime(); + double t = framestamp->getSimulationTime(); if (_last == -1.0) _last = t; diff --git a/src/osgParticle/ParticleProcessor.cpp b/src/osgParticle/ParticleProcessor.cpp index 58bf00c5f..f66203aba 100644 --- a/src/osgParticle/ParticleProcessor.cpp +++ b/src/osgParticle/ParticleProcessor.cpp @@ -73,7 +73,7 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv) // retrieve the current time - double t = nv.getFrameStamp()->getReferenceTime(); + double t = nv.getFrameStamp()->getSimulationTime(); // reset this processor if we've reached the reset point if ((_currentTime >= _resetTime) && (_resetTime > 0)) diff --git a/src/osgParticle/ParticleSystemUpdater.cpp b/src/osgParticle/ParticleSystemUpdater.cpp index 02c1ef5cb..e252910b7 100644 --- a/src/osgParticle/ParticleSystemUpdater.cpp +++ b/src/osgParticle/ParticleSystemUpdater.cpp @@ -32,7 +32,7 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv) { _frameNumber = nv.getFrameStamp()->getFrameNumber(); - double t = nv.getFrameStamp()->getReferenceTime(); + double t = nv.getFrameStamp()->getSimulationTime(); if (_t0 != -1.0) { ParticleSystem_Vector::iterator i; diff --git a/src/osgParticle/PrecipitationEffect.cpp b/src/osgParticle/PrecipitationEffect.cpp index 499a3f4b8..03355d8e2 100644 --- a/src/osgParticle/PrecipitationEffect.cpp +++ b/src/osgParticle/PrecipitationEffect.cpp @@ -198,7 +198,7 @@ void PrecipitationEffect::traverse(osg::NodeVisitor& nv) if (nv.getFrameStamp()) { - double currentTime = nv.getFrameStamp()->getReferenceTime(); + double currentTime = nv.getFrameStamp()->getSimulationTime(); static double previousTime = currentTime; double delta = currentTime - previousTime; _origin += _wind * delta; @@ -515,8 +515,8 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles) "uniform vec4 particleColour;\n" "uniform float particleSize;\n" "\n" - "uniform float osg_FrameTime;\n" - "uniform float osg_DeltaFrameTime;\n" + "uniform float osg_SimulationTime;\n" + "uniform float osg_DeltaSimulationTime;\n" "\n" "varying vec4 colour;\n" "varying vec2 texCoord;\n" @@ -528,10 +528,10 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles) " texCoord = gl_MultiTexCoord0.xy;\n" "\n" " vec4 v_previous = gl_Vertex;\n" - " v_previous.z = fract( (osg_FrameTime - startTime)*inversePeriod - offset);\n" + " v_previous.z = fract( (osg_SimulationTime - startTime)*inversePeriod - offset);\n" " \n" " vec4 v_current = v_previous;\n" - " v_current.z += (osg_DeltaFrameTime*inversePeriod);\n" + " v_current.z += (osg_DeltaSimulationTime*inversePeriod);\n" " \n" "\n" " colour = particleColour;\n" @@ -589,8 +589,8 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles) "uniform vec4 particleColour;\n" "uniform float particleSize;\n" "\n" - "uniform float osg_FrameTime;\n" - "uniform float osg_DeltaFrameTime;\n" + "uniform float osg_SimulationTime;\n" + "uniform float osg_DeltaSimulationTime;\n" "uniform mat4 previousModelViewMatrix;\n" "\n" "varying vec4 colour;\n" @@ -603,10 +603,10 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles) " texCoord = gl_MultiTexCoord0.xy;\n" "\n" " vec4 v_previous = gl_Vertex;\n" - " v_previous.z = fract( (osg_FrameTime - startTime)*inversePeriod - offset);\n" + " v_previous.z = fract( (osg_SimulationTime - startTime)*inversePeriod - offset);\n" " \n" " vec4 v_current = v_previous;\n" - " v_current.z += (osg_DeltaFrameTime*inversePeriod);\n" + " v_current.z += (osg_DeltaSimulationTime*inversePeriod);\n" " \n" " colour = particleColour;\n" " \n" @@ -659,7 +659,7 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles) "uniform vec4 particleColour;\n" "uniform float particleSize;\n" "\n" - "uniform float osg_FrameTime;\n" + "uniform float osg_SimulationTime;\n" "\n" "varying vec4 colour;\n" "\n" @@ -669,7 +669,7 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles) " float startTime = gl_MultiTexCoord1.x;\n" "\n" " vec4 v_current = gl_Vertex;\n" - " v_current.z = fract( (osg_FrameTime - startTime)*inversePeriod - offset);\n" + " v_current.z = fract( (osg_SimulationTime - startTime)*inversePeriod - offset);\n" " \n" " colour = particleColour;\n" "\n" diff --git a/src/osgPlugins/Inventor/PendulumCallback.cpp b/src/osgPlugins/Inventor/PendulumCallback.cpp index 0b3e6d493..f2459fdd0 100644 --- a/src/osgPlugins/Inventor/PendulumCallback.cpp +++ b/src/osgPlugins/Inventor/PendulumCallback.cpp @@ -34,7 +34,7 @@ void PendulumCallback::operator() (osg::Node* node, osg::NodeVisitor* nv) // can be shared between multiple parents. if (nv->getTraversalNumber()!=_previousTraversalNumber) { - double currentTime = fs->getReferenceTime(); + double currentTime = fs->getSimulationTime(); _angle += (currentTime - _previousTime) * 2 * osg::PI * _frequency; double frac = 0.5 + 0.5 * sin(_angle); diff --git a/src/osgPlugins/Inventor/ShuttleCallback.cpp b/src/osgPlugins/Inventor/ShuttleCallback.cpp index 3e8564841..a14794552 100644 --- a/src/osgPlugins/Inventor/ShuttleCallback.cpp +++ b/src/osgPlugins/Inventor/ShuttleCallback.cpp @@ -33,7 +33,7 @@ void ShuttleCallback::operator() (osg::Node* node, osg::NodeVisitor* nv) // can be shared between multiple parents. if (nv->getTraversalNumber()!=_previousTraversalNumber) { - double currentTime = fs->getReferenceTime(); + double currentTime = fs->getSimulationTime(); _angle += (currentTime - _previousTime) * 2 * osg::PI * _frequency; double frac = 0.5 + 0.5 * sin(_angle); diff --git a/src/osgPlugins/geo/ReaderWriterGEO.cpp b/src/osgPlugins/geo/ReaderWriterGEO.cpp index d8ca1eddd..ae593959d 100644 --- a/src/osgPlugins/geo/ReaderWriterGEO.cpp +++ b/src/osgPlugins/geo/ReaderWriterGEO.cpp @@ -93,7 +93,7 @@ void geoHeaderGeo::update(const osg::FrameStamp *_frameStamp) osg::Timer_t _frameTick = _timer.tick(); _lastFrameTick=_frameTick; - double time = _frameStamp->getReferenceTime(); + double time = _frameStamp->getSimulationTime(); intVars->update( _frameStamp); moveit(time); } @@ -132,7 +132,7 @@ public: // so that it visits 'invisible' nodes to update visibility. Or could use // a visitor with setTraversalMode(TraversalMode==TRAVERSE_ALL_CHILDREN)? traverse(node,nv); - // std::cout<<"update callback - post traverse"<< (float)_frameStamp->getReferenceTime() <getSimulationTime() <getReferenceTime(); + double stmptime=_frameStamp->getSimulationTime(); int iord=0; for (std::vector::const_iterator itr=vars.begin(); //gfl.begin(); itr!=vars.end(); // gfl.end(); @@ -2088,12 +2088,12 @@ void internalVars::update(const osg::FrameStamp *_frameStamp) { newtime = localtime( &long_time ); // * Convert to local time. timestart=newtime->tm_hour*3600 +newtime->tm_min*60+ newtime->tm_sec; } - double timeofday=timestart+_frameStamp->getReferenceTime(); + double timeofday=timestart+_frameStamp->getSimulationTime(); vars[iord].setVal(timeofday); } break; case GEO_DB_INTERNAL_VAR_ELAPSED_TIME: - vars[iord].setVal(_frameStamp->getReferenceTime()); + vars[iord].setVal(_frameStamp->getSimulationTime()); break; case GEO_DB_INTERNAL_VAR_SINE: vars[iord].setVal(sin(stmptime)); @@ -2105,35 +2105,35 @@ void internalVars::update(const osg::FrameStamp *_frameStamp) { vars[iord].setVal(tan(stmptime)); break; case GEO_DB_INTERNAL_VAR_MOUSE_X: // this is all windowing system dependent - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_MOUSE_Y: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_LEFT_MOUSE: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_MIDDLE_MOUSE: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_RIGHT_MOUSE: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_TEMP_FLOAT: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_TEMP_INT: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_TEMP_BOOL: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; case GEO_DB_INTERNAL_VAR_TEMP_STRING: - // vars[iord]=_frameStamp->getReferenceTime(); + // vars[iord]=_frameStamp->getSimulationTime(); break; } } - // std::cout<<"update callback - post traverse"<< (float)_frameStamp->getReferenceTime() <getSimulationTime() <setReferenceTime(time_since_start); + _frameStamp->setSimulationTime(_frameStamp->getReferenceTime()); } else { @@ -741,6 +742,7 @@ void OsgCameraGroup::sync() double estimatedSwapTimeForFrame = _timer.delta_s(_start_tick,endOfNewFrameTick); _frameStamp->setReferenceTime(estimatedSwapTimeForFrame); + _frameStamp->setSimulationTime(_frameStamp->getReferenceTime()); } } diff --git a/src/osgSim/DOFTransform.cpp b/src/osgSim/DOFTransform.cpp index 92c02a98a..3625fb5e8 100644 --- a/src/osgSim/DOFTransform.cpp +++ b/src/osgSim/DOFTransform.cpp @@ -72,7 +72,7 @@ void DOFTransform::traverse(osg::NodeVisitor& nv) // can be shared between multiple parents. if ((nv.getTraversalNumber()!=_previousTraversalNumber) && nv.getFrameStamp()) { - double newTime = nv.getFrameStamp()->getReferenceTime(); + double newTime = nv.getFrameStamp()->getSimulationTime(); animate((float)(newTime-_previousTime)); diff --git a/src/osgSim/LightPointDrawable.cpp b/src/osgSim/LightPointDrawable.cpp index 763c43e78..3168aab05 100644 --- a/src/osgSim/LightPointDrawable.cpp +++ b/src/osgSim/LightPointDrawable.cpp @@ -20,8 +20,8 @@ using namespace osgSim; LightPointDrawable::LightPointDrawable(): osg::Drawable(), _endian(osg::getCpuByteOrder()), - _referenceTime(0.0), - _referenceTimeInterval(0.0) + _simulationTime(0.0), + _simulationTimeInterval(0.0) { setSupportsDisplayList(false); @@ -45,8 +45,8 @@ LightPointDrawable::LightPointDrawable(): LightPointDrawable::LightPointDrawable(const LightPointDrawable& lpd,const osg::CopyOp& copyop): osg::Drawable(lpd,copyop), - _referenceTime(lpd._referenceTime), - _referenceTimeInterval(lpd._referenceTimeInterval), + _simulationTime(lpd._simulationTime), + _simulationTimeInterval(lpd._simulationTimeInterval), _sizedOpaqueLightPointList(lpd._sizedOpaqueLightPointList), _sizedAdditiveLightPointList(lpd._sizedAdditiveLightPointList), _sizedBlendedLightPointList(lpd._sizedBlendedLightPointList) diff --git a/src/osgSim/LightPointDrawable.h b/src/osgSim/LightPointDrawable.h index f64825cb7..374fd3602 100644 --- a/src/osgSim/LightPointDrawable.h +++ b/src/osgSim/LightPointDrawable.h @@ -83,20 +83,20 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable virtual void drawImplementation(osg::State& state) const; - void setReferenceTime(double time) + void setSimulationTime(double time) { - _referenceTime = time; - _referenceTimeInterval = 0.0; + _simulationTime = time; + _simulationTimeInterval = 0.0; } - void updateReferenceTime(double time) + void updateSimulationTime(double time) { - _referenceTimeInterval = osg::clampAbove(time-_referenceTime,0.0); - _referenceTime = time; + _simulationTimeInterval = osg::clampAbove(time-_simulationTime,0.0); + _simulationTime = time; } - double getReferenceTime() const { return _referenceTime; } - double getReferenceTimeInterval() const { return _referenceTimeInterval; } + double getSimulationTime() const { return _simulationTime; } + double getSimulationTimeInterval() const { return _simulationTimeInterval; } virtual osg::BoundingBox computeBound() const; @@ -106,8 +106,8 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable osg::Endian _endian; - double _referenceTime; - double _referenceTimeInterval; + double _simulationTime; + double _simulationTimeInterval; typedef std::vector LightPointList; typedef std::vector SizedLightPointList; diff --git a/src/osgSim/LightPointNode.cpp b/src/osgSim/LightPointNode.cpp index 45427c042..4b9a7365c 100644 --- a/src/osgSim/LightPointNode.cpp +++ b/src/osgSim/LightPointNode.cpp @@ -200,7 +200,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv) if (cv->getFrameStamp()) { - drawable->setReferenceTime(cv->getFrameStamp()->getReferenceTime()); + drawable->setSimulationTime(cv->getFrameStamp()->getSimulationTime()); } } @@ -224,7 +224,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv) // need to update the drawable's frame count. if (cv->getFrameStamp()) { - drawable->updateReferenceTime(cv->getFrameStamp()->getReferenceTime()); + drawable->updateSimulationTime(cv->getFrameStamp()->getSimulationTime()); } } @@ -246,8 +246,8 @@ void LightPointNode::traverse(osg::NodeVisitor& nv) const float minimumIntensity = 1.0f/256.0f; const osg::Vec3 eyePoint = cv->getEyeLocal(); - double time=drawable->getReferenceTime(); - double timeInterval=drawable->getReferenceTimeInterval(); + double time=drawable->getSimulationTime(); + double timeInterval=drawable->getSimulationTimeInterval(); const osg::Polytope clipvol(cv->getCurrentCullingSet().getFrustum()); const bool computeClipping = false;//(clipvol.getCurrentMask()!=0); diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index fbe5c6c87..debcc0275 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -111,6 +111,7 @@ SceneView::SceneView(DisplaySettings* ds) _activeUniforms = DEFAULT_UNIFORMS; _previousFrameTime = 0; + _previousSimulationTime = 0; _redrawInterlacedStereoStencilMask = true; _interlacedStereoStencilWidth = 0; @@ -139,6 +140,7 @@ SceneView::SceneView(const SceneView& rhs, const osg::CopyOp& copyop): _activeUniforms = rhs._activeUniforms; _previousFrameTime = rhs._previousFrameTime; + _previousSimulationTime = rhs._previousSimulationTime; _redrawInterlacedStereoStencilMask = rhs._redrawInterlacedStereoStencilMask; _interlacedStereoStencilWidth = rhs._interlacedStereoStencilWidth; @@ -331,6 +333,21 @@ void SceneView::updateUniforms() uniform->set(delta_frame_time); } + if ((_activeUniforms & SIMULATION_TIME_UNIFORM) && _frameStamp.valid()) + { + osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_SimulationTime",osg::Uniform::FLOAT); + uniform->set(static_cast(_frameStamp->getSimulationTime())); + } + + if ((_activeUniforms & DELTA_SIMULATION_TIME_UNIFORM) && _frameStamp.valid()) + { + float delta_simulation_time = (_previousSimulationTime != 0.0) ? static_cast(_frameStamp->getSimulationTime()-_previousSimulationTime) : 0.0f; + _previousSimulationTime = _frameStamp->getSimulationTime(); + + osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_DeltaSimulationTime",osg::Uniform::FLOAT); + uniform->set(delta_simulation_time); + } + if (_activeUniforms & VIEW_MATRIX_UNIFORM) { osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_ViewMatrix",osg::Uniform::FLOAT_MAT4); diff --git a/src/osgUtil/TransformCallback.cpp b/src/osgUtil/TransformCallback.cpp index 49e1940f9..60e1623c1 100644 --- a/src/osgUtil/TransformCallback.cpp +++ b/src/osgUtil/TransformCallback.cpp @@ -37,7 +37,7 @@ void TransformCallback::operator() (osg::Node* node, osg::NodeVisitor* nv) const osg::FrameStamp* fs = nv->getFrameStamp(); if (!fs) return; // not frame stamp, no handle on the time so can't move. - double newTime = fs->getReferenceTime(); + double newTime = fs->getSimulationTime(); // ensure that we do not operate on this node more than // once during this traversal. This is an issue since node diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index dbf72c7a2..9841c6f81 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -35,6 +35,7 @@ CompositeViewer::CompositeViewer(): _frameStamp = new osg::FrameStamp; _frameStamp->setFrameNumber(0); _frameStamp->setReferenceTime(0); + _frameStamp->setSimulationTime(0); setEventQueue(new osgGA::EventQueue); @@ -722,7 +723,7 @@ void CompositeViewer::realize() } -void CompositeViewer::frame() +void CompositeViewer::frame(double simulationTime) { if (_done) return; @@ -739,19 +740,29 @@ void CompositeViewer::frame() _firstFrame = false; } - advance(); + advance(simulationTime); eventTraversal(); updateTraversal(); renderingTraversals(); } -void CompositeViewer::advance() +void CompositeViewer::advance(double simulationTime) { if (_done) return; - _frameStamp->setReferenceTime( osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick()) ); _frameStamp->setFrameNumber(_frameStamp->getFrameNumber()+1); + + _frameStamp->setReferenceTime( osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick()) ); + + if (simulationTime==USE_REFERENCE_TIME) + { + _frameStamp->setSimulationTime(_frameStamp->getReferenceTime()); + } + else + { + _frameStamp->setSimulationTime(simulationTime); + } } void CompositeViewer::setCameraWithFocus(osg::Camera* camera) diff --git a/src/osgViewer/SimpleViewer.cpp b/src/osgViewer/SimpleViewer.cpp index 244b62ce4..3b1401ddd 100644 --- a/src/osgViewer/SimpleViewer.cpp +++ b/src/osgViewer/SimpleViewer.cpp @@ -25,6 +25,7 @@ SimpleViewer::SimpleViewer(): _frameStamp = new osg::FrameStamp; _frameStamp->setFrameNumber(0); _frameStamp->setReferenceTime(0); + _frameStamp->setSimulationTime(0); _eventVisitor = new osgGA::EventVisitor; @@ -122,7 +123,7 @@ void SimpleViewer::init() } } -void SimpleViewer::frame() +void SimpleViewer::frame(double simulationTime) { if (_firstFrame) { @@ -130,17 +131,27 @@ void SimpleViewer::frame() _firstFrame = false; } - advance(); + advance(simulationTime); eventTraversal(); updateTraversal(); renderingTraversal(); } -void SimpleViewer::advance() +void SimpleViewer::advance(double simulationTime) { - _frameStamp->setReferenceTime(osg::Timer::instance()->time_s()); _frameStamp->setFrameNumber(_frameStamp->getFrameNumber()+1); + _frameStamp->setReferenceTime(osg::Timer::instance()->time_s()); + + if (simulationTime==USE_REFERENCE_TIME) + { + _frameStamp->setSimulationTime(_frameStamp->getReferenceTime()); + } + else + { + _frameStamp->setSimulationTime(simulationTime); + } + _sceneView->setFrameStamp(_frameStamp.get()); } diff --git a/src/osgViewer/Viewer.cpp b/src/osgViewer/Viewer.cpp index 9a7b88809..3b1e4e334 100644 --- a/src/osgViewer/Viewer.cpp +++ b/src/osgViewer/Viewer.cpp @@ -32,6 +32,7 @@ Viewer::Viewer(): _frameStamp = new osg::FrameStamp; _frameStamp->setFrameNumber(0); _frameStamp->setReferenceTime(0); + _frameStamp->setSimulationTime(0); _eventVisitor = new osgGA::EventVisitor; _eventVisitor->setActionAdapter(this); @@ -784,7 +785,7 @@ void Viewer::realize() } -void Viewer::frame() +void Viewer::frame(double simulationTime) { if (_done) return; @@ -801,22 +802,32 @@ void Viewer::frame() _firstFrame = false; } - advance(); + advance(simulationTime); eventTraversal(); updateTraversal(); renderingTraversals(); } -void Viewer::advance() +void Viewer::advance(double simulationTime) { if (_done) return; double prevousReferenceTime = _frameStamp->getReferenceTime(); int previousFrameNumber = _frameStamp->getFrameNumber(); - _frameStamp->setReferenceTime( osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick()) ); _frameStamp->setFrameNumber(_frameStamp->getFrameNumber()+1); + + _frameStamp->setReferenceTime( osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick()) ); + + if (simulationTime==USE_REFERENCE_TIME) + { + _frameStamp->setSimulationTime(_frameStamp->getReferenceTime()); + } + else + { + _frameStamp->setSimulationTime(simulationTime); + } if (getStats()) { diff --git a/src/osgWrappers/osg/FrameStamp.cpp b/src/osgWrappers/osg/FrameStamp.cpp index 2c2d8046f..3a2fa1c48 100644 --- a/src/osgWrappers/osg/FrameStamp.cpp +++ b/src/osgWrappers/osg/FrameStamp.cpp @@ -45,6 +45,14 @@ BEGIN_OBJECT_REFLECTOR(osg::FrameStamp) __double__getReferenceTime, "", ""); + I_Method1(void, setSimulationTime, IN, double, refTime, + __void__setSimulationTime__double, + "", + ""); + I_Method0(double, getSimulationTime, + __double__getSimulationTime, + "", + ""); I_Method1(void, setCalendarTime, IN, const tm &, calendarTime, __void__setCalendarTime__C5_tm_R1, "", @@ -62,5 +70,8 @@ BEGIN_OBJECT_REFLECTOR(osg::FrameStamp) I_SimpleProperty(double, ReferenceTime, __double__getReferenceTime, __void__setReferenceTime__double); + I_SimpleProperty(double, SimulationTime, + __double__getSimulationTime, + __void__setSimulationTime__double); END_REFLECTOR diff --git a/src/osgWrappers/osgUtil/SceneView.cpp b/src/osgWrappers/osgUtil/SceneView.cpp index c587d6f4c..bef438a0c 100644 --- a/src/osgWrappers/osgUtil/SceneView.cpp +++ b/src/osgWrappers/osgUtil/SceneView.cpp @@ -56,6 +56,8 @@ BEGIN_ENUM_REFLECTOR(osgUtil::SceneView::ActiveUniforms) I_EnumLabel(osgUtil::SceneView::FRAME_NUMBER_UNIFORM); I_EnumLabel(osgUtil::SceneView::FRAME_TIME_UNIFORM); I_EnumLabel(osgUtil::SceneView::DELTA_FRAME_TIME_UNIFORM); + I_EnumLabel(osgUtil::SceneView::SIMULATION_TIME_UNIFORM); + I_EnumLabel(osgUtil::SceneView::DELTA_SIMULATION_TIME_UNIFORM); I_EnumLabel(osgUtil::SceneView::VIEW_MATRIX_UNIFORM); I_EnumLabel(osgUtil::SceneView::VIEW_MATRIX_INVERSE_UNIFORM); I_EnumLabel(osgUtil::SceneView::DEFAULT_UNIFORMS); diff --git a/src/osgWrappers/osgViewer/CompositeViewer.cpp b/src/osgWrappers/osgViewer/CompositeViewer.cpp index d2405a04d..d9a618b26 100644 --- a/src/osgWrappers/osgViewer/CompositeViewer.cpp +++ b/src/osgWrappers/osgViewer/CompositeViewer.cpp @@ -151,14 +151,14 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::CompositeViewer) __int__run, "Execute a main frame loop. ", "Equivialant to while (!viewer.done()) viewer.frame(); Also calls realize() if the viewer is not already realized, and installs trackball manipulator if one is not already assigned."); - I_Method0(void, frame, - __void__frame, - "Render a complete new frame. ", - "Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). "); - I_Method0(void, advance, - __void__advance, - "", - ""); + I_MethodWithDefaults1(void, frame, IN, double, simulationTime, USE_REFERENCE_TIME, + __void__frame__double, + "Render a complete new frame. ", + "Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). "); + I_MethodWithDefaults1(void, advance, IN, double, simulationTime, USE_REFERENCE_TIME, + __void__advance__double, + "", + ""); I_Method0(void, eventTraversal, __void__eventTraversal, "", diff --git a/src/osgWrappers/osgViewer/SimpleViewer.cpp b/src/osgWrappers/osgViewer/SimpleViewer.cpp index ec357c3f1..eca7b3a4d 100644 --- a/src/osgWrappers/osgViewer/SimpleViewer.cpp +++ b/src/osgWrappers/osgViewer/SimpleViewer.cpp @@ -89,14 +89,14 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::SimpleViewer) __C5_EventHandlers_R1__getEventHandlers, "", ""); - I_Method0(void, frame, - __void__frame, - "Render a complete new frame. ", - "Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameCullTraversal() and frameDrawTraversal(). Note, no internal makeCurrent() is issued before, or swap buffers called after frame(), these operations are the responsibility of the calling code. "); - I_Method0(void, advance, - __void__advance, - "", - ""); + I_MethodWithDefaults1(void, frame, IN, double, simulationTime, USE_REFERENCE_TIME, + __void__frame__double, + "Render a complete new frame. ", + "Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameCullTraversal() and frameDrawTraversal(). Note, no internal makeCurrent() is issued before, or swap buffers called after frame(), these operations are the responsibility of the calling code. "); + I_MethodWithDefaults1(void, advance, IN, double, simulationTime, USE_REFERENCE_TIME, + __void__advance__double, + "", + ""); I_Method0(void, eventTraversal, __void__eventTraversal, "", diff --git a/src/osgWrappers/osgViewer/Viewer.cpp b/src/osgWrappers/osgViewer/Viewer.cpp index db04892c4..5740ef5cd 100644 --- a/src/osgWrappers/osgViewer/Viewer.cpp +++ b/src/osgWrappers/osgViewer/Viewer.cpp @@ -124,14 +124,14 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::Viewer) __int__run, "Execute a main frame loop. ", "Equivialant to while (!viewer.done()) viewer.frame(); Also calls realize() if the viewer is not already realized, and installs trackball manipulator if one is not already assigned."); - I_Method0(void, frame, - __void__frame, - "Render a complete new frame. ", - "Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). "); - I_Method0(void, advance, - __void__advance, - "", - ""); + I_MethodWithDefaults1(void, frame, IN, double, simulationTime, USE_REFERENCE_TIME, + __void__frame__double, + "Render a complete new frame. ", + "Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). "); + I_MethodWithDefaults1(void, advance, IN, double, simulationTime, USE_REFERENCE_TIME, + __void__advance__double, + "", + ""); I_Method0(void, eventTraversal, __void__eventTraversal, "",