28 #include "boost/date_time/posix_time/posix_time.hpp"
30 #include "WGEShaderAnimationCallback.h"
33 osg::Uniform::Callback(),
34 m_start( boost::posix_time::microsec_clock::local_time() ),
35 m_ticksPerSec( ticksPerSecond ),
36 m_tickMillisecRatio( static_cast< double >( ticksPerSecond ) / 1000.0 )
51 boost::posix_time::ptime t = boost::posix_time::microsec_clock::local_time();
53 boost::posix_time::time_duration td = t -
m_start;
54 int ticks =
static_cast< int >(
static_cast< double >( td.total_milliseconds() ) *
m_tickMillisecRatio );
56 uniform->set( ticks );
boost::posix_time::ptime m_start
Timer that stops the time hopefully OS independent.
WGEShaderAnimationCallback(int ticksPerSecond=100)
Default constructor.
virtual void operator()(osg::Uniform *uniform, osg::NodeVisitor *nv)
Operator called on uniform update.
virtual ~WGEShaderAnimationCallback()
Destructor.
double m_tickMillisecRatio
Ratio between milliseconds and m_ticksPerSec.