protected override void OnFrameStarted( object source, FrameEventArgs evt )
{
animTime += evt.TimeSinceLastFrame;
while ( animTime > FISH_PATH_LENGTH )
{
animTime -= FISH_PATH_LENGTH;
}
for ( int i = 0; i < NUM_FISH; i++ )
{
// animate the fish
fishAnimations[ i ].AddTime( evt.TimeSinceLastFrame );
// move the fish
Vector3 newPos = fishSplines[ i ].Interpolate( animTime / FISH_PATH_LENGTH );
fishNodes[ i ].Position = newPos;
// work out the moving direction
Vector3 direction = fishLastPosition[ i ] - newPos;
direction.Normalize();
Quaternion orientation = -Vector3.UnitX.GetRotationTo( direction );
fishNodes[ i ].Orientation = orientation;
fishLastPosition[ i ] = newPos;
}
base.OnFrameStarted( source, evt );
}