PhysicsActor.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright (c) Contributors, http://www.openmetaverse.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. using Axiom.Math;
  29. namespace OpenSim.Physics.Manager
  30. {
  31. public delegate void PositionUpdate(PhysicsVector position);
  32. public delegate void VelocityUpdate(PhysicsVector velocity);
  33. public delegate void OrientationUpdate(Quaternion orientation);
  34. public abstract class PhysicsActor
  35. {
  36. public event PositionUpdate OnPositionUpdate;
  37. public event VelocityUpdate OnVelocityUpdate;
  38. public event OrientationUpdate OnOrientationUpdate;
  39. public static PhysicsActor Null
  40. {
  41. get
  42. {
  43. return new NullPhysicsActor();
  44. }
  45. }
  46. public abstract PhysicsVector Position
  47. {
  48. get;
  49. set;
  50. }
  51. public abstract PhysicsVector Velocity
  52. {
  53. get;
  54. set;
  55. }
  56. public abstract PhysicsVector Acceleration
  57. {
  58. get;
  59. }
  60. public abstract Quaternion Orientation
  61. {
  62. get;
  63. set;
  64. }
  65. public abstract bool Flying
  66. {
  67. get;
  68. set;
  69. }
  70. public abstract bool Kinematic
  71. {
  72. get;
  73. set;
  74. }
  75. public abstract void AddForce(PhysicsVector force);
  76. public abstract void SetMomentum(PhysicsVector momentum);
  77. }
  78. public class NullPhysicsActor : PhysicsActor
  79. {
  80. public override PhysicsVector Position
  81. {
  82. get
  83. {
  84. return PhysicsVector.Zero;
  85. }
  86. set
  87. {
  88. return;
  89. }
  90. }
  91. public override PhysicsVector Velocity
  92. {
  93. get
  94. {
  95. return PhysicsVector.Zero;
  96. }
  97. set
  98. {
  99. return;
  100. }
  101. }
  102. public override Quaternion Orientation
  103. {
  104. get
  105. {
  106. return Quaternion.Identity;
  107. }
  108. set
  109. {
  110. }
  111. }
  112. public override PhysicsVector Acceleration
  113. {
  114. get { return PhysicsVector.Zero; }
  115. }
  116. public override bool Flying
  117. {
  118. get
  119. {
  120. return false;
  121. }
  122. set
  123. {
  124. return;
  125. }
  126. }
  127. public override bool Kinematic
  128. {
  129. get
  130. {
  131. return true;
  132. }
  133. set
  134. {
  135. return;
  136. }
  137. }
  138. public override void AddForce(PhysicsVector force)
  139. {
  140. return;
  141. }
  142. public override void SetMomentum(PhysicsVector momentum)
  143. {
  144. return;
  145. }
  146. }
  147. }