1
0

IObject.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.Drawing;
  29. using OpenMetaverse;
  30. using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object;
  31. namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
  32. {
  33. [Serializable]
  34. public class TouchEventArgs : EventArgs
  35. {
  36. public IAvatar Avatar;
  37. public Vector3 TouchBiNormal;
  38. public Vector3 TouchNormal;
  39. public Vector3 TouchPosition;
  40. public Vector2 TouchUV;
  41. public Vector2 TouchST;
  42. public int TouchMaterialIndex;
  43. }
  44. public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e);
  45. public interface IObject : IEntity
  46. {
  47. #region Events
  48. event OnTouchDelegate OnTouch;
  49. #endregion
  50. /// <summary>
  51. /// Returns whether or not this object is still in the world.
  52. /// Eg, if you store an IObject reference, however the object
  53. /// is deleted before you use it, it will throw a NullReference
  54. /// exception. 'Exists' allows you to check the object is still
  55. /// in play before utilizing it.
  56. /// </summary>
  57. /// <example>
  58. /// IObject deleteMe = World.Objects[0];
  59. ///
  60. /// if (deleteMe.Exists) {
  61. /// deleteMe.Say("Hello, I still exist!");
  62. /// }
  63. ///
  64. /// World.Objects.Remove(deleteMe);
  65. ///
  66. /// if (!deleteMe.Exists) {
  67. /// Host.Console.Info("I was deleted");
  68. /// }
  69. /// </example>
  70. /// <remarks>
  71. /// Objects should be near-guarunteed to exist for any event which
  72. /// passes them as an argument. Storing an object for a longer period
  73. /// of time however will limit their reliability.
  74. ///
  75. /// It is a good practice to use Try/Catch blocks handling for
  76. /// NullReferenceException, when accessing remote objects.
  77. /// </remarks>
  78. bool Exists { get; }
  79. /// <summary>
  80. /// The local region-unique ID for this object.
  81. /// </summary>
  82. uint LocalID { get; }
  83. /// <summary>
  84. /// The description assigned to this object.
  85. /// </summary>
  86. String Description { get; set; }
  87. /// <summary>
  88. /// Returns the root object of a linkset. If this object is the root, it will return itself.
  89. /// </summary>
  90. IObject Root { get; }
  91. /// <summary>
  92. /// Returns a collection of objects which are linked to the current object. Does not include the root object.
  93. /// </summary>
  94. IObject[] Children { get; }
  95. /// <summary>
  96. /// Returns a list of materials attached to this object. Each may contain unique texture
  97. /// and other visual information. For primitive based objects, this correlates with
  98. /// Object Faces. For mesh based objects, this correlates with Materials.
  99. /// </summary>
  100. IObjectMaterial[] Materials { get; }
  101. /// <summary>
  102. /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds.
  103. /// </summary>
  104. Vector3 Scale { get; set; }
  105. /// <summary>
  106. /// The rotation of the object relative to the Scene
  107. /// </summary>
  108. Quaternion WorldRotation { get; set; }
  109. /// <summary>
  110. /// The rotation of the object relative to a parent object
  111. /// If root, works the same as WorldRotation
  112. /// </summary>
  113. Quaternion OffsetRotation { get; set; }
  114. /// <summary>
  115. /// The position of the object relative to a parent object
  116. /// If root, works the same as WorldPosition
  117. /// </summary>
  118. Vector3 OffsetPosition { get; set; }
  119. Vector3 SitTarget { get; set; }
  120. String SitTargetText { get; set; }
  121. String TouchText { get; set; }
  122. /// <summary>
  123. /// Text to be associated with this object, in the
  124. /// Second Life(r) viewer, this is shown above the
  125. /// object.
  126. /// </summary>
  127. String Text { get; set; }
  128. bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X)
  129. bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y)
  130. bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z)
  131. bool IsSandboxed { get; set; } // SetStatus(SANDBOX)
  132. bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB)
  133. bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE)
  134. bool IsTemporary { get; set; } // TEMP_ON_REZ
  135. bool IsFlexible { get; set; }
  136. IObjectShape Shape { get; }
  137. // TODO:
  138. // PrimHole
  139. // Repeats, Offsets, Cut/Dimple/ProfileCut
  140. // Hollow, Twist, HoleSize,
  141. // Taper[A+B], Shear[A+B], Revolutions,
  142. // RadiusOffset, Skew
  143. PhysicsMaterial PhysicsMaterial { get; set; }
  144. IObjectPhysics Physics { get; }
  145. IObjectSound Sound { get; }
  146. /// <summary>
  147. /// Causes the object to speak to its surroundings,
  148. /// equivilent to LSL/OSSL llSay
  149. /// </summary>
  150. /// <param name="msg">The message to send to the user</param>
  151. void Say(string msg);
  152. //// <value>
  153. /// Grants access to the objects inventory
  154. /// </value>
  155. IObjectInventory Inventory { get; }
  156. }
  157. public enum PhysicsMaterial
  158. {
  159. Default,
  160. Glass,
  161. Metal,
  162. Plastic,
  163. Wood,
  164. Rubber,
  165. Stone,
  166. Flesh
  167. }
  168. public enum TextureMapping
  169. {
  170. Default,
  171. Planar
  172. }
  173. public interface IObjectMaterial
  174. {
  175. Color Color { get; set; }
  176. UUID Texture { get; set; }
  177. TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN)
  178. bool Bright { get; set; } // SetPrimParms(FULLBRIGHT)
  179. double Bloom { get; set; } // SetPrimParms(GLOW)
  180. bool Shiny { get; set; } // SetPrimParms(SHINY)
  181. bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECATE IN FAVOUR OF UUID?]
  182. }
  183. }