protected void RapidUpdate()
{
if ( !RapidUpdateCustom() )
return; // Give Demo first shot at making the update
camAccel = Vector3.Zero; // reset acceleration zero
float scaleMove = 200 * inputTimer; // motion scalar
float scaleTurn = 100 * inputTimer; // turn rate scalar
// Disable Mouse Events if Right-Mouse clicked (control is given to the custom Demo)
bool mouseEn = ( !input.IsMousePressed( MouseButtons.Right ) );
// Keys that move camera. Mouse-Wheel elevates camera
if ( input.IsKeyPressed( KeyCodes.Left ) )
{
camAccel.x = -0.5f;
} // move left
if ( input.IsKeyPressed( KeyCodes.Right ) )
{
camAccel.x = 0.5f;
} // move right
if ( input.IsKeyPressed( KeyCodes.Up ) )
{
camAccel.z = -1;
} // move forward
if ( input.IsKeyPressed( KeyCodes.Down ) )
{
camAccel.z = 1;
} // move backward
if ( mouseEn )
camAccel.y += (float)( input.RelativeMouseZ * 0.1 ); // MouseWheel elevates camera
// When Mouse button pressed, Motion accelerates instead of turns camera
if ( mouseEn && input.IsMousePressed( MouseButtons.Left ) )
{
camAccel.x += input.RelativeMouseX * 0.3f; // side motion
camAccel.z += input.RelativeMouseY * 0.5f; // forward motion
}
// Calculate Camera Velocity and Location deltas
camVelocity += ( camAccel * scaleMove * camSpeed );
camera.MoveRelative( camVelocity * inputTimer );
// Now dampen the Velocity - only if user is not accelerating
if ( camAccel == Vector3.Zero )
{
camVelocity *= ( 1 - ( 4 * inputTimer ) );
}
// Keyboard arrows change Yaw/Pitch of camera
if ( input.IsKeyPressed( KeyCodes.Left ) )
{
camera.Yaw( scaleTurn );
}
if ( input.IsKeyPressed( KeyCodes.Right ) )
{
camera.Yaw( -scaleTurn );
}
if ( input.IsKeyPressed( KeyCodes.Up ) )
{
camera.Pitch( scaleTurn );
}
if ( input.IsKeyPressed( KeyCodes.Down ) )
{
camera.Pitch( -scaleTurn );
}
// Mouse motion changes Yaw/Pitch of camera
if ( mouseEn && !input.IsMousePressed( MouseButtons.Left ) )
{
camera.Yaw( -input.RelativeMouseX * 0.13f );
camera.Pitch( -input.RelativeMouseY * 0.13f );
}
} // end ReadUserMotionInputs()