// virtual touchdown points
#define TP_YDIST (3.25f)
#define TP_ZDIST (8.25f)
#define TP_ZBACK (8.25f)
#define TP_X (8.25f)
#define TP1_INIT _V(0,-TP_YDIST,TP_ZDIST)
#define TP2_INIT _V(-TP_X,-TP_YDIST,-TP_ZBACK)
#define TP3_INIT _V(TP_X,-TP_YDIST,-TP_ZBACK)
#define INITIAL_COG _V(0,TP_YDIST,0) // initial distance of COG from feet
void Eaglet::clbkPostStep( double simt, double simdt, double mjd )
{
double theta ;
double dunsel ;
if( running )
{
anim_step += ANIM_SPEED * simdt ;
if( anim_step > 1.0f )
{
// end of loop
anim_step = 0.0 ; // trim value
running = false ;
ordered_to_sit = false ;
cog = INITIAL_COG ;
tp1 = TP1_INIT ;
tp2 = TP2_INIT ;
tp3 = TP3_INIT ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
else
{
if( anim_step >= 0.75f )
{
if( ordered_to_sit )
{
// done spinning back, ready to sit
cog.y = INITIAL_COG.y + ((1-anim_step)*20.f) ;
tp1.y = tp2.y = tp3.y = -cog.y ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
else
{
// ready to sit
anim_step = 0.75 ; // trim value
running = false ; // stop any animation activity
ordered_to_spun = false ;
tp1.y = tp2.y = tp3.y = -cog.y ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
}
else
{
if( anim_step >= 0.5f )
{
if( ordered_to_spun )
{
theta = (anim_step-0.5f)*(launch_angle*4) ;
theta = launch_angle - theta ;
if( theta >= MAX_LA )
{
theta = MAX_LA ;
}
tp2.y = tp3.y = -cog.y ;
tp1.y = - ( cog.y + ( (TP_ZDIST+TP_ZBACK) * tan(theta) ) ) ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
else
{
anim_step = 0.5 ; // trim value
running = false ; // stop any animation activity
ordered_to_spin = false ;
theta = launch_angle ;
dunsel = ((TP_ZDIST+TP_ZBACK) * tan(theta)) ;
tp2.y = tp3.y = -cog.y + gammar*dunsel ;
tp1.y = - cog.y - ((1-gammar)*dunsel );
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
}
else
{
if( anim_step >= 0.25f )
{
if( ordered_to_spin )
{
theta = (anim_step-0.25f)*(launch_angle*4) ;
if( theta >= MAX_LA )
{
theta = MAX_LA ;
}
dunsel = ((TP_ZDIST+TP_ZBACK) * tan(theta)) ;
tp2.y = tp3.y = -cog.y + gammar*dunsel ;
tp1.y = - cog.y - ((1-gammar)*dunsel );
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
else
{
anim_step = 0.25 ; // trim value
running = false ;
ordered_to_stand = false ; // ready to spin
cog.y = 8.25 ;
tp1.y = tp2.y = tp3.y = -cog.y ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
}
else
{
if( ordered_to_stand )
{
// standing up
cog.y = INITIAL_COG.y + (anim_step*20.f) ;
tp1.y = tp2.y = tp3.y = -cog.y ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
else
{
// why running but not doing anything?
// REBOOT ANIMATION
anim_step = 0 ;
cog = INITIAL_COG ;
running = false ; // any animation activity
ordered_to_stand = false ;
ordered_to_sit = false ;
ordered_to_spin = false ;
ordered_to_spun = false ;
tp1 = TP1_INIT ;
tp2 = TP2_INIT ;
tp3 = TP3_INIT ;
SetTouchdownPoints( tp1, tp2, tp3 ) ;
}
}
}
}
}
SetAnimation( anim_launch, anim_step ) ; // use trimmed value of anim_step
}
return ;
}