Top Description Inners Fields Constructors Methods
com.jogamp.opengl.math.geom

public Class Frustum

extends Object
Class Inheritance
Imports
jogamp.common.os.PlatformPropsImpl, com.jogamp.common.os.Platform, com.jogamp.opengl.math.FloatUtil, .FovHVHalves

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 
  Klaus Hartmann 
  http://graphics.cs.ucf.edu/cap4720/fall2008/plane_extraction.pdf
Classifying Point, Sphere and AABBox:
Efficient View Frustum Culling
  Daniel Sýkora 
  Josef Jelínek 
  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 
http://www.emeyex.com/site/tuts/PlanesHalfSpaces.pdf
Frustum Culling,  Max Wagner 
http://www.emeyex.com/site/tuts/FrustumCulling.pdf

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Frustum.FovDesc

Frustum description by fovhv and zNear, zFar.

public static enum
public static class
Frustum.Plane

Plane equation := dot(n, x - p) = 0 -> ax + bc + cx + d == 0

In order to work w/ isOutside(..) methods, the normals have to point to the inside of the frustum.

Field Summary

Modifier and TypeField and Description
public static final int
BOTTOM

Index for bottom plane:

public static final int
FAR

Index for far plane:

public static final int
LEFT

Index for left plane:

public static final int
NEAR

Index for near plane:

protected final Frustum.Plane[]
planes

Normalized planes[l, r, b, t, n, f]

public static final int
RIGHT

Index for right plane:

public static final int
TOP

Index for top plane:

Constructor Summary

AccessConstructor and Description
public
Frustum()

Creates an undefined instance w/o calculating the frustum.

Method Summary

Modifier and TypeMethod and Description
public final Frustum.Location

Returns:

Location of point related to frustum planes
classifyPoint
(final float[]
the point
p
)

Check to see if a point is outside, inside or on a plane of the frustum.

public final Frustum.Location

Returns:

Location of point related to frustum planes
classifySphere
(final float[]
center of the sphere
p
,
final float
radius of the sphere
radius
)

Check to see if a sphere is outside, intersecting or inside of the frustum.

public final Frustum.Plane[]

Returns:

array of normalized Planes, order see above.
getPlanes
()

Planes are ordered in the returned array as follows:

public final boolean
isAABBoxOutside(final AABBox box)

Check to see if an axis aligned bounding box is completely outside of the frustum.

private static final boolean
isOutsideImpl(final Frustum.Plane p, final AABBox box)

public final boolean

Returns:

true if outside of the frustum, otherwise inside or on a plane
isPointOutside
(final float[]
the point
p
)

Check to see if a point is outside of the frustum.

public final boolean

Returns:

true if outside of the frustum, otherwise inside or intersecting
isSphereOutside
(final float[]
center of the sphere
p
,
final float
radius of the sphere
radius
)

Check to see if a sphere is outside of the frustum.

public StringBuilder
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public float[]

Returns:

given matrix for chaining
updateByFovDesc
(final float[]
4x4 matrix in column-major order (also result)
m
,
final int
offset in given array m, i.e. start of the 4x4 matrix
m_offset
,
final boolean
if true, given matrix will be initialized w/ identity matrix, otherwise only the frustum fields are set.
initM
,
final Frustum.FovDesc fovDesc)

Calculate the frustum planes in world coordinates using the passed FovDesc.

public final void
updateByPlanes(final Frustum.Plane[]
the 6 source planes
src
)

Copy the given src planes into this this instance's planes.

public void
updateByPMV(final float[] pmv, final int pmv_off)

Calculate the frustum planes in world coordinates using the passed float[16] as premultiplied P*MV (column major order).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BOTTOMback to summary
public static final int BOTTOM

Index for bottom plane:

FARback to summary
public static final int FAR

Index for far plane:

LEFTback to summary
public static final int LEFT

Index for left plane:

NEARback to summary
public static final int NEAR

Index for near plane:

planesback to summary
protected final Frustum.Plane[] planes

Normalized planes[l, r, b, t, n, f]

TOPback to summary
public static final int TOP

Index for top plane:

Constructor Detail

Frustumback to summary
public Frustum()

Creates an undefined instance w/o calculating the frustum.

Use one of the update(..) methods to set the planes.

See Also
updateByPlanes(Plane[]), updateByPMV(float[], int)

Method Detail

classifyPointback to summary
public final Frustum.Location classifyPoint(final float[] p)

Check to see if a point is outside, inside or on a plane of the frustum.

Parameters
p:float[]

the point

Returns:Frustum.Location

Location of point related to frustum planes

classifySphereback to summary
public final Frustum.Location classifySphere(final float[] p, final float radius)

Check to see if a sphere is outside, intersecting or inside of the frustum.

Parameters
p:float[]

center of the sphere

radius:float

radius of the sphere

Returns:Frustum.Location

Location of point related to frustum planes

getPlanesback to summary
public final Frustum.Plane[] getPlanes()

Planes are ordered in the returned array as follows:

Plane's normals are pointing to the inside of the frustum in order to work w/ isOutside(..) methods.

