コード例 #1
0
 /// <summary>
 /// Add a friction force to a body.
 /// </summary>
 /// <param name="f">The friction force to add.</param>
 private void AddFrictionForce(Force f)
 {
     // Try this.
     try
     {
         // ////////////////////////////////////////////////////////
         // System.out.println(this + ": The Friction: (" + f.getForce().toString() + ")");
         // Calculate the Friction.
         Vector3 friction = f.Body.Velocity + f.Velocity;
         // ////////////////////////////////////////////////////////
         // System.out.println(this + ": Old Velocity: (" + f.body.velocity.toString() + ")");
         // Clam the friction above or beneath zero and subtract it from the velocity.
         Vector3 v = Vector3.Clamp(f.Body.Velocity, Vector3.Zero, friction);
         v.Z = f.Body.Velocity.Z;
         f.Body.Velocity = v;
         // ////////////////////////////////////////////////////////
         // System.out.println(this + ": Velocity with applied Friction: (" + friction.toString() + ")");
         // System.out.println(this + ": ----------------------------------------------------------------------------");
     }
     // Catch the exception.
     catch (Exception e) { Console.WriteLine(this + ": Adding Friction Force to Body Error. (" + e + ")"); }
 }
コード例 #2
0
 /// <summary>
 /// Add a force to the physics simulator.
 /// </summary>
 /// <param name="force">The force to add.</param>
 public void AddForce(Force force)
 {
     // Try to add the Force at the end of the list.
     try
     {
         _Forces.Add(force);
     }
     // Catch the exception and display relevant information.
     catch (Exception e)
     {
         Console.WriteLine(this + ": Error adding force. (" + e + ")");
     }
 }