Package gov.nasa.worldwind.geom
Class Frustum
- java.lang.Object
-
- gov.nasa.worldwind.geom.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 Summary
Constructors Constructor Description 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(Plane left, Plane right, Plane bottom, Plane top, Plane near, Plane far, Viewport viewport)
Constructs a frustum.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsPoint(Vec3 point)
boolean
intersectsSegment(Vec3 pointA, Vec3 pointB)
Determines whether a line segment intersects this frustum.boolean
intersectsViewport(Viewport viewport)
Determines whether a screen coordinate viewport intersects this frustum.Frustum
setToModelviewProjection(Matrix4 projection, Matrix4 modelview, Viewport viewport)
Sets this frustum to one appropriate for a modelview-projection matrix.Frustum
setToModelviewProjection(Matrix4 projection, Matrix4 modelview, Viewport viewport, Viewport subViewport)
Sets this frustum to one appropriate for a subset of a modelview-projection matrix.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.
-
-
-
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 planeright
- the frustum's right planebottom
- the frustum's bottom planetop
- the frustum's top planenear
- the frustum's near planefar
- the frustum's far planeviewport
- 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 frommodelview
- the modelview matrix defining the frustum's position and orientation in Cartesian coordinatesviewport
- 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 frommodelview
- the modelview matrix defining the frustum's position and orientation in Cartesian coordinatesviewport
- the screen coordinate viewport corresponding to the projection matrixsubViewport
- 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 endpointpointB
- 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
-
-