UHSampleGame.CoreObjects.Units.Unit.RotateToFace C# (CSharp) Méthode

RotateToFace() public méthode

public RotateToFace ( Vector3 O, Vector3 P, Vector3 U ) : void
O Vector3
P Vector3
U Vector3
Résultat void
        void RotateToFace(Vector3 O, Vector3 P, Vector3 U)
        {
            Vector3 D = (P - O);
            Vector3 Right = Vector3.Cross(U, D);
            Vector3.Normalize(ref Right, out Right);
            Vector3 Backwards = Vector3.Cross(Right, U);
            Vector3.Normalize(ref Backwards, out Backwards);
            Vector3 Up = Vector3.Cross(Backwards, Right);

            //D.Normalize();

            //roll = (float)Math.Asin(D.Z);
            //yaw = (float)Math.Acos(D.X / Math.Cos(roll));
            ////if (D.Y < 0)
            ////    yaw = MathHelper.TwoPi - yaw;
            //ResetYawPitchRoll();

            LocalRotationMatrix.M11 = Right.X;
            LocalRotationMatrix.M12 = Right.Y;
            LocalRotationMatrix.M13 = Right.Z;
            LocalRotationMatrix.M14 = 0;
            LocalRotationMatrix.M21 = Up.X;
            LocalRotationMatrix.M22 = Up.Y;
            LocalRotationMatrix.M23 = Up.Z;
            LocalRotationMatrix.M24 = 0;
            LocalRotationMatrix.M31 = Backwards.X;
            LocalRotationMatrix.M32 = Backwards.Y;
            LocalRotationMatrix.M33 = Backwards.Z;
            LocalRotationMatrix.M34 = 0;
            LocalRotationMatrix.M41 = 0;
            LocalRotationMatrix.M42 = 0;
            LocalRotationMatrix.M43 = 0;
            LocalRotationMatrix.M44 = 1;
        }