From 47b091f6630a4db2df72b4b2a0bc877287a751f1 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 12 Dec 2007 17:18:15 +0000 Subject: 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. --- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 114 +++++++++++++++++++----- 1 file changed, 90 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') 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 [Serializable] public struct Vector3 { - public double X; - public double Y; - public double Z; + public double x; + public double y; + public double z; public Vector3(Vector3 vector) { - X = (float) vector.X; - Y = (float) vector.Y; - Z = (float) vector.Z; + x = (float) vector.x; + y = (float) vector.y; + z = (float) vector.z; } - public Vector3(double x, double y, double z) + public Vector3(double X, double Y, double Z) { - X = x; - Y = y; - Z = z; + x = X; + y = Y; + z = Z; + } + public string ToString() + { + return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">"; + } + public static Vector3 operator *(Vector3 v, float f) + { + v.x = v.x * f; + v.y = v.y * f; + v.z = v.z * f; + return v; + } + public static Vector3 operator /(Vector3 v, float f) + { + v.x = v.x / f; + v.y = v.y / f; + v.z = v.z / f; + return v; + } + public static Vector3 operator /(float f, Vector3 v) + { + v.x = v.x / f; + v.y = v.y / f; + v.z = v.z / f; + return v; + } + public static Vector3 operator *(float f, Vector3 v) + { + v.x = v.x * f; + v.y = v.y * f; + v.z = v.z * f; + return v; + } + public static Vector3 operator *(Vector3 v1, Vector3 v2) + { + v1.x = v1.x * v2.x; + v1.y = v1.y * v2.y; + v1.z = v1.z * v2.z; + return v1; + } + public static Vector3 operator +(Vector3 v1, Vector3 v2) + { + v1.x = v1.x + v2.x; + v1.y = v1.y + v2.y; + v1.z = v1.z + v2.z; + return v1; + } + public static Vector3 operator -(Vector3 v1, Vector3 v2) + { + v1.x = v1.x - v2.x; + v1.y = v1.y - v2.y; + v1.z = v1.z - v2.z; + return v1; + } + public static Vector3 operator %(Vector3 v1, Vector3 v2) + { + //Cross product + Vector3 tv; + tv.x = (v1.y * v2.z) - (v1.z * v2.y); + tv.y = (v1.z * v2.x) - (v1.x * v2.z); + tv.z = (v1.x * v2.y) - (v1.y * v2.x); + return tv; } } [Serializable] public struct Quaternion { - public double X; - public double Y; - public double Z; - public double R; + public double x; + public double y; + public double z; + public double r; public Quaternion(Quaternion Quat) { - X = (float) Quat.X; - Y = (float) Quat.Y; - Z = (float) Quat.Z; - R = (float) Quat.R; + x = (float) Quat.x; + y = (float) Quat.y; + z = (float) Quat.z; + r = (float) Quat.r; } - public Quaternion(double x, double y, double z, double r) + public Quaternion(double X, double Y, double Z, double R) + { + x = X; + y = Y; + z = Z; + r = R; + } + public string ToString() { - X = x; - Y = y; - Z = z; - R = r; + return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + r.ToString() + ">"; } } } -} \ No newline at end of file +} -- cgit v1.1