}
// Keep resetting sim time while the sim is initializing
globals->set_sim_time_sec( 0.0 );
+ Animation::set_sim_time_sec( 0.0 );
} else {
// idle_state is now 1000 meaning we've finished all our
// initializations and are running the main loop, so this will
delta_time_sec = 0;
last_time_stamp = current_time_stamp;
globals->inc_sim_time_sec( delta_time_sec );
+ Animation::set_sim_time_sec( globals->get_sim_time_sec() );
static long remainder = 0;
long elapsed;
SGTime *t = globals->get_time_params();
sglog().setLogLevels( SG_ALL, (sgDebugPriority)fgGetInt("/sim/log-level") );
+ sglog().setLogLevels( SG_ALL, SG_INFO );
FGLocation * acmodel_location = 0;
if(cur_fdm_state->getACModel() != 0) {
// Implementation of Animation
////////////////////////////////////////////////////////////////////////
+// Initialize the static data member
+double Animation::sim_time_sec = 0.0;
+
Animation::Animation (SGPropertyNode_ptr props, ssgBranch * branch)
: _branch(branch)
{
}
void
-Animation::update ()
+Animation::update()
{
}
}
void
-SelectAnimation::update ()
+SelectAnimation::update()
{
if (_condition != 0 && _condition->test())
((ssgSelector *)_branch)->select(0xffff);
_prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
_factor(props->getDoubleValue("factor", 1.0)),
_position_deg(props->getDoubleValue("starting-position-deg", 0)),
- _last_time_sec( sim_time_sec /* globals->get_sim_time_sec() */ )
+ _last_time_sec( sim_time_sec )
{
_center[0] = props->getFloatValue("center/x-m", 0);
_center[1] = props->getFloatValue("center/y-m", 0);
}
void
-SpinAnimation::update( double sim_time_sec )
+SpinAnimation::update()
{
double dt = sim_time_sec - _last_time_sec;
_last_time_sec = sim_time_sec;
}
void
-TimedAnimation::update( double sim_time_sec )
+TimedAnimation::update()
{
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
_last_time_sec = sim_time_sec;
}
void
-TranslateAnimation::update ()
+TranslateAnimation::update()
{
if (_table == 0) {
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
* instead, they should use the FGModelLoader declared in loader.hxx.
*/
ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
- SGPropertyNode *prop_root,
- double sim_time_sec );
+ SGPropertyNode *prop_root, double sim_time_sec );
\f
/**
* Update the animation.
*/
- virtual void update ();
+ virtual void update();
+
+ /**
+ * Set the value of sim_time_sec. This needs to be called every
+ * frame in order for the time based animations to work correctly.
+ */
+ static void set_sim_time_sec( double val ) { sim_time_sec = val; }
protected:
+ static double sim_time_sec;
+
ssgBranch * _branch;
};
SelectAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
virtual ~SelectAnimation ();
- virtual void update ();
+ virtual void update();
private:
FGCondition * _condition;
};
SGPropertyNode_ptr props,
double sim_time_sec );
virtual ~SpinAnimation ();
- virtual void update( double sim_time_sec );
+ virtual void update();
private:
SGPropertyNode_ptr _prop;
double _factor;
public:
TimedAnimation (SGPropertyNode_ptr props);
virtual ~TimedAnimation ();
- virtual void update( double sim_time_sec );
+ virtual void update();
private:
double _duration_sec;
double _last_time_sec;
TranslateAnimation( SGPropertyNode *prop_root,
SGPropertyNode_ptr props );
virtual ~TranslateAnimation ();
- virtual void update ();
+ virtual void update();
private:
SGPropertyNode_ptr _prop;
double _offset_m;