OSSL_Stub.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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.Runtime.Remoting.Lifetime;
  29. using System.Threading;
  30. using System.Reflection;
  31. using System.Collections;
  32. using System.Collections.Generic;
  33. using OpenSim.Framework;
  34. using OpenSim.Region.Framework.Interfaces;
  35. using OpenSim.Region.ScriptEngine.Interfaces;
  36. using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
  37. using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  38. using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  39. using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  40. using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  41. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  42. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  43. using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
  44. using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  45. namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
  46. {
  47. public partial class ScriptBaseClass : MarshalByRefObject
  48. {
  49. public IOSSL_Api m_OSSL_Functions;
  50. public void ApiTypeOSSL(IScriptApi api)
  51. {
  52. if (!(api is IOSSL_Api))
  53. return;
  54. m_OSSL_Functions = (IOSSL_Api)api;
  55. Prim = new OSSLPrim(this);
  56. }
  57. public void osSetRegionWaterHeight(double height)
  58. {
  59. m_OSSL_Functions.osSetRegionWaterHeight(height);
  60. }
  61. public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
  62. {
  63. m_OSSL_Functions.osSetRegionSunSettings(useEstateSun, sunFixed, sunHour);
  64. }
  65. public void osSetEstateSunSettings(bool sunFixed, double sunHour)
  66. {
  67. m_OSSL_Functions.osSetEstateSunSettings(sunFixed, sunHour);
  68. }
  69. public double osGetCurrentSunHour()
  70. {
  71. return m_OSSL_Functions.osGetCurrentSunHour();
  72. }
  73. public double osSunGetParam(string param)
  74. {
  75. return m_OSSL_Functions.osSunGetParam(param);
  76. }
  77. public void osSunSetParam(string param, double value)
  78. {
  79. m_OSSL_Functions.osSunSetParam(param, value);
  80. }
  81. public string osWindActiveModelPluginName()
  82. {
  83. return m_OSSL_Functions.osWindActiveModelPluginName();
  84. }
  85. // Not yet plugged in as available OSSL functions, so commented out
  86. // void osWindParamSet(string plugin, string param, float value)
  87. // {
  88. // m_OSSL_Functions.osWindParamSet(plugin, param, value);
  89. // }
  90. //
  91. // float osWindParamGet(string plugin, string param)
  92. // {
  93. // return m_OSSL_Functions.osWindParamGet(plugin, param);
  94. // }
  95. public double osList2Double(LSL_Types.list src, int index)
  96. {
  97. return m_OSSL_Functions.osList2Double(src, index);
  98. }
  99. public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
  100. int timer)
  101. {
  102. return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
  103. }
  104. public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
  105. int timer)
  106. {
  107. return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
  108. }
  109. public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
  110. int timer, int alpha)
  111. {
  112. return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
  113. }
  114. public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
  115. int timer, int alpha)
  116. {
  117. return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
  118. }
  119. public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams,
  120. bool blend, int disp, int timer, int alpha, int face)
  121. {
  122. return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams,
  123. blend, disp, timer, alpha, face);
  124. }
  125. public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams,
  126. bool blend, int disp, int timer, int alpha, int face)
  127. {
  128. return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams,
  129. blend, disp, timer, alpha, face);
  130. }
  131. public LSL_Float osTerrainGetHeight(int x, int y)
  132. {
  133. return m_OSSL_Functions.osTerrainGetHeight(x, y);
  134. }
  135. public LSL_Integer osTerrainSetHeight(int x, int y, double val)
  136. {
  137. return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
  138. }
  139. public void osTerrainFlush()
  140. {
  141. m_OSSL_Functions.osTerrainFlush();
  142. }
  143. public int osRegionRestart(double seconds)
  144. {
  145. return m_OSSL_Functions.osRegionRestart(seconds);
  146. }
  147. public void osRegionNotice(string msg)
  148. {
  149. m_OSSL_Functions.osRegionNotice(msg);
  150. }
  151. public bool osConsoleCommand(string Command)
  152. {
  153. return m_OSSL_Functions.osConsoleCommand(Command);
  154. }
  155. public void osSetParcelMediaURL(string url)
  156. {
  157. m_OSSL_Functions.osSetParcelMediaURL(url);
  158. }
  159. public void osSetPrimFloatOnWater(int floatYN)
  160. {
  161. m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
  162. }
  163. // Teleport Functions
  164. public void osTeleportAgent(string agent, string regionName, vector position, vector lookat)
  165. {
  166. m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
  167. }
  168. public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat)
  169. {
  170. m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat);
  171. }
  172. public void osTeleportAgent(string agent, vector position, vector lookat)
  173. {
  174. m_OSSL_Functions.osTeleportAgent(agent, position, lookat);
  175. }
  176. // Avatar info functions
  177. public string osGetAgentIP(string agent)
  178. {
  179. return m_OSSL_Functions.osGetAgentIP(agent);
  180. }
  181. public LSL_List osGetAgents()
  182. {
  183. return m_OSSL_Functions.osGetAgents();
  184. }
  185. // Animation Functions
  186. public void osAvatarPlayAnimation(string avatar, string animation)
  187. {
  188. m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
  189. }
  190. public void osAvatarStopAnimation(string avatar, string animation)
  191. {
  192. m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
  193. }
  194. //Texture Draw functions
  195. public string osMovePen(string drawList, int x, int y)
  196. {
  197. return m_OSSL_Functions.osMovePen(drawList, x, y);
  198. }
  199. public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
  200. {
  201. return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
  202. }
  203. public string osDrawLine(string drawList, int endX, int endY)
  204. {
  205. return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
  206. }
  207. public string osDrawText(string drawList, string text)
  208. {
  209. return m_OSSL_Functions.osDrawText(drawList, text);
  210. }
  211. public string osDrawEllipse(string drawList, int width, int height)
  212. {
  213. return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
  214. }
  215. public string osDrawRectangle(string drawList, int width, int height)
  216. {
  217. return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
  218. }
  219. public string osDrawFilledRectangle(string drawList, int width, int height)
  220. {
  221. return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
  222. }
  223. public string osSetFontSize(string drawList, int fontSize)
  224. {
  225. return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
  226. }
  227. public string osSetPenSize(string drawList, int penSize)
  228. {
  229. return m_OSSL_Functions.osSetPenSize(drawList, penSize);
  230. }
  231. public string osSetPenColour(string drawList, string colour)
  232. {
  233. return m_OSSL_Functions.osSetPenColour(drawList, colour);
  234. }
  235. public string osDrawImage(string drawList, int width, int height, string imageUrl)
  236. {
  237. return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
  238. }
  239. public vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
  240. {
  241. return m_OSSL_Functions.osGetDrawStringSize(contentType, text, fontName, fontSize);
  242. }
  243. public void osSetStateEvents(int events)
  244. {
  245. m_OSSL_Functions.osSetStateEvents(events);
  246. }
  247. public string osGetScriptEngineName()
  248. {
  249. return m_OSSL_Functions.osGetScriptEngineName();
  250. }
  251. public string osGetSimulatorVersion()
  252. {
  253. return m_OSSL_Functions.osGetSimulatorVersion();
  254. }
  255. public Hashtable osParseJSON(string JSON)
  256. {
  257. return m_OSSL_Functions.osParseJSON(JSON);
  258. }
  259. public void osMessageObject(key objectUUID,string message)
  260. {
  261. m_OSSL_Functions.osMessageObject(objectUUID,message);
  262. }
  263. public void osMakeNotecard(string notecardName, LSL_Types.list contents)
  264. {
  265. m_OSSL_Functions.osMakeNotecard(notecardName, contents);
  266. }
  267. public string osGetNotecardLine(string name, int line)
  268. {
  269. return m_OSSL_Functions.osGetNotecardLine(name, line);
  270. }
  271. public string osGetNotecard(string name)
  272. {
  273. return m_OSSL_Functions.osGetNotecard(name);
  274. }
  275. public int osGetNumberOfNotecardLines(string name)
  276. {
  277. return m_OSSL_Functions.osGetNumberOfNotecardLines(name);
  278. }
  279. public string osAvatarName2Key(string firstname, string lastname)
  280. {
  281. return m_OSSL_Functions.osAvatarName2Key(firstname, lastname);
  282. }
  283. public string osKey2Name(string id)
  284. {
  285. return m_OSSL_Functions.osKey2Name(id);
  286. }
  287. public string osGetGridNick()
  288. {
  289. return m_OSSL_Functions.osGetGridNick();
  290. }
  291. public string osGetGridName()
  292. {
  293. return m_OSSL_Functions.osGetGridName();
  294. }
  295. public string osGetGridLoginURI()
  296. {
  297. return m_OSSL_Functions.osGetGridLoginURI();
  298. }
  299. public LSL_String osFormatString(string str, LSL_List strings)
  300. {
  301. return m_OSSL_Functions.osFormatString(str, strings);
  302. }
  303. public LSL_List osMatchString(string src, string pattern, int start)
  304. {
  305. return m_OSSL_Functions.osMatchString(src, pattern, start);
  306. }
  307. // Information about data loaded into the region
  308. public string osLoadedCreationDate()
  309. {
  310. return m_OSSL_Functions.osLoadedCreationDate();
  311. }
  312. public string osLoadedCreationTime()
  313. {
  314. return m_OSSL_Functions.osLoadedCreationTime();
  315. }
  316. public string osLoadedCreationID()
  317. {
  318. return m_OSSL_Functions.osLoadedCreationID();
  319. }
  320. public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
  321. {
  322. return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules);
  323. }
  324. public OSSLPrim Prim;
  325. [Serializable]
  326. public class OSSLPrim
  327. {
  328. internal ScriptBaseClass OSSL;
  329. public OSSLPrim(ScriptBaseClass bc)
  330. {
  331. OSSL = bc;
  332. Position = new OSSLPrim_Position(this);
  333. Rotation = new OSSLPrim_Rotation(this);
  334. }
  335. public OSSLPrim_Position Position;
  336. public OSSLPrim_Rotation Rotation;
  337. private TextStruct _text;
  338. public TextStruct Text
  339. {
  340. get { return _text; }
  341. set
  342. {
  343. _text = value;
  344. OSSL.llSetText(_text.Text, _text.color, _text.alpha);
  345. }
  346. }
  347. [Serializable]
  348. public struct TextStruct
  349. {
  350. public string Text;
  351. public LSL_Types.Vector3 color;
  352. public double alpha;
  353. }
  354. }
  355. [Serializable]
  356. public class OSSLPrim_Position
  357. {
  358. private OSSLPrim prim;
  359. private LSL_Types.Vector3 Position;
  360. public OSSLPrim_Position(OSSLPrim _prim)
  361. {
  362. prim = _prim;
  363. }
  364. private void Load()
  365. {
  366. Position = prim.OSSL.llGetPos();
  367. }
  368. private void Save()
  369. {
  370. if (Position.x > ((int)Constants.RegionSize - 1))
  371. Position.x = ((int)Constants.RegionSize - 1);
  372. if (Position.x < 0)
  373. Position.x = 0;
  374. if (Position.y > ((int)Constants.RegionSize - 1))
  375. Position.y = ((int)Constants.RegionSize - 1);
  376. if (Position.y < 0)
  377. Position.y = 0;
  378. if (Position.z > 768)
  379. Position.z = 768;
  380. if (Position.z < 0)
  381. Position.z = 0;
  382. prim.OSSL.llSetPos(Position);
  383. }
  384. public double x
  385. {
  386. get
  387. {
  388. Load();
  389. return Position.x;
  390. }
  391. set
  392. {
  393. Load();
  394. Position.x = value;
  395. Save();
  396. }
  397. }
  398. public double y
  399. {
  400. get
  401. {
  402. Load();
  403. return Position.y;
  404. }
  405. set
  406. {
  407. Load();
  408. Position.y = value;
  409. Save();
  410. }
  411. }
  412. public double z
  413. {
  414. get
  415. {
  416. Load();
  417. return Position.z;
  418. }
  419. set
  420. {
  421. Load();
  422. Position.z = value;
  423. Save();
  424. }
  425. }
  426. }
  427. [Serializable]
  428. public class OSSLPrim_Rotation
  429. {
  430. private OSSLPrim prim;
  431. private LSL_Types.Quaternion Rotation;
  432. public OSSLPrim_Rotation(OSSLPrim _prim)
  433. {
  434. prim = _prim;
  435. }
  436. private void Load()
  437. {
  438. Rotation = prim.OSSL.llGetRot();
  439. }
  440. private void Save()
  441. {
  442. prim.OSSL.llSetRot(Rotation);
  443. }
  444. public double x
  445. {
  446. get
  447. {
  448. Load();
  449. return Rotation.x;
  450. }
  451. set
  452. {
  453. Load();
  454. Rotation.x = value;
  455. Save();
  456. }
  457. }
  458. public double y
  459. {
  460. get
  461. {
  462. Load();
  463. return Rotation.y;
  464. }
  465. set
  466. {
  467. Load();
  468. Rotation.y = value;
  469. Save();
  470. }
  471. }
  472. public double z
  473. {
  474. get
  475. {
  476. Load();
  477. return Rotation.z;
  478. }
  479. set
  480. {
  481. Load();
  482. Rotation.z = value;
  483. Save();
  484. }
  485. }
  486. public double s
  487. {
  488. get
  489. {
  490. Load();
  491. return Rotation.s;
  492. }
  493. set
  494. {
  495. Load();
  496. Rotation.s = value;
  497. Save();
  498. }
  499. }
  500. }
  501. }
  502. }