Added osg::FrameStamp::set/getSimulationTime().
Added setting of osg_SimulationTime and osg_DeltaSimulationTime to the uniforms set by SceneView Added frame(double simulationTime) and advance(double simulationTime) parameters to osgViewer::SimpleViewer, Vewer and CompositeViewer. Updated various examples and Nodes to use SimulationTime where appropriate.
This commit is contained in:
parent
13dd5acb63
commit
7232a831da
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 = "<<fs.getFrameNumber()<<" "<<fs.getReferenceTime()<<std::endl;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ LightTransformCallback::operator()(Node* node, NodeVisitor* nv)
|
||||
const FrameStamp* fs = nv->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);
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
{
|
||||
osg::MatrixTransform *xform = dynamic_cast<osg::MatrixTransform *>(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);
|
||||
|
@ -524,7 +524,7 @@ class MyTransformCallback : public osg::NodeCallback
|
||||
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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_)
|
||||
{
|
||||
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ class MyGustCallback : public osg::NodeCallback
|
||||
{
|
||||
osgParticle::PrecipitationEffect* pe = dynamic_cast<osgParticle::PrecipitationEffect*>(node);
|
||||
|
||||
float value = sin(nv->getFrameStamp()->getReferenceTime());
|
||||
float value = sin(nv->getFrameStamp()->getSimulationTime());
|
||||
if (value<-0.5)
|
||||
{
|
||||
pe->snow(1.0);
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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<osg::Switch*>(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<<std::endl;
|
||||
|
||||
sw->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"<<std::endl;
|
||||
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(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()= "<<new_bin->getStateGraphList().size()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"new_bin->getRenderBinList().size()= "<<new_bin->getRenderBinList().size()<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"new_bin->getRenderLeafList().size()= "<<new_bin->getRenderLeafList().size()<<std::endl;
|
||||
|
||||
for(osgUtil::RenderBin::RenderBinList::iterator itr = new_bin->getRenderBinList().begin();
|
||||
itr != new_bin->getRenderBinList().end();
|
||||
++itr)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"bin num = "<<itr->first<<std::endl;
|
||||
}
|
||||
|
||||
cv->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<osg::Geode> 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"<<std::endl;
|
||||
|
||||
osg::StencilTwoSided* stencil = new osg::StencilTwoSided;
|
||||
stencil->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"<<std::endl;
|
||||
|
||||
osg::Stencil* stencil = new osg::Stencil;
|
||||
stencil->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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 )
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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] */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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() <<std::endl;
|
||||
// std::cout<<"update callback - post traverse"<< (float)_frameStamp->getSimulationTime() <<std::endl;
|
||||
}
|
||||
private:
|
||||
};
|
||||
@ -2066,7 +2066,7 @@ void userVars::addUserVar(const georecord &gr) {
|
||||
}
|
||||
|
||||
void internalVars::update(const osg::FrameStamp *_frameStamp) {
|
||||
double stmptime=_frameStamp->getReferenceTime();
|
||||
double stmptime=_frameStamp->getSimulationTime();
|
||||
int iord=0;
|
||||
for (std::vector<geoValue>::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() <<std::endl;
|
||||
// std::cout<<"update callback - post traverse"<< (float)_frameStamp->getSimulationTime() <<std::endl;
|
||||
}
|
||||
|
||||
void geoField::parseExt(std::ifstream &fin) const { // Feb 2003 parse onme extension fields
|
||||
|
@ -734,6 +734,7 @@ void OsgCameraGroup::sync()
|
||||
{
|
||||
double time_since_start = _timer.delta_s(_start_tick,_timer.tick());
|
||||
_frameStamp->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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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<ColorPosition> LightPointList;
|
||||
typedef std::vector<LightPointList> SizedLightPointList;
|
||||
|
@ -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);
|
||||
|
@ -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<float>(_frameStamp->getSimulationTime()));
|
||||
}
|
||||
|
||||
if ((_activeUniforms & DELTA_SIMULATION_TIME_UNIFORM) && _frameStamp.valid())
|
||||
{
|
||||
float delta_simulation_time = (_previousSimulationTime != 0.0) ? static_cast<float>(_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);
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
"",
|
||||
|
@ -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,
|
||||
"",
|
||||
|
@ -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,
|
||||
"",
|
||||
|
Loading…
Reference in New Issue
Block a user