/// <summary>
 /// Checks whether the current BoundingFrustum intersects the specified Plane.
 /// </summary>
 /// <param name="plane">The plane.</param>
 /// <param name="result">Plane intersection type.</param>
 public void Intersects(ref MyPlane plane, out MyPlaneIntersectionType result)
 {
     result = PlaneIntersectsPoints(ref plane, GetCorners());
 }
Beispiel #2
0
 /// <summary>
 /// Determines if there is an intersection between the current object and a <see cref="MyPlane"/>.
 /// </summary>
 /// <param name="plane">The plane to test.</param>
 /// <returns>Whether the two objects intersected.</returns>
 public MyPlaneIntersectionType Intersects(ref MyPlane plane)
 {
     return(MyCollision.PlaneIntersectsSphere(ref plane, ref this));
 }
 /// <summary>
 /// Checks whether the current BoundingFrustum intersects the specified Plane.
 /// </summary>
 /// <param name="plane">The plane.</param>
 /// <returns>Plane intersection type.</returns>
 public MyPlaneIntersectionType Intersects(ref MyPlane plane)
 {
     return(PlaneIntersectsPoints(ref plane, GetCorners()));
 }
        private static MyVector3 Get3PlanesInterPoint(ref MyPlane p1, ref MyPlane p2, ref MyPlane p3)
        {
            //P = -d1 * N2xN3 / N1.N2xN3 - d2 * N3xN1 / N2.N3xN1 - d3 * N1xN2 / N3.N1xN2
            MyVector3 v =
                -p1.D * MyVector3.Cross(p2.Normal, p3.Normal) / MyVector3.Dot(p1.Normal, MyVector3.Cross(p2.Normal, p3.Normal))
                - p2.D * MyVector3.Cross(p3.Normal, p1.Normal) / MyVector3.Dot(p2.Normal, MyVector3.Cross(p3.Normal, p1.Normal))
                - p3.D * MyVector3.Cross(p1.Normal, p2.Normal) / MyVector3.Dot(p3.Normal, MyVector3.Cross(p1.Normal, p2.Normal));

            return(v);
        }
        private static void GetPlanesFromMatrix(ref MyMatrix matrix, out MyPlane near, out MyPlane far, out MyPlane left, out MyPlane right, out MyPlane top, out MyPlane bottom)
        {
            //http://www.chadvernon.com/blog/resources/directx9/frustum-culling/

            // Left plane
            left.Normal.X = matrix.M14 + matrix.M11;
            left.Normal.Y = matrix.M24 + matrix.M21;
            left.Normal.Z = matrix.M34 + matrix.M31;
            left.D        = matrix.M44 + matrix.M41;
            left.Normalize();

            // Right plane
            right.Normal.X = matrix.M14 - matrix.M11;
            right.Normal.Y = matrix.M24 - matrix.M21;
            right.Normal.Z = matrix.M34 - matrix.M31;
            right.D        = matrix.M44 - matrix.M41;
            right.Normalize();

            // Top plane
            top.Normal.X = matrix.M14 - matrix.M12;
            top.Normal.Y = matrix.M24 - matrix.M22;
            top.Normal.Z = matrix.M34 - matrix.M32;
            top.D        = matrix.M44 - matrix.M42;
            top.Normalize();

            // Bottom plane
            bottom.Normal.X = matrix.M14 + matrix.M12;
            bottom.Normal.Y = matrix.M24 + matrix.M22;
            bottom.Normal.Z = matrix.M34 + matrix.M32;
            bottom.D        = matrix.M44 + matrix.M42;
            bottom.Normalize();

            // Near plane
            near.Normal.X = matrix.M13;
            near.Normal.Y = matrix.M23;
            near.Normal.Z = matrix.M33;
            near.D        = matrix.M43;
            near.Normalize();

            // Far plane
            far.Normal.X = matrix.M14 - matrix.M13;
            far.Normal.Y = matrix.M24 - matrix.M23;
            far.Normal.Z = matrix.M34 - matrix.M33;
            far.D        = matrix.M44 - matrix.M43;
            far.Normalize();
        }
Beispiel #6
0
 /// <summary>
 /// Determines if there is an intersection between the current object and a <see cref="MyPlane"/>.
 /// </summary>
 /// <param name="plane">The plane to test.</param>
 /// <param name="point">When the method completes, contains the point of intersection,
 /// or <see cref="MyVector3.Zero"/> if there was no intersection.</param>
 /// <returns>Whether the two objects intersected.</returns>
 public bool Intersects(ref MyPlane plane, out MyVector3 point)
 {
     return(MyCollision.RayIntersectsPlane(ref this, ref plane, out point));
 }
Beispiel #7
0
 /// <summary>
 /// Determines if there is an intersection between the current object and a <see cref="MyPlane"/>.
 /// </summary>
 /// <param name="plane">The plane to test.</param>
 /// <param name="distance">When the method completes, contains the distance of the intersection,
 /// or 0 if there was no intersection.</param>
 /// <returns>Whether the two objects intersected.</returns>
 public bool Intersects(ref MyPlane plane, out float distance)
 {
     return(MyCollision.RayIntersectsPlane(ref this, ref plane, out distance));
 }