Package com.jogamp.opengl.math.geom
Class Frustum
java.lang.Object
com.jogamp.opengl.math.geom.Frustum
Providing frustum
planes
derived by different inputs
(P*MV
, ..) used to classify objects
and to test whether they are outside
Extracting the world-frustum planes from the P*Mv:
Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix Gil Gribb <ggribb@ravensoft.com> Klaus Hartmann <k_hartmann@osnabrueck.netsurf.de> http://graphics.cs.ucf.edu/cap4720/fall2008/plane_extraction.pdfClassifying Point, Sphere and AABBox:
Efficient View Frustum Culling Daniel Sýkora <sykorad@fel.cvut.cz> Josef Jelínek <jelinej1@fel.cvut.cz> http://www.cg.tuwien.ac.at/hostings/cescg/CESCG-2002/DSykoraJJelinek/index.html
Lighthouse3d.com http://www.lighthouse3d.com/tutorials/view-frustum-culling/Fundamentals about Planes, Half-Spaces and Frustum-Culling:
Planes and Half-Spaces, Max Wagner <mwagner@digipen.edu> http://www.emeyex.com/site/tuts/PlanesHalfSpaces.pdf
Frustum Culling, Max Wagner <mwagner@digipen.edu> http://www.emeyex.com/site/tuts/FrustumCulling.pdf
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
static class
Plane equation := dot(n, x - p) = 0 -> ax + bc + cx + d == 0 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Index for bottom plane: 2static final int
Index for far plane: 5static final int
Index for left plane: 0static final int
Index for near plane: 4static final int
Index for right plane: 1static final int
Index for top plane: 3 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Frustum.Location
classifyPoint
(float[] p) Check to see if a point is outside, inside or on a plane of the frustum.final Frustum.Location
classifySphere
(float[] p, float radius) Check to see if a sphere is outside, intersecting or inside of the frustum.final Frustum.Plane[]
final boolean
isAABBoxOutside
(AABBox box) Check to see if an axis aligned bounding box is completely outside of the frustum.final boolean
isPointOutside
(float[] p) Check to see if a point is outside of the frustum.final boolean
isSphereOutside
(float[] p, float radius) Check to see if a sphere is outside of the frustum.toString()
float[]
updateByFovDesc
(float[] m, int m_offset, boolean initM, Frustum.FovDesc fovDesc) Calculate the frustum planes in world coordinates using the passedFrustum.FovDesc
.final void
updateByPlanes
(Frustum.Plane[] src) Copy the givensrc
planes into this this instance's planes.void
updateByPMV
(float[] pmv, int pmv_off) Calculate the frustum planes in world coordinates using the passed float[16] as premultiplied P*MV (column major order).
-
Field Details
-
LEFT
public static final int LEFTIndex for left plane: 0- See Also:
-
RIGHT
public static final int RIGHTIndex for right plane: 1- See Also:
-
BOTTOM
public static final int BOTTOMIndex for bottom plane: 2- See Also:
-
TOP
public static final int TOPIndex for top plane: 3- See Also:
-
NEAR
public static final int NEARIndex for near plane: 4- See Also:
-
FAR
public static final int FARIndex for far plane: 5- See Also:
-
-
Constructor Details
-
Frustum
public Frustum()Creates an undefined instance w/o calculating the frustum.Use one of the
update(..)
methods to set theplanes
.
-
-
Method Details
-
getPlanes
Frustum.Plane
s are ordered in the returned array as follows:Frustum.Plane
's normals are pointing to the inside of the frustum in order to work w/isOutside(..)
methods.- Returns:
- array of normalized
Frustum.Plane
s, order see above.
-
updateByPlanes
Copy the givensrc
planes into this this instance's planes.- Parameters:
src
- the 6 source planes
-
updateByFovDesc
Calculate the frustum planes in world coordinates using the passedFrustum.FovDesc
.Operation Details:
- The given
Frustum.FovDesc
will be transformed into the given float[16] as a perspective matrix (column major order) first, seeFloatUtil.makePerspective(float[], int, boolean, FovHVHalves, float, float)
. - Then the float[16] perspective matrix is used to
updateByPMV(float[], int)
this instance.
Frustum plane's normals will point to the inside of the viewing frustum, as required by this class.
- Parameters:
m
- 4x4 matrix in column-major order (also result)m_offset
- offset in given array m, i.e. start of the 4x4 matrixinitM
- if true, given matrix will be initialized w/ identity matrix, otherwise only the frustum fields are set.fovDesc
-Frustum
Frustum.FovDesc
- Returns:
- given matrix for chaining
- See Also:
- The given
-
updateByPMV
public void updateByPMV(float[] pmv, int pmv_off) Calculate the frustum planes in world coordinates using the passed float[16] as premultiplied P*MV (column major order).Frustum plane's normals will point to the inside of the viewing frustum, as required by this class.
-
isAABBoxOutside
Check to see if an axis aligned bounding box is completely outside of the frustum.Note: If method returns false, the box may only be partially inside.
-
classifyPoint
Check to see if a point is outside, inside or on a plane of the frustum.- Parameters:
p
- the point- Returns:
Frustum.Location
of point related to frustum planes
-
isPointOutside
public final boolean isPointOutside(float[] p) Check to see if a point is outside of the frustum.- Parameters:
p
- the point- Returns:
- true if outside of the frustum, otherwise inside or on a plane
-
classifySphere
Check to see if a sphere is outside, intersecting or inside of the frustum.- Parameters:
p
- center of the sphereradius
- radius of the sphere- Returns:
Frustum.Location
of point related to frustum planes
-
isSphereOutside
public final boolean isSphereOutside(float[] p, float radius) Check to see if a sphere is outside of the frustum.- Parameters:
p
- center of the sphereradius
- radius of the sphere- Returns:
- true if outside of the frustum, otherwise inside or intersecting
-
toString
-
toString
-