Class Frustum


  • public class Frustum
    extends java.lang.Object
    Represents a six-sided view frustum in Cartesian coordinates with a corresponding viewport in screen coordinates.
    • Constructor Detail

      • Frustum

        public Frustum()
        Constructs a new unit frustum with each of its planes 1 meter from the center and a viewport with width and height both 1.
      • Frustum

        public Frustum​(Plane left,
                       Plane right,
                       Plane bottom,
                       Plane top,
                       Plane near,
                       Plane far,
                       Viewport viewport)
        Constructs a frustum.
        Parameters:
        left - the frustum's left plane
        right - the frustum's right plane
        bottom - the frustum's bottom plane
        top - the frustum's top plane
        near - the frustum's near plane
        far - the frustum's far plane
        viewport - the frustum's viewport
        Throws:
        java.lang.IllegalArgumentException - If any argument is null
    • Method Detail

      • setToUnitFrustum

        public Frustum setToUnitFrustum()
        Sets this frustum to a unit frustum with each of its planes 1 meter from the center a viewport with width and height both 1.
        Returns:
        this frustum, set to a unit frustum
      • setToModelviewProjection

        public Frustum setToModelviewProjection​(Matrix4 projection,
                                                Matrix4 modelview,
                                                Viewport viewport)
        Sets this frustum to one appropriate for a modelview-projection matrix. A modelview-projection matrix's view frustum is a Cartesian volume that contains everything visible in a scene displayed using that modelview-projection matrix.
        This method assumes that the specified matrices represents a projection matrix and a modelview matrix respectively. If this is not the case the results are undefined.
        Parameters:
        projection - the projection matrix to extract the frustum from
        modelview - the modelview matrix defining the frustum's position and orientation in Cartesian coordinates
        viewport - the screen coordinate viewport corresponding to the projection matrix
        Returns:
        this frustum, with its planes set to the modelview-projection matrix's view frustum, in Cartesian coordinates
        Throws:
        java.lang.IllegalArgumentException - If any argument is null
      • setToModelviewProjection

        public Frustum setToModelviewProjection​(Matrix4 projection,
                                                Matrix4 modelview,
                                                Viewport viewport,
                                                Viewport subViewport)
        Sets this frustum to one appropriate for a subset of a modelview-projection matrix. A modelview-projection matrix's view frustum is a Cartesian volume that contains everything visible in a scene displayed using that modelview-projection matrix. The subset is defined by the region within the original viewport that the frustum contains.
        This method assumes that the specified matrices represents a projection matrix and a modelview matrix respectively. If this is not the case the results are undefined.
        Parameters:
        projection - the projection matrix to extract the frustum from
        modelview - the modelview matrix defining the frustum's position and orientation in Cartesian coordinates
        viewport - the screen coordinate viewport corresponding to the projection matrix
        subViewport - the screen coordinate region the frustum should contain
        Returns:
        this frustum, with its planes set to the modelview-projection matrix's view frustum, in Cartesian coordinates
        Throws:
        java.lang.IllegalArgumentException - If any argument is null
      • containsPoint

        public boolean containsPoint​(Vec3 point)
      • intersectsSegment

        public boolean intersectsSegment​(Vec3 pointA,
                                         Vec3 pointB)
        Determines whether a line segment intersects this frustum.
        Parameters:
        pointA - the first line segment endpoint
        pointB - the second line segment endpoint
        Returns:
        true if the segment intersects or is contained in this frustum, otherwise false
        Throws:
        java.lang.IllegalArgumentException - If either point is null
      • intersectsViewport

        public boolean intersectsViewport​(Viewport viewport)
        Determines whether a screen coordinate viewport intersects this frustum.
        Parameters:
        viewport - the viewport to test
        Returns:
        true if the viewport intersects or is contained in this frustum, otherwise false
        Throws:
        java.lang.IllegalArgumentException - If the viewport is null