Example #1
0
 public static void Update(FrustumCone f, Vector3 origin, Matrix4 view, Matrix4 proj)
 {
     f.Origin = origin;
     var inVP = Matrix4.Mult(view, proj).Inverted();
     f.LeftBottom = GetDir(origin, new Vector2(-1, -1), inVP);
     f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP);
     f.LeftTop = GetDir(origin, new Vector2(-1, 1), inVP);
     f.RightTop = GetDir(origin, new Vector2(1, 1), inVP);
 }
Example #2
0
            public static void Update(FrustumCone f, Vector3 origin, Matrix4 view, Matrix4 proj)
            {
                f.Origin = origin;
                var inVP = Matrix4.Mult(view, proj).Inverted();

                f.LeftBottom  = GetDir(origin, new Vector2(-1, -1), inVP);
                f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP);
                f.LeftTop     = GetDir(origin, new Vector2(-1, 1), inVP);
                f.RightTop    = GetDir(origin, new Vector2(1, 1), inVP);
            }
Example #3
0
 public static FrustumCone Create(Vector3 origin, Matrix4 view, Matrix4 proj)
 {
     var f = new FrustumCone();
     f.Origin = origin;
     var inVP = Matrix4.Mult(view, proj).Inverted();
     f.LeftBottom = GetDir(origin, new Vector2(-1, -1), inVP);
     f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP);
     f.LeftTop = GetDir(origin, new Vector2(-1, 1), inVP);
     f.RightTop = GetDir(origin, new Vector2(1, 1), inVP);
     return f;
 }
Example #4
0
            public static FrustumCone Create(Vector3 origin, Matrix4 view, Matrix4 proj)
            {
                var f = new FrustumCone();

                f.Origin = origin;
                var inVP = Matrix4.Mult(view, proj).Inverted();

                f.LeftBottom  = GetDir(origin, new Vector2(-1, -1), inVP);
                f.RightBottom = GetDir(origin, new Vector2(1, -1), inVP);
                f.LeftTop     = GetDir(origin, new Vector2(-1, 1), inVP);
                f.RightTop    = GetDir(origin, new Vector2(1, 1), inVP);
                return(f);
            }
Example #5
0
        public void Update()
        {
            lock (Transformation)
            {
                var tRotationMatrix = Matrix4.CreateFromQuaternion(Transformation.GetOrientation().Inverted());
                var tViewMatrix     = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix;

                if (cone == null)
                {
                    var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix);
                    cone = tcone;
                }
                else
                {
                    FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix);
                }

                RotationMatrix = tRotationMatrix;
                ViewMatrix     = tViewMatrix;
                VPMatrix       = Matrix4.Mult(ViewMatrix, ProjectionMatrix);
            }
        }
Example #6
0
        public void UpdateFromRollPitch()
        {
            lock (Transformation)
            {
                var rotationX = Quaternion.FromAxisAngle(Vector3.UnitY, Pitch);
                var rotationY = Quaternion.FromAxisAngle(Vector3.UnitX, Roll);
                Transformation.SetOrientation(Quaternion.Multiply(rotationX.Inverted(), rotationY.Inverted()));
                var tRotationMatrix = Matrix4.CreateFromQuaternion(rotationX) * Matrix4.CreateFromQuaternion(rotationY);
                var tViewMatrix     = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix;

                if (cone == null)
                {
                    var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix);
                    cone = tcone;
                }
                else
                {
                    FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix);
                }
                RotationMatrix = tRotationMatrix;
                ViewMatrix     = tViewMatrix;
                VPMatrix       = Matrix4.Mult(ViewMatrix, ProjectionMatrix);
            }
        }
Example #7
0
        public void UpdateFromRollPitch()
        {
            var rotationX = Quaternion.FromAxisAngle(Vector3.UnitY, Pitch);
            var rotationY = Quaternion.FromAxisAngle(Vector3.UnitX, Roll);
            Transformation.SetOrientation(Quaternion.Multiply(rotationX.Inverted(), rotationY.Inverted()));
            RotationMatrix = Matrix4.CreateFromQuaternion(rotationX) * Matrix4.CreateFromQuaternion(rotationY);
            ViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix;

            if(cone == null)
            {
                var tcone = FrustumCone.Create(Transformation.GetPosition(), ViewMatrix, ProjectionMatrix);
                cone = tcone;
            }
            else
                FrustumCone.Update(cone, Transformation.GetPosition(), ViewMatrix, ProjectionMatrix);
        }
Example #8
0
        public void Update()
        {
            lock (Transformation)
            {
                var tRotationMatrix = Matrix4.CreateFromQuaternion(Transformation.GetOrientation().Inverted());
                var tViewMatrix = Matrix4.CreateTranslation(-Transformation.GetPosition()) * RotationMatrix;

                if(cone == null)
                {
                    var tcone = FrustumCone.Create(Transformation.GetPosition(), tViewMatrix, ProjectionMatrix);
                    cone = tcone;
                } else FrustumCone.Update(cone, Transformation.GetPosition(), tViewMatrix, ProjectionMatrix);

                RotationMatrix = tRotationMatrix;
                ViewMatrix = tViewMatrix;
            }
        }