1
0
Fork 0

Timed animations now working again.

This commit is contained in:
curt 2003-05-08 15:56:31 +00:00
parent 677ec873be
commit b85ff8c210
3 changed files with 26 additions and 13 deletions

View file

@ -497,6 +497,7 @@ void fgRenderFrame() {
}
// 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
@ -1024,6 +1025,7 @@ static void fgMainLoop( void ) {
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;
@ -1038,6 +1040,7 @@ static void fgMainLoop( void ) {
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) {

View file

@ -349,6 +349,9 @@ fgLoad3DModel( const string &fg_root, const string &path,
// Implementation of Animation
////////////////////////////////////////////////////////////////////////
// Initialize the static data member
double Animation::sim_time_sec = 0.0;
Animation::Animation (SGPropertyNode_ptr props, ssgBranch * branch)
: _branch(branch)
{
@ -461,7 +464,7 @@ SpinAnimation::SpinAnimation( SGPropertyNode *prop_root,
_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);
@ -477,7 +480,7 @@ SpinAnimation::~SpinAnimation ()
}
void
SpinAnimation::update( double sim_time_sec )
SpinAnimation::update()
{
double dt = sim_time_sec - _last_time_sec;
_last_time_sec = sim_time_sec;
@ -511,7 +514,7 @@ TimedAnimation::~TimedAnimation ()
}
void
TimedAnimation::update( double sim_time_sec )
TimedAnimation::update()
{
if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
_last_time_sec = sim_time_sec;

View file

@ -53,8 +53,7 @@ class FGLocation;
* 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 );
@ -88,8 +87,16 @@ public:
*/
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;
};
@ -155,7 +162,7 @@ public:
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;
@ -175,7 +182,7 @@ class TimedAnimation : public Animation
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;