aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs114
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs106
2 files changed, 143 insertions, 77 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index df3d752..5618db6 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -36,48 +36,114 @@ namespace OpenSim.Region.ScriptEngine.Common
36 [Serializable] 36 [Serializable]
37 public struct Vector3 37 public struct Vector3
38 { 38 {
39 public double X; 39 public double x;
40 public double Y; 40 public double y;
41 public double Z; 41 public double z;
42 42
43 public Vector3(Vector3 vector) 43 public Vector3(Vector3 vector)
44 { 44 {
45 X = (float) vector.X; 45 x = (float) vector.x;
46 Y = (float) vector.Y; 46 y = (float) vector.y;
47 Z = (float) vector.Z; 47 z = (float) vector.z;
48 } 48 }
49 49
50 public Vector3(double x, double y, double z) 50 public Vector3(double X, double Y, double Z)
51 { 51 {
52 X = x; 52 x = X;
53 Y = y; 53 y = Y;
54 Z = z; 54 z = Z;
55 }
56 public string ToString()
57 {
58 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">";
59 }
60 public static Vector3 operator *(Vector3 v, float f)
61 {
62 v.x = v.x * f;
63 v.y = v.y * f;
64 v.z = v.z * f;
65 return v;
66 }
67 public static Vector3 operator /(Vector3 v, float f)
68 {
69 v.x = v.x / f;
70 v.y = v.y / f;
71 v.z = v.z / f;
72 return v;
73 }
74 public static Vector3 operator /(float f, Vector3 v)
75 {
76 v.x = v.x / f;
77 v.y = v.y / f;
78 v.z = v.z / f;
79 return v;
80 }
81 public static Vector3 operator *(float f, Vector3 v)
82 {
83 v.x = v.x * f;
84 v.y = v.y * f;
85 v.z = v.z * f;
86 return v;
87 }
88 public static Vector3 operator *(Vector3 v1, Vector3 v2)
89 {
90 v1.x = v1.x * v2.x;
91 v1.y = v1.y * v2.y;
92 v1.z = v1.z * v2.z;
93 return v1;
94 }
95 public static Vector3 operator +(Vector3 v1, Vector3 v2)
96 {
97 v1.x = v1.x + v2.x;
98 v1.y = v1.y + v2.y;
99 v1.z = v1.z + v2.z;
100 return v1;
101 }
102 public static Vector3 operator -(Vector3 v1, Vector3 v2)
103 {
104 v1.x = v1.x - v2.x;
105 v1.y = v1.y - v2.y;
106 v1.z = v1.z - v2.z;
107 return v1;
108 }
109 public static Vector3 operator %(Vector3 v1, Vector3 v2)
110 {
111 //Cross product
112 Vector3 tv;
113 tv.x = (v1.y * v2.z) - (v1.z * v2.y);
114 tv.y = (v1.z * v2.x) - (v1.x * v2.z);
115 tv.z = (v1.x * v2.y) - (v1.y * v2.x);
116 return tv;
55 } 117 }
56 } 118 }
57 119
58 [Serializable] 120 [Serializable]
59 public struct Quaternion 121 public struct Quaternion
60 { 122 {
61 public double X; 123 public double x;
62 public double Y; 124 public double y;
63 public double Z; 125 public double z;
64 public double R; 126 public double r;
65 127
66 public Quaternion(Quaternion Quat) 128 public Quaternion(Quaternion Quat)
67 { 129 {
68 X = (float) Quat.X; 130 x = (float) Quat.x;
69 Y = (float) Quat.Y; 131 y = (float) Quat.y;
70 Z = (float) Quat.Z; 132 z = (float) Quat.z;
71 R = (float) Quat.R; 133 r = (float) Quat.r;
72 } 134 }
73 135
74 public Quaternion(double x, double y, double z, double r) 136 public Quaternion(double X, double Y, double Z, double R)
137 {
138 x = X;
139 y = Y;
140 z = Z;
141 r = R;
142 }
143 public string ToString()
75 { 144 {
76 X = x; 145 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + r.ToString() + ">";
77 Y = y;
78 Z = z;
79 R = r;
80 } 146 }
81 } 147 }
82 } 148 }
83} \ No newline at end of file 149}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
index 0edff14..0e905be 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
@@ -165,24 +165,24 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
165 //This next group are vector operations involving squaring and square root. ckrinke 165 //This next group are vector operations involving squaring and square root. ckrinke
166 public double llVecMag(LSL_Types.Vector3 v) 166 public double llVecMag(LSL_Types.Vector3 v)
167 { 167 {
168 return (v.X*v.X + v.Y*v.Y + v.Z*v.Z); 168 return (v.x*v.x + v.y*v.y + v.z*v.z);
169 } 169 }
170 170
171 public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) 171 public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v)
172 { 172 {
173 double mag = v.X*v.X + v.Y*v.Y + v.Z*v.Z; 173 double mag = v.x*v.x + v.y*v.y + v.z*v.z;
174 LSL_Types.Vector3 nor = new LSL_Types.Vector3(); 174 LSL_Types.Vector3 nor = new LSL_Types.Vector3();
175 nor.X = v.X/mag; 175 nor.x = v.x/mag;
176 nor.Y = v.Y/mag; 176 nor.y = v.y/mag;
177 nor.Z = v.Z/mag; 177 nor.z = v.z/mag;
178 return nor; 178 return nor;
179 } 179 }
180 180
181 public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) 181 public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
182 { 182 {
183 double dx = a.X - b.X; 183 double dx = a.x - b.x;
184 double dy = a.Y - b.Y; 184 double dy = a.y - b.y;
185 double dz = a.Z - b.Z; 185 double dz = a.z - b.z;
186 return Math.Sqrt(dx*dx + dy*dy + dz*dz); 186 return Math.Sqrt(dx*dx + dy*dy + dz*dz);
187 } 187 }
188 188
@@ -190,31 +190,31 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
190 public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) 190 public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r)
191 { 191 {
192 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke 192 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke
193 LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X*r.X, r.Y*r.Y, r.Z*r.Z, r.R*r.R); 193 LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.x*r.x, r.y*r.y, r.z*r.z, r.r*r.r);
194 double m = (t.X + t.Y + t.Z + t.R); 194 double m = (t.x + t.y + t.z + t.r);
195 if (m == 0) return new LSL_Types.Vector3(); 195 if (m == 0) return new LSL_Types.Vector3();
196 double n = 2*(r.Y*r.R + r.X*r.Z); 196 double n = 2*(r.y*r.r + r.x*r.z);
197 double p = m*m - n*n; 197 double p = m*m - n*n;
198 if (p > 0) 198 if (p > 0)
199 return new LSL_Types.Vector3(Math.Atan2(2.0*(r.X*r.R - r.Y*r.Z), (-t.X - t.Y + t.Z + t.R)), 199 return new LSL_Types.Vector3(Math.Atan2(2.0*(r.x*r.r - r.y*r.z), (-t.x - t.y + t.z + t.r)),
200 Math.Atan2(n, Math.Sqrt(p)), 200 Math.Atan2(n, Math.Sqrt(p)),
201 Math.Atan2(2.0*(r.Z*r.R - r.X*r.Y), (t.X - t.Y - t.Z + t.R))); 201 Math.Atan2(2.0*(r.z*r.r - r.x*r.y), (t.x - t.y - t.z + t.r)));
202 else if (n > 0) 202 else if (n > 0)
203 return new LSL_Types.Vector3(0.0, Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); 203 return new LSL_Types.Vector3(0.0, Math.PI/2, Math.Atan2((r.z*r.r + r.x*r.y), 0.5 - t.x - t.z));
204 else 204 else
205 return new LSL_Types.Vector3(0.0, -Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); 205 return new LSL_Types.Vector3(0.0, -Math.PI/2, Math.Atan2((r.z*r.r + r.x*r.y), 0.5 - t.x - t.z));
206 } 206 }
207 207
208 public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) 208 public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v)
209 { 209 {
210 //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 210 //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07
211 float err = 0.00001f; 211 float err = 0.00001f;
212 double ax = Math.Sin(v.X/2); 212 double ax = Math.Sin(v.x/2);
213 double aw = Math.Cos(v.X/2); 213 double aw = Math.Cos(v.x/2);
214 double by = Math.Sin(v.Y/2); 214 double by = Math.Sin(v.y/2);
215 double bw = Math.Cos(v.Y/2); 215 double bw = Math.Cos(v.y/2);
216 double cz = Math.Sin(v.Z/2); 216 double cz = Math.Sin(v.z/2);
217 double cw = Math.Cos(v.Z/2); 217 double cw = Math.Cos(v.z/2);
218 LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); 218 LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw);
219 LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); 219 LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw);
220 LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); 220 LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw);
@@ -226,10 +226,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
226 //This addition doesnt compile yet c = a + b; 226 //This addition doesnt compile yet c = a + b;
227 LSL_Types.Quaternion d = new LSL_Types.Quaternion(); 227 LSL_Types.Quaternion d = new LSL_Types.Quaternion();
228 //This addition doesnt compile yet d = a - b; 228 //This addition doesnt compile yet d = a - b;
229 if ((Math.Abs(c.X) > err && Math.Abs(d.X) > err) || 229 if ((Math.Abs(c.x) > err && Math.Abs(d.x) > err) ||
230 (Math.Abs(c.Y) > err && Math.Abs(d.Y) > err) || 230 (Math.Abs(c.y) > err && Math.Abs(d.y) > err) ||
231 (Math.Abs(c.Z) > err && Math.Abs(d.Z) > err) || 231 (Math.Abs(c.z) > err && Math.Abs(d.z) > err) ||
232 (Math.Abs(c.R) > err && Math.Abs(d.R) > err)) 232 (Math.Abs(c.r) > err && Math.Abs(d.r) > err))
233 { 233 {
234 //return a new Quaternion that is null until I figure this out 234 //return a new Quaternion that is null until I figure this out
235 // return b; 235 // return b;
@@ -426,9 +426,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
426 { 426 {
427 // TODO: this needs to trigger a persistance save as well 427 // TODO: this needs to trigger a persistance save as well
428 LLVector3 tmp = m_host.Scale; 428 LLVector3 tmp = m_host.Scale;
429 tmp.X = (float) scale.X; 429 tmp.X = (float) scale.x;
430 tmp.Y = (float) scale.Y; 430 tmp.Y = (float) scale.y;
431 tmp.Z = (float) scale.Z; 431 tmp.Z = (float) scale.z;
432 m_host.Scale = tmp; 432 m_host.Scale = tmp;
433 m_host.SendFullUpdateToAllClients(); 433 m_host.SendFullUpdateToAllClients();
434 return; 434 return;
@@ -446,9 +446,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
446 if (face > -1) 446 if (face > -1)
447 { 447 {
448 texcolor = tex.CreateFace((uint)face).RGBA; 448 texcolor = tex.CreateFace((uint)face).RGBA;
449 texcolor.R = (float)Math.Abs(color.X - 1); 449 texcolor.R = (float)Math.Abs(color.x - 1);
450 texcolor.G = (float)Math.Abs(color.Y - 1); 450 texcolor.G = (float)Math.Abs(color.y - 1);
451 texcolor.B = (float)Math.Abs(color.Z - 1); 451 texcolor.B = (float)Math.Abs(color.z - 1);
452 tex.FaceTextures[face].RGBA = texcolor; 452 tex.FaceTextures[face].RGBA = texcolor;
453 m_host.UpdateTexture(tex); 453 m_host.UpdateTexture(tex);
454 return; 454 return;
@@ -456,18 +456,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
456 else if (face == -1) 456 else if (face == -1)
457 { 457 {
458 texcolor = tex.DefaultTexture.RGBA; 458 texcolor = tex.DefaultTexture.RGBA;
459 texcolor.R = (float)Math.Abs(color.X - 1); 459 texcolor.R = (float)Math.Abs(color.x - 1);
460 texcolor.G = (float)Math.Abs(color.Y - 1); 460 texcolor.G = (float)Math.Abs(color.y - 1);
461 texcolor.B = (float)Math.Abs(color.Z - 1); 461 texcolor.B = (float)Math.Abs(color.z - 1);
462 tex.DefaultTexture.RGBA = texcolor; 462 tex.DefaultTexture.RGBA = texcolor;
463 for (uint i = 0; i < 32; i++) 463 for (uint i = 0; i < 32; i++)
464 { 464 {
465 if (tex.FaceTextures[i] != null) 465 if (tex.FaceTextures[i] != null)
466 { 466 {
467 texcolor = tex.FaceTextures[i].RGBA; 467 texcolor = tex.FaceTextures[i].RGBA;
468 texcolor.R = (float)Math.Abs(color.X - 1); 468 texcolor.R = (float)Math.Abs(color.x - 1);
469 texcolor.G = (float)Math.Abs(color.Y - 1); 469 texcolor.G = (float)Math.Abs(color.y - 1);
470 texcolor.B = (float)Math.Abs(color.Z - 1); 470 texcolor.B = (float)Math.Abs(color.z - 1);
471 tex.FaceTextures[i].RGBA = texcolor; 471 tex.FaceTextures[i].RGBA = texcolor;
472 } 472 }
473 } 473 }
@@ -533,17 +533,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
533 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color 533 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
534 { 534 {
535 texcolor = tex.DefaultTexture.RGBA; 535 texcolor = tex.DefaultTexture.RGBA;
536 rgb.X = (255 - (texcolor.R * 255)) / 255; 536 rgb.x = (255 - (texcolor.R * 255)) / 255;
537 rgb.Y = (255 - (texcolor.G * 255)) / 255; 537 rgb.y = (255 - (texcolor.G * 255)) / 255;
538 rgb.Z = (255 - (texcolor.B * 255)) / 255; 538 rgb.z = (255 - (texcolor.B * 255)) / 255;
539 return rgb; 539 return rgb;
540 } 540 }
541 if (face > -1) 541 if (face > -1)
542 { 542 {
543 texcolor = tex.GetFace((uint)face).RGBA; 543 texcolor = tex.GetFace((uint)face).RGBA;
544 rgb.X = (255 - (texcolor.R * 255)) / 255; 544 rgb.x = (255 - (texcolor.R * 255)) / 255;
545 rgb.Y = (255 - (texcolor.G * 255)) / 255; 545 rgb.y = (255 - (texcolor.G * 255)) / 255;
546 rgb.Z = (255 - (texcolor.B * 255)) / 255; 546 rgb.z = (255 - (texcolor.B * 255)) / 255;
547 return rgb; 547 return rgb;
548 } 548 }
549 NotImplemented("llGetColor"); 549 NotImplemented("llGetColor");
@@ -691,11 +691,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
691 { 691 {
692 if (m_host.ParentID != 0) 692 if (m_host.ParentID != 0)
693 { 693 {
694 m_host.UpdateOffSet(new LLVector3((float) pos.X, (float) pos.Y, (float) pos.Z)); 694 m_host.UpdateOffSet(new LLVector3((float) pos.x, (float) pos.y, (float) pos.z));
695 } 695 }
696 else 696 else
697 { 697 {
698 m_host.UpdateGroupPosition(new LLVector3((float) pos.X, (float) pos.Y, (float) pos.Z)); 698 m_host.UpdateGroupPosition(new LLVector3((float) pos.x, (float) pos.y, (float) pos.z));
699 } 699 }
700 } 700 }
701 701
@@ -724,7 +724,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
724 724
725 public void llSetRot(LSL_Types.Quaternion rot) 725 public void llSetRot(LSL_Types.Quaternion rot)
726 { 726 {
727 m_host.UpdateRotation(new LLQuaternion((float) rot.X, (float) rot.Y, (float) rot.Z, (float) rot.R)); 727 m_host.UpdateRotation(new LLQuaternion((float) rot.x, (float) rot.y, (float) rot.z, (float) rot.r));
728 } 728 }
729 729
730 public LSL_Types.Quaternion llGetRot() 730 public LSL_Types.Quaternion llGetRot()
@@ -1216,7 +1216,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
1216 1216
1217 public void llSetText(string text, LSL_Types.Vector3 color, double alpha) 1217 public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
1218 { 1218 {
1219 Vector3 av3 = new Vector3((float) color.X, (float) color.Y, (float) color.Z); 1219 Vector3 av3 = new Vector3((float) color.x, (float) color.y, (float) color.z);
1220 m_host.SetText(text, av3, alpha); 1220 m_host.SetText(text, av3, alpha);
1221 } 1221 }
1222 1222
@@ -1351,9 +1351,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
1351 { 1351 {
1352 face = 0; 1352 face = 0;
1353 } 1353 }
1354 offset.X = tex.GetFace((uint)face).OffsetU; 1354 offset.x = tex.GetFace((uint)face).OffsetU;
1355 offset.Y = tex.GetFace((uint)face).OffsetV; 1355 offset.y = tex.GetFace((uint)face).OffsetV;
1356 offset.Z = 0.0; 1356 offset.z = 0.0;
1357 return offset; 1357 return offset;
1358 } 1358 }
1359 1359
@@ -1365,9 +1365,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
1365 { 1365 {
1366 side = 0; 1366 side = 0;
1367 } 1367 }
1368 scale.X = tex.GetFace((uint)side).RepeatU; 1368 scale.x = tex.GetFace((uint)side).RepeatU;
1369 scale.Y = tex.GetFace((uint)side).RepeatV; 1369 scale.y = tex.GetFace((uint)side).RepeatV;
1370 scale.Z = 0.0; 1370 scale.z = 0.0;
1371 return scale; 1371 return scale;
1372 } 1372 }
1373 1373