PhysXPrim.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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. using System;
  28. using System.Collections.Generic;
  29. using Nini.Config;
  30. using OpenSim.Framework;
  31. using OpenSim.Region.Physics.Manager;
  32. using PhysXWrapper;
  33. using Quaternion=OpenMetaverse.Quaternion;
  34. using System.Reflection;
  35. using log4net;
  36. using OpenMetaverse;
  37. namespace OpenSim.Region.Physics.PhysXPlugin
  38. {
  39. public class PhysXPrim : PhysicsActor
  40. {
  41. private Vector3 _velocity;
  42. private Vector3 _acceleration;
  43. private Vector3 m_rotationalVelocity;
  44. private NxActor _prim;
  45. public PhysXPrim(NxActor prim)
  46. {
  47. _velocity = Vector3.Zero;
  48. _acceleration = Vector3.Zero;
  49. _prim = prim;
  50. }
  51. public override int PhysicsActorType
  52. {
  53. get { return (int) ActorTypes.Prim; }
  54. set { return; }
  55. }
  56. public override bool IsPhysical
  57. {
  58. get { return false; }
  59. set { return; }
  60. }
  61. public override bool SetAlwaysRun
  62. {
  63. get { return false; }
  64. set { return; }
  65. }
  66. public override uint LocalID
  67. {
  68. set { return; }
  69. }
  70. public override bool Grabbed
  71. {
  72. set { return; }
  73. }
  74. public override bool Selected
  75. {
  76. set { return; }
  77. }
  78. public override float Buoyancy
  79. {
  80. get { return 0f; }
  81. set { return; }
  82. }
  83. public override bool FloatOnWater
  84. {
  85. set { return; }
  86. }
  87. public override bool ThrottleUpdates
  88. {
  89. get { return false; }
  90. set { return; }
  91. }
  92. public override Vector3 RotationalVelocity
  93. {
  94. get { return m_rotationalVelocity; }
  95. set { m_rotationalVelocity = value; }
  96. }
  97. public override bool Flying
  98. {
  99. get { return false; //no flying prims for you
  100. }
  101. set { }
  102. }
  103. public override bool IsColliding
  104. {
  105. get { return false; }
  106. set { }
  107. }
  108. public override bool CollidingGround
  109. {
  110. get { return false; }
  111. set { return; }
  112. }
  113. public override bool CollidingObj
  114. {
  115. get { return false; }
  116. set { return; }
  117. }
  118. public override bool Stopped
  119. {
  120. get { return false; }
  121. }
  122. public override Vector3 Position
  123. {
  124. get
  125. {
  126. Vector3 pos = Vector3.Zero;
  127. Vec3 vec = _prim.Position;
  128. pos.X = vec.X;
  129. pos.Y = vec.Y;
  130. pos.Z = vec.Z;
  131. return pos;
  132. }
  133. set
  134. {
  135. Vector3 vec = value;
  136. Vec3 pos = new Vec3();
  137. pos.X = vec.X;
  138. pos.Y = vec.Y;
  139. pos.Z = vec.Z;
  140. _prim.Position = pos;
  141. }
  142. }
  143. public override PrimitiveBaseShape Shape
  144. {
  145. set { return; }
  146. }
  147. public override Vector3 Velocity
  148. {
  149. get { return _velocity; }
  150. set { _velocity = value; }
  151. }
  152. public override Vector3 Torque
  153. {
  154. get { return Vector3.Zero; }
  155. set { return; }
  156. }
  157. public override float CollisionScore
  158. {
  159. get { return 0f; }
  160. set { }
  161. }
  162. public override bool Kinematic
  163. {
  164. get { return _prim.Kinematic; }
  165. set { _prim.Kinematic = value; }
  166. }
  167. public override Quaternion Orientation
  168. {
  169. get
  170. {
  171. Quaternion res;
  172. PhysXWrapper.Quaternion quat = _prim.GetOrientation();
  173. res.W = quat.W;
  174. res.X = quat.X;
  175. res.Y = quat.Y;
  176. res.Z = quat.Z;
  177. return res;
  178. }
  179. set { }
  180. }
  181. public override Vector3 Acceleration
  182. {
  183. get { return _acceleration; }
  184. }
  185. public void SetAcceleration(Vector3 accel)
  186. {
  187. _acceleration = accel;
  188. }
  189. public override void AddForce(Vector3 force, bool pushforce)
  190. {
  191. }
  192. public override void AddAngularForce(Vector3 force, bool pushforce)
  193. {
  194. }
  195. public override void SetMomentum(Vector3 momentum)
  196. {
  197. }
  198. public override Vector3 Size
  199. {
  200. get { return Vector3.Zero; }
  201. set { }
  202. }
  203. public override void link(PhysicsActor obj)
  204. {
  205. }
  206. public override void delink()
  207. {
  208. }
  209. public override void LockAngularMotion(Vector3 axis)
  210. {
  211. }
  212. public override float Mass
  213. {
  214. get { return 0f; }
  215. }
  216. public override Vector3 Force
  217. {
  218. get { return Vector3.Zero; }
  219. set { return; }
  220. }
  221. public override int VehicleType
  222. {
  223. get { return 0; }
  224. set { return; }
  225. }
  226. public override void VehicleFloatParam(int param, float value)
  227. {
  228. }
  229. public override void VehicleVectorParam(int param, Vector3 value)
  230. {
  231. }
  232. public override void VehicleRotationParam(int param, Quaternion rotation)
  233. {
  234. }
  235. public override void VehicleFlags(int param, bool remove) { }
  236. public override void SetVolumeDetect(int param)
  237. {
  238. }
  239. public override Vector3 CenterOfMass
  240. {
  241. get { return Vector3.Zero; }
  242. }
  243. public override Vector3 GeometricCenter
  244. {
  245. get { return Vector3.Zero; }
  246. }
  247. public override void CrossingFailure()
  248. {
  249. }
  250. public override Vector3 PIDTarget { set { return; } }
  251. public override bool PIDActive { set { return; } }
  252. public override float PIDTau { set { return; } }
  253. public override float PIDHoverHeight { set { return; } }
  254. public override bool PIDHoverActive { set { return; } }
  255. public override PIDHoverType PIDHoverType { set { return; } }
  256. public override float PIDHoverTau { set { return; } }
  257. public override Quaternion APIDTarget
  258. {
  259. set { return; }
  260. }
  261. public override bool APIDActive
  262. {
  263. set { return; }
  264. }
  265. public override float APIDStrength
  266. {
  267. set { return; }
  268. }
  269. public override float APIDDamping
  270. {
  271. set { return; }
  272. }
  273. public override void SubscribeEvents(int ms)
  274. {
  275. }
  276. public override void UnSubscribeEvents()
  277. {
  278. }
  279. public override bool SubscribedEvents()
  280. {
  281. return false;
  282. }
  283. }
  284. }