Exemple #1
0
        private static Matrix RotateToFace(Vector3 o, Vector3 p, Vector3 u)
        {
            var d = Vector3.Normalize(o - p);
            var s = Vector3.Normalize(Vector3.Cross(Vector3.Normalize(u), d));
            var v = Vector3.Normalize(Vector3.Cross(d, s));

            return(SlimDxExtension.ToMatrix(
                       v.X, v.Y, v.Z, 0,
                       d.X, d.Y, d.Z, 0,
                       s.X, s.Y, s.Z, 0,
                       o.X, o.Y, o.Z, 1));
        }
Exemple #2
0
        private static Matrix RotateToFaceDirSpecial(Vector3 o, Vector3 p, Vector3 u)
        {
            var d = Vector3.Normalize(p - o);
            var s = Vector3.Normalize(Vector3.Cross(d, Vector3.Normalize(u)));
            var v = Vector3.Cross(s, d);

            return(SlimDxExtension.ToMatrix(
                       d.X, d.Y, d.Z, 0,
                       v.X, v.Y, v.Z, 0,
                       s.X, s.Y, s.Z, 0,
                       o.X, o.Y, o.Z, 1));
        }