1
0

IObject.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 UUID of the Owner of the Object.
  89. /// </summary>
  90. UUID OwnerId { get; }
  91. /// <summary>
  92. /// Returns the UUID of the Creator of the Object.
  93. /// </summary>
  94. UUID CreatorId { get; }
  95. /// <summary>
  96. /// Returns the root object of a linkset. If this object is the root, it will return itself.
  97. /// </summary>
  98. IObject Root { get; }
  99. /// <summary>
  100. /// Returns a collection of objects which are linked to the current object. Does not include the root object.
  101. /// </summary>
  102. IObject[] Children { get; }
  103. /// <summary>
  104. /// Returns a list of materials attached to this object. Each may contain unique texture
  105. /// and other visual information. For primitive based objects, this correlates with
  106. /// Object Faces. For mesh based objects, this correlates with Materials.
  107. /// </summary>
  108. IObjectMaterial[] Materials { get; }
  109. /// <summary>
  110. /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds.
  111. /// </summary>
  112. Vector3 Scale { get; set; }
  113. /// <summary>
  114. /// The rotation of the object relative to the Scene
  115. /// </summary>
  116. Quaternion WorldRotation { get; set; }
  117. /// <summary>
  118. /// The rotation of the object relative to a parent object
  119. /// If root, works the same as WorldRotation
  120. /// </summary>
  121. Quaternion OffsetRotation { get; set; }
  122. /// <summary>
  123. /// The position of the object relative to a parent object
  124. /// If root, works the same as WorldPosition
  125. /// </summary>
  126. Vector3 OffsetPosition { get; set; }
  127. Vector3 SitTarget { get; set; }
  128. String SitTargetText { get; set; }
  129. String TouchText { get; set; }
  130. /// <summary>
  131. /// Text to be associated with this object, in the
  132. /// Second Life(r) viewer, this is shown above the
  133. /// object.
  134. /// </summary>
  135. String Text { get; set; }
  136. bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X)
  137. bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y)
  138. bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z)
  139. bool IsSandboxed { get; set; } // SetStatus(SANDBOX)
  140. bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB)
  141. bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE)
  142. bool IsTemporary { get; set; } // TEMP_ON_REZ
  143. bool IsFlexible { get; set; }
  144. IObjectShape Shape { get; }
  145. // TODO:
  146. // PrimHole
  147. // Repeats, Offsets, Cut/Dimple/ProfileCut
  148. // Hollow, Twist, HoleSize,
  149. // Taper[A+B], Shear[A+B], Revolutions,
  150. // RadiusOffset, Skew
  151. PhysicsMaterial PhysicsMaterial { get; set; }
  152. IObjectPhysics Physics { get; }
  153. IObjectSound Sound { get; }
  154. /// <summary>
  155. /// Causes the object to speak to its surroundings,
  156. /// equivilent to LSL/OSSL llSay
  157. /// </summary>
  158. /// <param name="msg">The message to send to the user</param>
  159. void Say(string msg);
  160. /// <summary>
  161. /// Causes the object to speak to on a specific channel,
  162. /// equivilent to LSL/OSSL llSay
  163. /// </summary>
  164. /// <param name="msg">The message to send to the user</param>
  165. /// <param name="channel">The channel on which to send the message</param>
  166. void Say(string msg,int channel);
  167. /// <summary>
  168. /// Opens a Dialog Panel in the Users Viewer,
  169. /// equivilent to LSL/OSSL llDialog
  170. /// </summary>
  171. /// <param name="avatar">The UUID of the Avatar to which the Dialog should be send</param>
  172. /// <param name="message">The Message to display at the top of the Dialog</param>
  173. /// <param name="buttons">The Strings that act as label/value of the Bottons in the Dialog</param>
  174. /// <param name="chat_channel">The channel on which to send the response</param>
  175. void Dialog(UUID avatar, string message, string[] buttons, int chat_channel);
  176. //// <value>
  177. /// Grants access to the objects inventory
  178. /// </value>
  179. IObjectInventory Inventory { get; }
  180. }
  181. public enum PhysicsMaterial
  182. {
  183. Default,
  184. Glass,
  185. Metal,
  186. Plastic,
  187. Wood,
  188. Rubber,
  189. Stone,
  190. Flesh
  191. }
  192. public enum TextureMapping
  193. {
  194. Default,
  195. Planar
  196. }
  197. public interface IObjectMaterial
  198. {
  199. Color Color { get; set; }
  200. UUID Texture { get; set; }
  201. TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN)
  202. bool Bright { get; set; } // SetPrimParms(FULLBRIGHT)
  203. double Bloom { get; set; } // SetPrimParms(GLOW)
  204. bool Shiny { get; set; } // SetPrimParms(SHINY)
  205. bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECATE IN FAVOUR OF UUID?]
  206. }
  207. }