示例#1
0
        /// <summary>
        /// Solve A * x = b, where b is a column vector. This is more efficient
        /// than computing the inverse in one-shot cases.
        /// </summary>
        /// <param name="b">The b.</param>
        /// <returns></returns>
        public FVector3 Solve33(FVector3 b)
        {
            float det = FVector3.Dot(ex, FVector3.Cross(ey, ez));

            if (det != 0.0f)
            {
                det = 1.0f / det;
            }

            return(new FVector3(det * FVector3.Dot(b, FVector3.Cross(ey, ez)),
                                det * FVector3.Dot(ex, FVector3.Cross(b, ez)),
                                det * FVector3.Dot(ex, FVector3.Cross(ey, b))));
        }
示例#2
0
        public static void CreateBillboard(ref FVector3 objectPosition, ref FVector3 cameraPosition,
                                           ref FVector3 cameraUpVector, FVector3?cameraForwardVector, out FMatrix result)
        {
            FVector3 translation = objectPosition - cameraPosition;
            FVector3 backwards, right, up;

            FVector3.Normalize(ref translation, out backwards);
            FVector3.Normalize(ref cameraUpVector, out up);
            FVector3.Cross(ref backwards, ref up, out right);
            FVector3.Cross(ref backwards, ref right, out up);
            result             = Identity;
            result.Backward    = backwards;
            result.Right       = right;
            result.Up          = up;
            result.Translation = translation;
        }
示例#3
0
        public static void CreateWorld(ref FVector3 position, ref FVector3 forward, ref FVector3 up, out FMatrix result)
        {
            FVector3 x, y, z;

            FVector3.Normalize(ref forward, out z);
            FVector3.Cross(ref forward, ref up, out x);
            FVector3.Cross(ref x, ref forward, out y);
            x.Normalize();
            y.Normalize();

            result             = new FMatrix();
            result.Right       = x;
            result.Up          = y;
            result.Forward     = z;
            result.Translation = position;
            result.M44         = 1f;
        }
示例#4
0
        public static void CreateLookAt(ref FVector3 cameraPosition, ref FVector3 cameraTarget, ref FVector3 cameraUpVector,
                                        out FMatrix result)
        {
            // http://msdn.microsoft.com/en-us/library/bb205343(v=VS.85).aspx

            FVector3 vz = FVector3.Normalize(cameraPosition - cameraTarget);
            FVector3 vx = FVector3.Normalize(FVector3.Cross(cameraUpVector, vz));
            FVector3 vy = FVector3.Cross(vz, vx);

            result     = Identity;
            result.M11 = vx.X;
            result.M12 = vy.X;
            result.M13 = vz.X;
            result.M21 = vx.Y;
            result.M22 = vy.Y;
            result.M23 = vz.Y;
            result.M31 = vx.Z;
            result.M32 = vy.Z;
            result.M33 = vz.Z;
            result.M41 = -FVector3.Dot(vx, cameraPosition);
            result.M42 = -FVector3.Dot(vy, cameraPosition);
            result.M43 = -FVector3.Dot(vz, cameraPosition);
        }
示例#5
0
        public static FMatrix CreateLookAt(FVector3 cameraPosition, FVector3 cameraTarget, FVector3 cameraUpVector)
        {
            FMatrix ret;

            CreateLookAt(ref cameraPosition, ref cameraTarget, ref cameraUpVector, out ret);
            return(ret);
        }
示例#6
0
 public static void CreateFromAxisAngle(ref FVector3 axis, float angle, out FMatrix result)
 {
     throw new NotImplementedException();
 }
示例#7
0
 public static FMatrix CreateFromAxisAngle(FVector3 axis, float angle)
 {
     throw new NotImplementedException();
 }
示例#8
0
 public static void CreateConstrainedBillboard(ref FVector3 objectPosition, ref FVector3 cameraPosition,
                                               ref FVector3 rotateAxis, FVector3?cameraForwardVector,
                                               FVector3?objectForwardVector, out FMatrix result)
 {
     throw new NotImplementedException();
 }
示例#9
0
 public static FMatrix CreateConstrainedBillboard(FVector3 objectPosition, FVector3 cameraPosition,
                                                  FVector3 rotateAxis, Nullable <FVector3> cameraForwardVector,
                                                  Nullable <FVector3> objectForwardVector)
 {
     throw new NotImplementedException();
 }
示例#10
0
 /// <summary>
 /// Set this matrix to all zeros.
 /// </summary>
 public void SetZero()
 {
     ex = FVector3.Zero;
     ey = FVector3.Zero;
     ez = FVector3.Zero;
 }
示例#11
0
 /// <summary>
 /// Construct this matrix using columns.
 /// </summary>
 /// <param name="c1">The c1.</param>
 /// <param name="c2">The c2.</param>
 /// <param name="c3">The c3.</param>
 public Mat33(FVector3 c1, FVector3 c2, FVector3 c3)
 {
     ex = c1;
     ey = c2;
     ez = c3;
 }
示例#12
0
 /// Perform the cross product on two vectors.
 public static FVector3 Cross(FVector3 a, FVector3 b)
 {
     return(new FVector3(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X));
 }
示例#13
0
 /// Perform the dot product on two vectors.
 public static float Dot(FVector3 a, FVector3 b)
 {
     return(a.X * b.X + a.Y * b.Y + a.Z * b.Z);
 }
示例#14
0
 /// Multiply a matrix times a vector.
 public static FVector3 Mul(Mat33 A, FVector3 v)
 {
     return(v.X * A.ex + v.Y * A.ey + v.Z * A.ez);
 }