public class Frustum extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Frustum.Corners
Holds the eight corner points of a frustum.
|
Modifier and Type | Field and Description |
---|---|
protected Plane[] |
allPlanes
Holds all six frustum planes in an array in the order left, right, bottom, top, near, far.
|
protected Plane |
bottom |
protected Plane |
far |
protected Plane |
left |
protected Plane |
near |
protected Plane |
right |
protected Plane |
top |
Constructor and Description |
---|
Frustum()
Constructs a frustum two meters wide centered at the origin.
|
Frustum(Plane left,
Plane right,
Plane bottom,
Plane top,
Plane near,
Plane far)
Create a frustum from six
Plane s defining the frustum boundaries. |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Extent extent)
Indicates whether a specified
Extent is fully within this frustum. |
boolean |
contains(Vec4 point)
Indicates whether a specified point is within this frustum.
|
boolean |
equals(Object obj) |
static Frustum |
fromPerspective(Angle horizontalFieldOfView,
int viewportWidth,
int viewportHeight,
double near,
double far)
Creates a
Frustum from a horizontal field-of-view, viewport aspect ratio and distance to near and
far depth clipping planes. |
static Frustum |
fromPerspective(double width,
double height,
double near,
double far)
Creates a
Frustum from three sets of parallel clipping planes (a parallel projectionMatrix). |
static Frustum |
fromPerspectiveVecs(Vec4 vTL,
Vec4 vTR,
Vec4 vBL,
Vec4 vBR,
double near,
double far)
Creates a
Frustum from four edge vectors, viewport aspect ratio and distance to near and far planes. |
static Frustum |
fromProjectionMatrix(Matrix projectionMatrix)
Creates a frustum by extracting the six frustum planes from a projection matrix.
|
Plane[] |
getAllPlanes()
Returns all the planes.
|
Plane |
getBottom()
Returns the bottom plane.
|
Frustum.Corners |
getCorners()
Returns the eight corners of this frustum.
|
Plane |
getFar()
Returns the far plane.
|
Plane |
getLeft()
Returns the left plane.
|
Plane |
getNear()
Returns the near plane.
|
Plane |
getRight()
Returns the right plane.
|
Plane |
getTop()
Returns the top plane.
|
int |
hashCode() |
boolean |
intersects(Extent extent)
Indicates whether a specified
Extent intersects this frustum. |
boolean |
intersectsSegment(Vec4 pa,
Vec4 pb)
Determines whether a line segment intersects this frustum.
|
String |
toString() |
Frustum |
transformBy(Matrix matrix)
Returns a copy of this frustum transformed by a specified
Matrix . |
protected final Plane[] allPlanes
protected final Plane bottom
protected final Plane far
protected final Plane left
protected final Plane near
protected final Plane right
protected final Plane top
public Frustum()
public Frustum(Plane left, Plane right, Plane bottom, Plane top, Plane near, Plane far)
Plane
s defining the frustum boundaries.
None of the arguments may be null.near
- the near planefar
- the far planeleft
- the left planeright
- the right planetop
- the top planebottom
- the bottom planeIllegalArgumentException
- if any argument is null.public final boolean contains(Extent extent)
Extent
is fully within this frustum.extent
- the Extent to test.IllegalArgumentException
- if the extent is null.public final boolean contains(Vec4 point)
point
- the point to test.IllegalArgumentException
- if the point is null.public static Frustum fromPerspective(Angle horizontalFieldOfView, int viewportWidth, int viewportHeight, double near, double far)
Frustum
from a horizontal field-of-view, viewport aspect ratio and distance to near and
far depth clipping planes. The near plane must be closer than the far plane, and both near and far values must be
positive.horizontalFieldOfView
- horizontal field-of-view angle in the range (0, 180)viewportWidth
- the width of the viewport in screen pixelsviewportHeight
- the height of the viewport in screen pixelsnear
- distance to the near depth clipping planefar
- distance to far depth clipping planeIllegalArgumentException
- if fov is not in the range (0, 180), if either near or far are negative, or near
is greater than or equal to farpublic static Frustum fromPerspective(double width, double height, double near, double far)
Frustum
from three sets of parallel clipping planes (a parallel projectionMatrix). In this
case, the near and far depth clipping planes may be negative.near
- distance to the near depth clipping planefar
- distance to far depth clipping planewidth
- horizontal dimension of the near clipping planeheight
- vertical dimension of the near clipping planeIllegalArgumentException
- if the difference of any plane set (lright - left, top - bottom, far - near) is
less than or equal to zero.public static Frustum fromPerspectiveVecs(Vec4 vTL, Vec4 vTR, Vec4 vBL, Vec4 vBR, double near, double far)
Frustum
from four edge vectors, viewport aspect ratio and distance to near and far planes.
The edge vectors connect the near corners of the frustum to the far corners. The near plane must be closer than
the far plane, and both planes must be positive.vTL
- vector defining the top-left of the frustumvTR
- vector defining the top-right of the frustumvBL
- vector defining the bottom-left of the frustumvBR
- vector defining the bottom-right of the frustumnear
- distance to the near planefar
- distance to far planeIllegalArgumentException
- if any of the vectors are null, if either near or far are negative, or near is
greater than or equal to farpublic static Frustum fromProjectionMatrix(Matrix projectionMatrix)
projectionMatrix
- the projection matrix to extract the frustum planes from.IllegalArgumentException
- if the projection matrix is null.public Plane[] getAllPlanes()
public final Plane getBottom()
public Frustum.Corners getCorners()
public final Plane getFar()
public final Plane getLeft()
public final Plane getNear()
public final Plane getRight()
public final Plane getTop()
public boolean intersects(Extent extent)
Extent
intersects this frustum.extent
- the Extent to test.IllegalArgumentException
- if the extent is null.public boolean intersectsSegment(Vec4 pa, Vec4 pb)
pa
- one end of the segment.pb
- the other end of the segment.IllegalArgumentException
- if either point is null.public Frustum transformBy(Matrix matrix)
Matrix
.matrix
- the Matrix to apply to this frustum.IllegalArgumentException
- if the matrix is null.