コード例 #1
0
ファイル: Camera.cs プロジェクト: lanicon/Theta
        private static Matrix <float> ComputeViewMatrix(Vector <float> eye, Vector <float> target, Vector <float> up)
        {
            Code.AssertArgNonNull(eye, "eye");
            Code.AssertArgNonNull(target, "target");
            Code.AssertArgNonNull(up, "up");

            Code.Assert <ArgumentException>(eye.Dimensions == 3, "The eye vector must be 3 dimensional.");
            Code.Assert <ArgumentException>(target.Dimensions == 3, "The target vector must be 3 dimensional.");
            Code.Assert <ArgumentException>(up.Dimensions == 3, "The up vector must be 3 dimensional.");

            Vector <float> z = Vector <float> .Normalize(eye - target);

            Vector <float> x = Vector <float> .Normalize(Vector <float> .CrossProduct(up, z));

            Vector <float> y = Vector <float> .Normalize(Vector <float> .CrossProduct(z, x));

            Matrix <float> result = new Matrix <float>(new float[, ]
            {
                { x.X, y.X, z.X, 0 },
                { x.Y, y.Y, z.Y, 0 },
                { x.Z, y.Z, z.Z, 0 },
                { -((x.X * eye.X) + (x.Y * eye.Y) + (x.Z * eye.Z)), -((y.X * eye.X) + (y.Y * eye.Y) + (y.Z * eye.Z)), -((z.X * eye.X) + (z.Y * eye.Y) + (z.Z * eye.Z)), 1 },
            });

            return(result);
        }
コード例 #2
0
 public void AddBody(RigidPhysicsObject <T> rigidPhysicsObject)
 {
     Code.AssertArgNonNull(rigidPhysicsObject, "rigidPhysicsObject");
     this._rigidPhysicsObjects.Add(rigidPhysicsObject);
 }