Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateBillboard() [2/2]

static Matrix Microsoft.Xna.Framework.Matrix.CreateBillboard ( Vector3 objectPosition,
Vector3 cameraPosition,
Vector3 cameraUpVector,
Vector3? cameraForwardVector )
inlinestatic

Definition at line 230 of file Matrix.cs.

231 {
232 Vector3 value = default(Vector3);
233 value.X = objectPosition.X - cameraPosition.X;
234 value.Y = objectPosition.Y - cameraPosition.Y;
235 value.Z = objectPosition.Z - cameraPosition.Z;
236 float num = value.LengthSquared();
237 if (num < 0.0001f)
238 {
239 value = (cameraForwardVector.HasValue ? (-cameraForwardVector.Value) : Vector3.Forward);
240 }
241 else
242 {
243 Vector3.Multiply(ref value, 1f / (float)Math.Sqrt(num), out value);
244 }
245 Vector3.Cross(ref cameraUpVector, ref value, out var result);
246 result.Normalize();
247 Vector3.Cross(ref value, ref result, out var result2);
248 Matrix result3 = default(Matrix);
249 result3.M11 = result.X;
250 result3.M12 = result.Y;
251 result3.M13 = result.Z;
252 result3.M14 = 0f;
253 result3.M21 = result2.X;
254 result3.M22 = result2.Y;
255 result3.M23 = result2.Z;
256 result3.M24 = 0f;
257 result3.M31 = value.X;
258 result3.M32 = value.Y;
259 result3.M33 = value.Z;
260 result3.M34 = 0f;
261 result3.M41 = objectPosition.X;
262 result3.M42 = objectPosition.Y;
263 result3.M43 = objectPosition.Z;
264 result3.M44 = 1f;
265 return result3;
266 }
static double Sqrt(double d)
Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
Definition Matrix.cs:210

References Microsoft.Xna.Framework.Vector3.Cross(), Microsoft.Xna.Framework.Vector3.Forward, Microsoft.Xna.Framework.Vector3.Multiply(), System.Math.Sqrt(), System.value, Microsoft.Xna.Framework.Vector3.X, Microsoft.Xna.Framework.Vector3.Y, and Microsoft.Xna.Framework.Vector3.Z.