public virtual bool frameRenderingQueued( FrameEventArgs evt )
{
if ( mStyle == CameraStyle.FreeLook )
{
// build our acceleration vector based on keyboard input composite
Vector3 accel = Vector3.Zero;
if ( mGoingForward )
accel += mCamera.Direction;
if ( mGoingBack )
accel -= mCamera.Direction;
if ( mGoingRight )
accel += mCamera.Right;
if ( mGoingLeft )
accel -= mCamera.Right;
if ( mGoingUp )
accel += mCamera.Up;
if ( mGoingDown )
accel -= mCamera.Up;
// if accelerating, try to reach top speed in a certain time
if ( accel.LengthSquared != 0 )
{
accel.Normalize();
mVelocity += accel * TopSpeed * evt.TimeSinceLastFrame * 10;
}
// if not accelerating, try to stop in a certain time
else
mVelocity -= mVelocity * evt.TimeSinceLastFrame * 10;
// keep camera velocity below top speed and above zero
if ( mVelocity.LengthSquared > TopSpeed * TopSpeed )
{
mVelocity.Normalize();
mVelocity *= TopSpeed;
}
else if ( mVelocity.LengthSquared < 0.1 )
mVelocity = Vector3.Zero;
if ( mVelocity != Vector3.Zero )
mCamera.Move( mVelocity * evt.TimeSinceLastFrame );
}
return true;
}