diff options
author | Charles Krinke | 2007-12-12 17:18:15 +0000 |
---|---|---|
committer | Charles Krinke | 2007-12-12 17:18:15 +0000 |
commit | 47b091f6630a4db2df72b4b2a0bc877287a751f1 (patch) | |
tree | d3990f3015be184330c9ac8dc50b4527e71c9dd1 /OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs | |
parent | couple of small fixes. (diff) | |
download | opensim-SC_OLD-47b091f6630a4db2df72b4b2a0bc877287a751f1.zip opensim-SC_OLD-47b091f6630a4db2df72b4b2a0bc877287a751f1.tar.gz opensim-SC_OLD-47b091f6630a4db2df72b4b2a0bc877287a751f1.tar.bz2 opensim-SC_OLD-47b091f6630a4db2df72b4b2a0bc877287a751f1.tar.xz |
Thanks to Alondria for: Adding vector->string and rotation->string,
float * vector, vector * float, vector / float, vector + vector,
vector - vector, vector * vector, vector % vector and changing
x, y, z, (and r) parts of vector and rotation to be lower case
(similar to LL's LSL vectors/rots). With these changes we should
expect to run kan-ed#1, kan-ed#2 and most of kan-ed#3.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs | 106 |
1 files changed, 53 insertions, 53 deletions
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 | ||