Esempio n. 1
0
        public unsafe Sphere GetTranformed(Matrix matrix)
        {
            Sphere  sphere = new Sphere();
            Vector3 center = Center;

            Vector3.TransformCoordinates(ref center, ref matrix, out sphere.Center);
            if (Radius > 0)
            {
                sphere.Radius = Math.Max(new Vector3(Radius * matrix.M11, Radius * matrix.M12, Radius * matrix.M13).Length(),
                                         Math.Max(new Vector3(Radius * matrix.M21, Radius * matrix.M22, Radius * matrix.M23).Length(),
                                                  new Vector3(Radius * matrix.M31, Radius * matrix.M32, Radius * matrix.M33).Length()));
            }
            return(sphere);
        }
Esempio n. 2
0
        public void Transform(Matrix invViewProj)
        {
            unsafe
            {
                for (int i = 0; i < 8; i++)
                {
                    Vector3.TransformCoordinates(ref HsBox[i], ref invViewProj, out CornersWorld[i]);
                }

                planes[0] = new Plane(CornersWorld[7], CornersWorld[3], CornersWorld[5]); // Right
                planes[1] = new Plane(CornersWorld[2], CornersWorld[6], CornersWorld[4]); // Left
                planes[2] = new Plane(CornersWorld[6], CornersWorld[7], CornersWorld[5]); // Far
                planes[3] = new Plane(CornersWorld[0], CornersWorld[1], CornersWorld[2]); // Near
                planes[4] = new Plane(CornersWorld[2], CornersWorld[3], CornersWorld[6]); // Top
                planes[5] = new Plane(CornersWorld[1], CornersWorld[0], CornersWorld[4]); // Bottom
            }
        }