Visibility
public
class
Visibility
extends Object
A collection of utility methods for computing the visibility of triangle
meshes.
Summary
Public methods 
static
void

computeBoundingSphere(float[] positions, int positionsOffset, int positionsCount, float[] sphere, int sphereOffset)
Compute a bounding sphere for a set of points.

static
int

frustumCullSpheres(float[] mvp, int mvpOffset, float[] spheres, int spheresOffset, int spheresCount, int[] results, int resultsOffset, int resultsCapacity)
Given an OpenGL ES ModelViewProjection matrix (which implicitly
describes a frustum) and a list of spheres, determine which spheres
intersect the frustum.

static
int

visibilityTest(float[] ws, int wsOffset, float[] positions, int positionsOffset, char[] indices, int indicesOffset, int indexCount)
Test whether a given triangle mesh is visible on the screen.

Inherited methods 
From class
java.lang.Object
Object

clone()
Creates and returns a copy of this object.

boolean

equals(Object obj)
Indicates whether some other object is "equal to" this one.

void

finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.

final
Class<?>

getClass()
Returns the runtime class of this Object .

int

hashCode()
Returns a hash code value for the object.

final
void

notify()
Wakes up a single thread that is waiting on this object's
monitor.

final
void

notifyAll()
Wakes up all threads that are waiting on this object's monitor.

String

toString()
Returns a string representation of the object.

final
void

wait(long millis, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

final
void

wait(long millis)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.

final
void

wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.


Public constructors
Public methods
computeBoundingSphere
void computeBoundingSphere (float[] positions,
int positionsOffset,
int positionsCount,
float[] sphere,
int sphereOffset)
Compute a bounding sphere for a set of points. It is approximately the
minimal bounding sphere of an axisaligned box that bounds the points.
Parameters 
positions 
float : positions in x, y, z triples 
positionsOffset 
int : offset into positions array 
positionsCount 
int : number of position triples to process 
sphere 
float : array containing the output as (x, y, z, r) 
sphereOffset 
int : offset where the sphere data will be written 
Throws 
IllegalArgumentException 
if positions is null,
positionsOffset < 0, positionsOffset > positions.length  positionsCount,
sphere is null, sphereOffset < 0, sphereOffset > sphere.length  4.

frustumCullSpheres
int frustumCullSpheres (float[] mvp,
int mvpOffset,
float[] spheres,
int spheresOffset,
int spheresCount,
int[] results,
int resultsOffset,
int resultsCapacity)
Given an OpenGL ES ModelViewProjection matrix (which implicitly
describes a frustum) and a list of spheres, determine which spheres
intersect the frustum.
A ModelViewProjection matrix can be computed by multiplying the
a Projection matrix by the a ModelView matrix (in that order.). There
are several possible ways to obtain the current ModelView and
Projection matrices. The most generally applicable way is to keep
track of the current matrices in application code. If that is not
convenient, there are two optional OpenGL ES extensions which may
be used to read the current matrices from OpenGL ES:
 GL10Ext.glQueryMatrixxOES
 GL11.GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES and
GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES
The problem with reading back the matrices is that your application
will only work with devices that support the extension(s) that
it uses.
A frustum is a sixsided truncated pyramid that defines the portion of
world space that is visible in the view.
Spheres are described as four floating point values: x, y, z, and r, in
worldspace coordinates. R is the radius of the sphere.
Parameters 
mvp 
float : a float array containing the modeviewprojection matrix 
mvpOffset 
int : The offset of the mvp data within the mvp array. 
spheres 
float : a float array containing the sphere data. 
spheresOffset 
int : an offset into the sphere array where the sphere
data starts 
spheresCount 
int : the number of spheres to cull. 
results 
int : an integer array containing the indices of the spheres
that are either contained entirely within or intersect the frustum. 
resultsOffset 
int : an offset into the results array where the results
start. 
resultsCapacity 
int : the number of array elements available for storing
results. 
Returns 
int 
the number of spheres that intersected the frustum. Can be
larger than resultsCapacity, in which case only the first resultsCapacity
results are written into the results array. 
Throws 
IllegalArgumentException 
if mvp is null, mvpOffset < 0,
mvpOffset > mvp.length  16, spheres is null, spheresOffset < 0,
spheresOffset > spheres.length  sphereCount,
results is null, resultsOffset < 0, resultsOffset > results.length 
resultsCapacity.

visibilityTest
int visibilityTest (float[] ws,
int wsOffset,
float[] positions,
int positionsOffset,
char[] indices,
int indicesOffset,
int indexCount)
Test whether a given triangle mesh is visible on the screen. The mesh
is specified as an indexed triangle list.
Parameters 
ws 
float : the world space to screen space transform matrix, as an OpenGL
column matrix. 
wsOffset 
int : an index into the ws array where the data starts. 
positions 
float : the vertex positions (x, y, z). 
positionsOffset 
int : the index in the positions array where the data
starts. 
indices 
char : the indices of the triangle list. The indices are
expressed as chars because they are unsigned 16bit values. 
indicesOffset 
int : the index in the indices array where the index data
starts. 
indexCount 
int : the number of indices in use. Typically a multiple of
three. If not a multiple of three, the remaining one or two indices will
be ignored. 
Returns 
int 
2 if all of the mesh is visible, 1 if some part of the mesh is
visible, 0 if no part is visible. 
Throws 
IllegalArgumentException 
if ws is null, wsOffset < 0,
positions is null, positionsOffset < 0, indices is null,
indicesOffset < 0, indicesOffset > indices.length  indexCount
