diff options
author | Dahlia Trimble | 2008-10-15 04:42:28 +0000 |
---|---|---|
committer | Dahlia Trimble | 2008-10-15 04:42:28 +0000 |
commit | 901acddbdd38c441426f43cbfa78c422a19cec17 (patch) | |
tree | 32303dcebf039c840ebae0430bc57e0aa895f5ef /OpenSim/Framework/Util.cs | |
parent | * Send an avatar update to other clients when an avatar rotates, as well as w... (diff) | |
download | opensim-SC-901acddbdd38c441426f43cbfa78c422a19cec17.zip opensim-SC-901acddbdd38c441426f43cbfa78c422a19cec17.tar.gz opensim-SC-901acddbdd38c441426f43cbfa78c422a19cec17.tar.bz2 opensim-SC-901acddbdd38c441426f43cbfa78c422a19cec17.tar.xz |
Thanks to M. Igarashi and nlin for a patch that implements llGetCameraRot().
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 57c1601..28c818a 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -116,6 +116,60 @@ namespace OpenSim.Framework | |||
116 | 116 | ||
117 | # endregion | 117 | # endregion |
118 | 118 | ||
119 | public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) | ||
120 | { | ||
121 | float s; | ||
122 | float tr = (float) (fwd.X + left.Y + up.Z + 1.0); | ||
123 | |||
124 | if (tr >= 1.0) | ||
125 | { | ||
126 | s = (float) (0.5 / Math.Sqrt(tr)); | ||
127 | return new Quaternion( | ||
128 | (left.Z - up.Y) * s, | ||
129 | (up.X - fwd.Z) * s, | ||
130 | (fwd.Y - left.X) * s, | ||
131 | (float) 0.25 / s); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | float max = (left.Y > up.Z) ? left.Y : up.Z; | ||
136 | |||
137 | if (max < fwd.X) | ||
138 | { | ||
139 | s = (float) (Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0)); | ||
140 | float x = (float) (s * 0.5); | ||
141 | s = (float) (0.5 / s); | ||
142 | return new Quaternion( | ||
143 | x, | ||
144 | (fwd.Y + left.X) * s, | ||
145 | (up.X + fwd.Z) * s, | ||
146 | (left.Z - up.Y) * s); | ||
147 | } | ||
148 | else if (max == left.Y) | ||
149 | { | ||
150 | s = (float) (Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0)); | ||
151 | float y = (float) (s * 0.5); | ||
152 | s = (float) (0.5 / s); | ||
153 | return new Quaternion( | ||
154 | (fwd.Y + left.X) * s, | ||
155 | y, | ||
156 | (left.Z + up.Y) * s, | ||
157 | (up.X - fwd.Z) * s); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | s = (float) (Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0)); | ||
162 | float z = (float) (s * 0.5); | ||
163 | s = (float) (0.5 / s); | ||
164 | return new Quaternion( | ||
165 | (up.X + fwd.Z) * s, | ||
166 | (left.Z + up.Y) * s, | ||
167 | z, | ||
168 | (fwd.Y - left.X) * s); | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | |||
119 | public static Random RandomClass | 173 | public static Random RandomClass |
120 | { | 174 | { |
121 | get { return randomClass; } | 175 | get { return randomClass; } |