Returns:Frustum.Plane[]

array of normalized Planes, order see above.

isAABBoxOutsideback to summary
public final boolean isAABBoxOutside(final AABBox box)

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.

isOutsideImplback to summary
private static final boolean isOutsideImpl(final Frustum.Plane p, final AABBox box)
isPointOutsideback to summary
public final boolean isPointOutside(final float[] p)

Check to see if a point is outside of the frustum.

Parameters
p:float[]

the point

Returns:boolean

true if outside of the frustum, otherwise inside or on a plane

isSphereOutsideback to summary
public final boolean isSphereOutside(final float[] p, final float radius)

Check to see if a sphere is outside of the frustum.

Parameters
p:float[]

center of the sphere

radius:float

radius of the sphere

Returns:boolean

true if outside of the frustum, otherwise inside or intersecting

toStringback to summary
public StringBuilder toString(StringBuilder sb)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
updateByFovDescback to summary
public float[] updateByFovDesc(final float[] m, final int m_offset, final boolean initM, final Frustum.FovDesc fovDesc)

Calculate the frustum planes in world coordinates using the passed FovDesc.

Operation Details:

Frustum plane's normals will point to the inside of the viewing frustum, as required by this class.

Parameters
m:float[]

4x4 matrix in column-major order (also result)

m_offset:int

offset in given array m, i.e. start of the 4x4 matrix

initM:boolean

if true, given matrix will be initialized w/ identity matrix, otherwise only the frustum fields are set.

fovDesc:Frustum.FovDesc

Frustum FovDesc

Returns:float[]

given matrix for chaining

See Also
FloatUtil#makePerspective(float[], int, boolean, FovHVHalves, float, float)
updateByPlanesback to summary
public final void updateByPlanes(final Frustum.Plane[] src)

Copy the given src planes into this this instance's planes.

Parameters
src:Frustum.Plane[]

the 6 source planes

updateByPMVback to summary
public void updateByPMV(final float[] pmv, final 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.

com.jogamp.opengl.math.geom back to summary

public Class Frustum.FovDesc

extends Object
Class Inheritance

Frustum description by fovhv and zNear, zFar.

Field Summary

Modifier and TypeField and Description
public final FovHVHalves
fovhv

Field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians.

public final float
zFar

Far Z

public final float
zNear

Near Z

Constructor Summary

AccessConstructor and Description
public
FovDesc(final FovHVHalves
field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians
fovhv
,
final float zNear, final float zFar)

Method Summary

Modifier and TypeMethod and Description
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

fovhvback to summary
public final FovHVHalves fovhv

Field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians.

zFarback to summary
public final float zFar

Far Z

zNearback to summary
public final float zNear

Near Z

Constructor Detail

FovDescback to summary
public FovDesc(final FovHVHalves fovhv, final float zNear, final float zFar) throws IllegalArgumentException
Parameters
fovhv:FovHVHalves

field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians

Exceptions
IllegalArgumentException:
if zNear <= 0 or zFar <= zNear.

Method Detail

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

com.jogamp.opengl.math.geom back to summary

public final Enum Frustum.Location

extends Enum<Frustum.Location>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Frustum.Location
public static final Frustum.Location
public static final Frustum.Location

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Frustum.Location
public static Frustum.Location[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSIDEback to summary
public static final Frustum.Location INSIDE
INTERSECTback to summary
public static final Frustum.Location INTERSECT
OUTSIDEback to summary
public static final Frustum.Location OUTSIDE

Constructor Detail

Locationback to summary
private Location()

Method Detail

valueOfback to summary
public static Frustum.Location valueOf(String name)
valuesback to summary
public static Frustum.Location[] values()
com.jogamp.opengl.math.geom back to summary

public Class Frustum.Plane

extends Object
Class Inheritance

Plane equation := dot(n, x - p) = 0 -> ax + bc + cx + d == 0

In order to work w/ isOutside(..) methods, the normals have to point to the inside of the frustum.

Field Summary

Modifier and TypeField and Description
public float
d

Distance to origin

public final float[]
n

Normal of the plane

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final float
distanceTo(final float x, final float y, final float z)

Return signed distance of plane to given point.

public final float
distanceTo(final float[] p)

Return distance of plane to given point, see distanceTo(float, float, float).

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

dback to summary
public float d

Distance to origin

nback to summary
public final float[] n

Normal of the plane

Constructor Detail

Planeback to summary
public Plane()

Method Detail

distanceToback to summary
public final float distanceTo(final float x, final float y, final float z)

Return signed distance of plane to given point.

  • If dist < 0 , then the point p lies in the negative halfspace.
  • If dist = 0 , then the point p lies in the plane.
  • If dist > 0 , then the point p lies in the positive halfspace.
A plane cuts 3D space into 2 half spaces.

Positive halfspace is where the plane’s normals vector points into.

Negative halfspace is the other side of the plane, i.e. *-1

distanceToback to summary
public final float distanceTo(final float[] p)

Return distance of plane to given point, see distanceTo(float, float, float).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override