コード例 #1
0
ファイル: Camera.cs プロジェクト: Keldyn/BattleOfTheClans
        public Common.Bounding.Frustum FrustumFromRectangle(SlimDX.Direct3D9.Viewport viewport, Vector2 topLeft, Vector2 bottomRight)
        {
            Common.Bounding.Frustum f = new Common.Bounding.Frustum();
            f.planes = new Plane[6];
            Vector3 ntl = Vector3.Unproject(new Vector3(topLeft.X, topLeft.Y, ZNear), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);
            Vector3 ntr = Vector3.Unproject(new Vector3(bottomRight.X, topLeft.Y, ZNear), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);
            Vector3 nbl = Vector3.Unproject(new Vector3(topLeft.X, bottomRight.Y, ZNear), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);
            Vector3 nbr = Vector3.Unproject(new Vector3(bottomRight.X, bottomRight.Y, ZNear), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);

            Vector3 ftl = Vector3.Unproject(new Vector3(topLeft.X, topLeft.Y, ZFar), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);
            Vector3 ftr = Vector3.Unproject(new Vector3(bottomRight.X, topLeft.Y, ZFar), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);
            Vector3 fbl = Vector3.Unproject(new Vector3(topLeft.X, bottomRight.Y, ZFar), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);
            Vector3 fbr = Vector3.Unproject(new Vector3(bottomRight.X, bottomRight.Y, ZFar), viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinZ, viewport.MaxZ, View * Projection);

            f.planes[(int)Common.Bounding.FrustumPlanes.Left] = new Plane(ntl, nbl, ftl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Top] = new Plane(ntl, ftl, ntr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Right] = new Plane(ntr, ftr, nbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Bottom] = new Plane(nbl, nbr, fbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Near] = new Plane(ntl, ntr, nbl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Far] = new Plane(ftr, ftl, fbl);
            return f;
        }
コード例 #2
0
        public static Common.Bounding.Frustum Frustum(Matrix viewProjection)
        {
            Common.Bounding.Frustum f = new Common.Bounding.Frustum();
            f.planes = new Plane[6];
            Vector3[] corners = GetCornersFromRectangle(viewProjection);
            Vector3   ntl     = corners[0];
            Vector3   ntr     = corners[1];
            Vector3   nbl     = corners[2];
            Vector3   nbr     = corners[3];

            Vector3 ftl = corners[4];
            Vector3 ftr = corners[5];
            Vector3 fbl = corners[6];
            Vector3 fbr = corners[7];

            f.planes[(int)Common.Bounding.FrustumPlanes.Left]   = new Plane(ntl, nbl, ftl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Top]    = new Plane(ntl, ftl, ntr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Right]  = new Plane(ntr, ftr, nbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Bottom] = new Plane(nbl, nbr, fbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Near]   = new Plane(ntl, ntr, nbl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Far]    = new Plane(ftr, ftl, fbl);
            return(f);
        }
コード例 #3
0
        public Common.Bounding.Frustum FrustumFromRectangle(Viewport viewport, System.Drawing.Point topLeft, System.Drawing.Point bottomRight)
        {
            Common.Bounding.Frustum f = new Common.Bounding.Frustum();
            f.planes = new Plane[6];
            Vector3[] corners = GetCornersFromRectangle(viewport, topLeft, bottomRight);
            Vector3   ntl     = corners[0];
            Vector3   ntr     = corners[1];
            Vector3   nbl     = corners[2];
            Vector3   nbr     = corners[3];

            Vector3 ftl = corners[4];
            Vector3 ftr = corners[5];
            Vector3 fbl = corners[6];
            Vector3 fbr = corners[7];

            f.planes[(int)Common.Bounding.FrustumPlanes.Left]   = new Plane(ntl, nbl, ftl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Top]    = new Plane(ntl, ftl, ntr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Right]  = new Plane(ntr, ftr, nbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Bottom] = new Plane(nbl, nbr, fbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Near]   = new Plane(ntl, ntr, nbl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Far]    = new Plane(ftr, ftl, fbl);
            return(f);
        }
コード例 #4
0
        public static Common.Bounding.Frustum Frustum(Matrix viewProjection)
        {
            Common.Bounding.Frustum f = new Common.Bounding.Frustum();
            f.planes = new Plane[6];
            Vector3[] corners = GetCornersFromRectangle(viewProjection);
            Vector3 ntl = corners[0];
            Vector3 ntr = corners[1];
            Vector3 nbl = corners[2];
            Vector3 nbr = corners[3];

            Vector3 ftl = corners[4];
            Vector3 ftr = corners[5];
            Vector3 fbl = corners[6];
            Vector3 fbr = corners[7];

            f.planes[(int)Common.Bounding.FrustumPlanes.Left] = new Plane(ntl, nbl, ftl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Top] = new Plane(ntl, ftl, ntr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Right] = new Plane(ntr, ftr, nbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Bottom] = new Plane(nbl, nbr, fbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Near] = new Plane(ntl, ntr, nbl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Far] = new Plane(ftr, ftl, fbl);
            return f;
        }
コード例 #5
0
 public static bool Intersect(Common.Bounding.Frustum a, MetaBoundingBox b, out object intersection)
 {
     return(Common.Intersection.Intersect(a, b.GetBoundingBox(content).Value, out intersection));
 }
コード例 #6
0
 public static bool Intersect(Common.Bounding.Frustum a, BoundingMetaMesh b, out object intersection)
 {
     intersection = null;
     // Hack! Never actually compares against bounding meta meshes.
     return(true);
 }
コード例 #7
0
        public Common.Bounding.Frustum FrustumFromRectangle(Viewport viewport, System.Drawing.Point topLeft, System.Drawing.Point bottomRight)
        {
            Common.Bounding.Frustum f = new Common.Bounding.Frustum();
            f.planes = new Plane[6];
            Vector3[] corners = GetCornersFromRectangle(viewport, topLeft, bottomRight);
            Vector3 ntl = corners[0];
            Vector3 ntr = corners[1];
            Vector3 nbl = corners[2];
            Vector3 nbr = corners[3];

            Vector3 ftl = corners[4];
            Vector3 ftr = corners[5];
            Vector3 fbl = corners[6];
            Vector3 fbr = corners[7];

            f.planes[(int)Common.Bounding.FrustumPlanes.Left] = new Plane(ntl, nbl, ftl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Top] = new Plane(ntl, ftl, ntr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Right] = new Plane(ntr, ftr, nbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Bottom] = new Plane(nbl, nbr, fbr);
            f.planes[(int)Common.Bounding.FrustumPlanes.Near] = new Plane(ntl, ntr, nbl);
            f.planes[(int)Common.Bounding.FrustumPlanes.Far] = new Plane(ftr, ftl, fbl);
            return f;
        }