diff options
author | Adam Frisby | 2007-07-13 17:43:25 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-13 17:43:25 +0000 |
commit | 6d37fe4947eb31999295ab7f6961b7b0ab1a25c0 (patch) | |
tree | bc77978b5db979ea4b30ce123a62a58389364740 /OpenSim | |
parent | * Added wrappers for: (diff) | |
download | opensim-SC_OLD-6d37fe4947eb31999295ab7f6961b7b0ab1a25c0.zip opensim-SC_OLD-6d37fe4947eb31999295ab7f6961b7b0ab1a25c0.tar.gz opensim-SC_OLD-6d37fe4947eb31999295ab7f6961b7b0ab1a25c0.tar.bz2 opensim-SC_OLD-6d37fe4947eb31999295ab7f6961b7b0ab1a25c0.tar.xz |
* Moved LSL-style functions to ScriptInterpretedAPI.cs and put a XML remark comment that they are defunct and best avoided at all costs.
* More wrappers: llCollisionFilter, llCollisionSprite, llCos, llCreateLink, llDeleteSubList, llDeleteSubString, llDetachFromAvatar
* More functions: osCos, osDeleteSubList, osDeleteSubString
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs | 139 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs | 206 |
2 files changed, 208 insertions, 137 deletions
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs index 702653e..6a2b839 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs | |||
@@ -16,152 +16,17 @@ namespace OpenSim.Region.Environment.Scripting | |||
16 | public class ScriptAPI | 16 | public class ScriptAPI |
17 | { | 17 | { |
18 | Scene scene; | 18 | Scene scene; |
19 | ScriptInterpretedAPI interpretedAPI; | ||
19 | 20 | ||
20 | public ScriptAPI(Scene world) | 21 | public ScriptAPI(Scene world) |
21 | { | 22 | { |
22 | scene = world; | 23 | scene = world; |
24 | interpretedAPI = new ScriptInterpretedAPI(); | ||
23 | } | 25 | } |
24 | 26 | ||
25 | public Object CallMethod(String method, Object[] args) | 27 | public Object CallMethod(String method, Object[] args) |
26 | { | 28 | { |
27 | return null; | 29 | return null; |
28 | } | 30 | } |
29 | |||
30 | // LSL Compatibility below | ||
31 | // remap LL* functions to OS* | ||
32 | public int osAbs(int val) | ||
33 | { | ||
34 | return Math.Abs(val); | ||
35 | } | ||
36 | |||
37 | public float osAcos(float val) | ||
38 | { | ||
39 | return (float)Math.Acos(val); | ||
40 | } | ||
41 | |||
42 | [Obsolete("Unimplemented")] | ||
43 | public void osAddToLandPassList(Key avatar, float hours) | ||
44 | { | ||
45 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | [Obsolete("Unimplemented")] | ||
50 | public void osAdjustSoundVolume(float volume) | ||
51 | { | ||
52 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAdjustSoundVolume(float volume)"); | ||
53 | return; | ||
54 | } | ||
55 | |||
56 | [Obsolete("Unimplemented")] | ||
57 | public void osAllowInventoryDrop(int add) | ||
58 | { | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | [Obsolete("Unimplemented")] | ||
63 | public float osAngleBetween(Rotation a, Rotation b) | ||
64 | { | ||
65 | Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); | ||
66 | Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | [Obsolete("Unimplemented")] | ||
72 | public void osApplyImpulse(Vector force, int local) | ||
73 | { | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | [Obsolete("Unimplemented")] | ||
78 | public void osApplyRotationalImpulse(Vector force, int local) | ||
79 | { | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | public float osAsin(float val) | ||
84 | { | ||
85 | return (float)Math.Asin(val); | ||
86 | } | ||
87 | |||
88 | public float osAtan2(float x, float y) | ||
89 | { | ||
90 | return (float)Math.Atan2(x, y); | ||
91 | } | ||
92 | |||
93 | [Obsolete("Unimplemented")] | ||
94 | public void osAttachToAvatar(Key avatar, int attachmentPoint) | ||
95 | { | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | [Obsolete("Unimplemented")] | ||
100 | public Key osAvatarOnSitTarget() | ||
101 | { | ||
102 | return Key.Zero; | ||
103 | } | ||
104 | |||
105 | public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) | ||
106 | { | ||
107 | Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); | ||
108 | Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); | ||
109 | Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); | ||
110 | Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); | ||
111 | |||
112 | axQ.FromAxes(axFwd, axLeft, axUp); | ||
113 | |||
114 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); | ||
115 | } | ||
116 | |||
117 | public Rotation osAxisAngle2Rot(Vector axis, float angle) | ||
118 | { | ||
119 | Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); | ||
120 | |||
121 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); | ||
122 | } | ||
123 | |||
124 | public string osBase64ToString(string str) | ||
125 | { | ||
126 | Encoding enc = System.Text.Encoding.UTF8; | ||
127 | return enc.GetString(Convert.FromBase64String(str)); | ||
128 | } | ||
129 | |||
130 | [Obsolete("Unimplemented")] | ||
131 | public void osBreakAllLinks() | ||
132 | { | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | [Obsolete("Unimplemented")] | ||
137 | public void osBreakLink() | ||
138 | { | ||
139 | return; | ||
140 | } | ||
141 | |||
142 | public LSLList osCSV2List(string src) | ||
143 | { | ||
144 | LSLList retVal = new LSLList(); | ||
145 | retVal.AddRange(src.Split(',')); | ||
146 | |||
147 | return retVal; | ||
148 | } | ||
149 | |||
150 | public int osCeil(float val) | ||
151 | { | ||
152 | return (int)Math.Ceiling(val); | ||
153 | } | ||
154 | |||
155 | [Obsolete("Unimplemented")] | ||
156 | public void osCloseRemoteDataChannel(Key channel) | ||
157 | { | ||
158 | return; | ||
159 | } | ||
160 | |||
161 | [Obsolete("Unimplemented")] | ||
162 | public float osCloud(Vector offset) | ||
163 | { | ||
164 | return 0.0; | ||
165 | } | ||
166 | } | 31 | } |
167 | } | 32 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs new file mode 100644 index 0000000..0ae6e62 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs | |||
@@ -0,0 +1,206 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Key = libsecondlife.LLUUID; | ||
5 | using Rotation = libsecondlife.LLQuaternion; | ||
6 | using Vector = libsecondlife.LLVector3; | ||
7 | using LSLList = System.Collections.Generic.List<string>; | ||
8 | |||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | |||
11 | namespace OpenSim.Region.Environment.Scripting | ||
12 | { | ||
13 | /// <summary> | ||
14 | /// A class inteded to act as an API for LSL-styled interpreted languages | ||
15 | /// </summary> | ||
16 | /// <remarks>Avoid at all costs. This should ONLY be used for LSL.</remarks> | ||
17 | class ScriptInterpretedAPI | ||
18 | { | ||
19 | public int osAbs(int val) | ||
20 | { | ||
21 | return Math.Abs(val); | ||
22 | } | ||
23 | |||
24 | public float osAcos(float val) | ||
25 | { | ||
26 | return (float)Math.Acos(val); | ||
27 | } | ||
28 | |||
29 | [Obsolete("Unimplemented")] | ||
30 | public void osAddToLandPassList(Key avatar, float hours) | ||
31 | { | ||
32 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); | ||
33 | return; | ||
34 | } | ||
35 | |||
36 | [Obsolete("Unimplemented")] | ||
37 | public void osAdjustSoundVolume(float volume) | ||
38 | { | ||
39 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAdjustSoundVolume(float volume)"); | ||
40 | return; | ||
41 | } | ||
42 | |||
43 | [Obsolete("Unimplemented")] | ||
44 | public void osAllowInventoryDrop(int add) | ||
45 | { | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | [Obsolete("Unimplemented")] | ||
50 | public float osAngleBetween(Rotation a, Rotation b) | ||
51 | { | ||
52 | Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); | ||
53 | Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | [Obsolete("Unimplemented")] | ||
59 | public void osApplyImpulse(Vector force, int local) | ||
60 | { | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | [Obsolete("Unimplemented")] | ||
65 | public void osApplyRotationalImpulse(Vector force, int local) | ||
66 | { | ||
67 | return; | ||
68 | } | ||
69 | |||
70 | public float osAsin(float val) | ||
71 | { | ||
72 | return (float)Math.Asin(val); | ||
73 | } | ||
74 | |||
75 | public float osAtan2(float x, float y) | ||
76 | { | ||
77 | return (float)Math.Atan2(x, y); | ||
78 | } | ||
79 | |||
80 | [Obsolete("Unimplemented")] | ||
81 | public void osAttachToAvatar(Key avatar, int attachmentPoint) | ||
82 | { | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | [Obsolete("Unimplemented")] | ||
87 | public Key osAvatarOnSitTarget() | ||
88 | { | ||
89 | return Key.Zero; | ||
90 | } | ||
91 | |||
92 | public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) | ||
93 | { | ||
94 | Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); | ||
95 | Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); | ||
96 | Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); | ||
97 | Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); | ||
98 | |||
99 | axQ.FromAxes(axFwd, axLeft, axUp); | ||
100 | |||
101 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); | ||
102 | } | ||
103 | |||
104 | public Rotation osAxisAngle2Rot(Vector axis, float angle) | ||
105 | { | ||
106 | Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); | ||
107 | |||
108 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); | ||
109 | } | ||
110 | |||
111 | public string osBase64ToString(string str) | ||
112 | { | ||
113 | Encoding enc = System.Text.Encoding.UTF8; | ||
114 | return enc.GetString(Convert.FromBase64String(str)); | ||
115 | } | ||
116 | |||
117 | [Obsolete("Unimplemented")] | ||
118 | public void osBreakAllLinks() | ||
119 | { | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | [Obsolete("Unimplemented")] | ||
124 | public void osBreakLink() | ||
125 | { | ||
126 | return; | ||
127 | } | ||
128 | |||
129 | public LSLList osCSV2List(string src) | ||
130 | { | ||
131 | LSLList retVal = new LSLList(); | ||
132 | retVal.AddRange(src.Split(',')); | ||
133 | |||
134 | return retVal; | ||
135 | } | ||
136 | |||
137 | public int osCeil(float val) | ||
138 | { | ||
139 | return (int)Math.Ceiling(val); | ||
140 | } | ||
141 | |||
142 | [Obsolete("Unimplemented")] | ||
143 | public void osCloseRemoteDataChannel(Key channel) | ||
144 | { | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | [Obsolete("Unimplemented")] | ||
149 | public float osCloud(Vector offset) | ||
150 | { | ||
151 | return 0.0; | ||
152 | } | ||
153 | |||
154 | [Obsolete("Unimplemented")] | ||
155 | public void osCollisionFilter(string name, Key id, int accept) | ||
156 | { | ||
157 | return; | ||
158 | } | ||
159 | |||
160 | [Obsolete("Unimplemented")] | ||
161 | public void osCollisionSprite(string impact_sprite) | ||
162 | { | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | public float osCos(float theta) | ||
167 | { | ||
168 | return (float)Math.Cos(theta); | ||
169 | } | ||
170 | |||
171 | [Obsolete("Unimplemented")] | ||
172 | public void osCreateLink(Key target, int parent) | ||
173 | { | ||
174 | return false; | ||
175 | } | ||
176 | |||
177 | [Obsolete("Partially Unimplemented")] | ||
178 | public LSLList osDeleteSubList(LSLList src, int start, int end) | ||
179 | { | ||
180 | if (start < 0 || end < 0) | ||
181 | { | ||
182 | throw new Exception("Unsupported at this time."); | ||
183 | } | ||
184 | |||
185 | src.RemoveRange(start, start - end + 1); | ||
186 | return src; | ||
187 | } | ||
188 | |||
189 | [Obsolete("Partially Unimplemented")] | ||
190 | public string osDeleteSubString(string src, int start, int end) | ||
191 | { | ||
192 | if (start < 0 || end < 0) | ||
193 | { | ||
194 | throw new Exception("Unsupported at this time."); | ||
195 | } | ||
196 | |||
197 | return src.Remove(start, start - end + 1); | ||
198 | } | ||
199 | |||
200 | [Obsolete("Unimplemented")] | ||
201 | public void osDetachFromAvatar(Key avatar) | ||
202 | { | ||
203 | return; | ||
204 | } | ||
205 | } | ||
206 | } | ||