public class Visibility extends Object
|Constructor and Description|
|Modifier and Type||Method and Description|
Compute a bounding sphere for a set of points.
Given an OpenGL ES ModelView-Projection matrix (which implicitly describes a frustum) and a list of spheres, determine which spheres intersect the frustum.
Test whether a given triangle mesh is visible on the screen.
public static int visibilityTest(float ws, int wsOffset, float positions, int positionsOffset, char indices, int indicesOffset, int indexCount)
ws- the world space to screen space transform matrix, as an OpenGL column matrix.
wsOffset- an index into the ws array where the data starts.
positions- the vertex positions (x, y, z).
positionsOffset- the index in the positions array where the data starts.
indices- the indices of the triangle list. The indices are expressed as chars because they are unsigned 16-bit values.
indicesOffset- the index in the indices array where the index data starts.
indexCount- 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.
IllegalArgumentException- if ws is null, wsOffset < 0, positions is null, positionsoffset < 0, indices is null, indicesoffset < 0, indicesoffset > indices.length - indexCount
public static int frustumCullSpheres(float mvp, int mvpOffset, float spheres, int spheresOffset, int spheresCount, int results, int resultsOffset, int resultsCapacity)
A ModelView-Projection 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:
A frustum is a six-sided 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 world-space coordinates. R is the radius of the sphere.
mvp- a float array containing the mode-view-projection matrix
mvpOffset- The offset of the mvp data within the mvp array.
spheres- a float array containing the sphere data.
spheresOffset- an offset into the sphere array where the sphere data starts
spheresCount- the number of spheres to cull.
results- an integer array containing the indices of the spheres that are either contained entirely within or intersect the frustum.
resultsOffset- an offset into the results array where the results start.
resultsCapacity- the number of array elements available for storing results.
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.
public static void computeBoundingSphere(float positions, int positionsOffset, int positionsCount, float sphere, int sphereOffset)
positions- positions in x, y, z triples
positionsOffset- offset into positions array
positionsCount- number of position triples to process
sphere- array containing the output as (x, y, z, r)
sphereOffset- offset where the sphere data will be written
IllegalArgumentException- if positions is null, positionsOffset < 0, positionsoffset > positions.length - positionsCount, sphere is null, sphereOffset < 0, sphereoffset > sphere.length - 4.