OSSL_BuilIn_Commands.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 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. using System;
  28. using System.Collections.Generic;
  29. using System.Text;
  30. using libsecondlife;
  31. using OpenSim.Region.Environment.Scenes;
  32. namespace OpenSim.Region.ScriptEngine.Common
  33. {
  34. public class OSSL_BuilIn_Commands : LSL_BuiltIn_Commands, OSSL_BuilIn_Commands_Interface
  35. {
  36. public OSSL_BuilIn_Commands(ScriptEngineBase.ScriptEngine scriptEngine, SceneObjectPart host, uint localID,
  37. LLUUID itemID)
  38. : base(scriptEngine, host, localID, itemID)
  39. {
  40. Prim = new OSSLPrim(this);
  41. }
  42. public OSSLPrim Prim;
  43. [Serializable]
  44. public class OSSLPrim
  45. {
  46. internal OSSL_BuilIn_Commands OSSL;
  47. public OSSLPrim(OSSL_BuilIn_Commands bc)
  48. {
  49. OSSL = bc;
  50. Position = new OSSLPrim_Position(this);
  51. Rotation = new OSSLPrim_Rotation(this);
  52. }
  53. public OSSLPrim_Position Position;
  54. public OSSLPrim_Rotation Rotation;
  55. //public LSL_Types.Vector3 Position
  56. //{
  57. // get { return OSSL.llGetPos(); }
  58. // set { OSSL.llSetPos(value); }
  59. //}
  60. //public LSL_Types.Quaternion Rotation
  61. //{
  62. // get { return OSSL.llGetRot(); }
  63. // set { OSSL.llSetRot(value); }
  64. //}
  65. private TextStruct _text;
  66. public TextStruct Text
  67. {
  68. get { return _text; }
  69. set
  70. {
  71. _text = value;
  72. OSSL.llSetText(_text.Text, _text.color, _text.alpha);
  73. }
  74. }
  75. [Serializable]
  76. public struct TextStruct
  77. {
  78. public string Text;
  79. public LSL_Types.Vector3 color;
  80. public double alpha;
  81. }
  82. }
  83. [Serializable]
  84. public class OSSLPrim_Position
  85. {
  86. private OSSLPrim prim;
  87. private LSL_Types.Vector3 Position;
  88. public OSSLPrim_Position(OSSLPrim _prim)
  89. {
  90. prim = _prim;
  91. }
  92. private void Load()
  93. {
  94. Position = prim.OSSL.llGetPos();
  95. }
  96. private void Save()
  97. {
  98. if (Position.x > 255)
  99. Position.x = 255;
  100. if (Position.x < 0)
  101. Position.x = 0;
  102. if (Position.y > 255)
  103. Position.y = 255;
  104. if (Position.y < 0)
  105. Position.y = 0;
  106. if (Position.z > 768)
  107. Position.z = 768;
  108. if (Position.z < 0)
  109. Position.z = 0;
  110. prim.OSSL.llSetPos(Position);
  111. }
  112. public double x
  113. {
  114. get
  115. {
  116. Load();
  117. return Position.x;
  118. }
  119. set
  120. {
  121. Load();
  122. Position.x = value;
  123. Save();
  124. }
  125. }
  126. public double y
  127. {
  128. get
  129. {
  130. Load();
  131. return Position.y;
  132. }
  133. set
  134. {
  135. Load();
  136. Position.y = value;
  137. Save();
  138. }
  139. }
  140. public double z
  141. {
  142. get
  143. {
  144. Load();
  145. return Position.z;
  146. }
  147. set
  148. {
  149. Load();
  150. Position.z = value;
  151. Save();
  152. }
  153. }
  154. }
  155. [Serializable]
  156. public class OSSLPrim_Rotation
  157. {
  158. private OSSLPrim prim;
  159. private LSL_Types.Quaternion Rotation;
  160. public OSSLPrim_Rotation(OSSLPrim _prim)
  161. {
  162. prim = _prim;
  163. }
  164. private void Load()
  165. {
  166. Rotation = prim.OSSL.llGetRot();
  167. }
  168. private void Save()
  169. {
  170. prim.OSSL.llSetRot(Rotation);
  171. }
  172. public double x
  173. {
  174. get
  175. {
  176. Load();
  177. return Rotation.x;
  178. }
  179. set
  180. {
  181. Load();
  182. Rotation.x = value;
  183. Save();
  184. }
  185. }
  186. public double y
  187. {
  188. get
  189. {
  190. Load();
  191. return Rotation.y;
  192. }
  193. set
  194. {
  195. Load();
  196. Rotation.y = value;
  197. Save();
  198. }
  199. }
  200. public double z
  201. {
  202. get
  203. {
  204. Load();
  205. return Rotation.z;
  206. }
  207. set
  208. {
  209. Load();
  210. Rotation.z = value;
  211. Save();
  212. }
  213. }
  214. public double s
  215. {
  216. get
  217. {
  218. Load();
  219. return Rotation.s;
  220. }
  221. set
  222. {
  223. Load();
  224. Rotation.s = value;
  225. Save();
  226. }
  227. }
  228. }
  229. //public struct OSSLPrim_Rotation
  230. //{
  231. // public double X;
  232. // public double Y;
  233. // public double Z;
  234. // public double R;
  235. //}
  236. }
  237. }