|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.video.model.VertexUtil
public class VertexUtil
Provides methods for manipulating raw vertex data as two dimensional float
arrays. The first index for the array is the index of a particular vertex.
The second index is the index of a coordinate in a vertex. Basically, it all
boils down to vertex arrays being arrays of length three float arrays.
API Stability: Stable.
Field Summary | |
---|---|
static int |
PORTION_ALPHA
Indicates that the alpha portion of an image should be used. |
static int |
PORTION_BLUE
Indicates that the blue portion of an image should be used. |
static int |
PORTION_GREEN
Indicates that the green portion of an image should be used. |
static int |
PORTION_LUMINANCE
Indicates that the red, green and blue portions of an image should be used to produce luminance values based on the standard NTSC luminance conversion. |
static int |
PORTION_RED
Indicates that the red portion of an image should be used. |
Method Summary | |
---|---|
static float[][] |
buildCylinder(int slices,
int stacks)
Constructs a cylinder approximation mesh with a radius of one. |
static float[][] |
buildHeightMapMesh(java.awt.image.BufferedImage map,
int portion,
float xDist,
float yDist,
float hFactor)
Produces a Quads vertex array from a BufferedImage used as a height map. |
static float[][] |
buildHeightMapTexCoord(java.awt.image.BufferedImage map)
|
static float[][] |
buildIcosahedron()
Constructs an icosahedron mesh for a Triangles object. |
static float[][] |
buildOctahedron()
Constructs an octahedron mesh for a Triangles object. |
static float[][] |
buildPlane(int slices,
int stacks)
Constructs an XZ planar mesh with unit width. |
static float[][] |
buildPlaneTexCoord(int slices,
int stacks)
Constructs a planar texture coordinate array cooresponding to any of the vertex arrays produced by the build* methods. |
static float[][] |
buildSphere(int slices,
int stacks)
Constructs a sphere approximation mesh with a radius of one. |
static float[][] |
buildSphereMapMesh(java.awt.image.BufferedImage map,
int portion)
Builds a mesh for a height-mapped sphere. |
static float[][] |
buildSphereMapMesh(java.awt.image.BufferedImage map,
int portion,
float hr)
Builds a mesh for a height-mapped sphere. |
static float[][] |
buildSphereMapMesh(java.awt.image.BufferedImage map,
int portion,
float hr,
float pr)
Builds a mesh for a height-mapped sphere. |
static float[][] |
buildSphereMapTexCoord(java.awt.image.BufferedImage map)
|
static float[][] |
buildSphereTexCoord(int slices,
int stacks)
Constructs a texture coordinate array for the result of a call to buildSphere(int,int). |
static float[][] |
buildTetrahedron()
Constructs a tetrahedron mesh for a Triangles object. |
static float[][] |
center(float[][] va)
Calculates the center of va and adjusts it (by creating a new vertex array) so it is centered on the origin. |
static float[][] |
copy(float[][] va)
|
static void |
copy(float[][] src,
int srcPos,
float[][] dst,
int dstPos,
int len)
Makes a deep copy of a portion of a vertex array. |
static float[] |
getCenter(float[][] va)
Calculates and returns the center point of a vertex array. |
static float |
getRadius(float[][] va,
float[] center)
Gets the minimum radius of sphere that will enclose the object described by the vertex array va. |
static float[][] |
join(float[][] va1,
float[][] va2)
Constructs a new vertex array from all the vertices in both va1 and va2. |
static float[][] |
join(float[][] va1,
float[][] va2,
float[][] va3)
Constructs a new vertex array from all the vertices in both va1, va2 and va3. |
static void |
normalize(float[][] va)
Normalizes all the vertices in va. |
static float[][] |
quadsToTriangles(float[][] quads)
Converts a vertex array intended for use with a Quads object into one for use with a Triangles object. |
static float[][] |
quadsToTrianglesTexCoord(float[][] tc,
float[][] quads)
Converts a texture coordinate array intended for use with a Quads object for use with a Triangles object. |
static int |
reduce(float[][] va)
Deprecated. This is unneeded, unless you really want to reduce memory usage as much as possible. This method simply takes too long to be worth it except on the most memory constrained hardware. |
static float[][] |
reverseTriangles(float[][] va)
Switches a vertex array containing data for a Triangles MeshElement from counter-clockwise to clockwise or vice-versa. |
static float[][] |
rotate(float x,
float y,
float z,
float[][] va)
Rotates the given vertex array by the given values and returns the result. |
static float[][] |
scale(float[] scale,
float[][] va)
Scales the given vertex array by the given values. |
static float[][] |
scale(float r,
float[][] va)
Scales the given vertex array by the same value in all directions. |
static float[][] |
scale(float xs,
float ys,
float zs,
float[][] va)
Scales the given vertex array by the given values. |
static float[][] |
subdivideTriangles(float[][] va)
Divides each of the triangles in va into 4 smaller triangles and returns the result. |
static float[][] |
swapXY(float[][] va)
Constructs a new vertex array from va with the X and Y axes swapped. |
static float[][] |
swapXZ(float[][] va)
Constructs a new vertex array from va with the X and Z axes swapped. |
static float[][] |
swapYZ(float[][] va)
Constructs a new vertex array from va with the Y and Z axes swapped. |
static float[][] |
translate(float[] trans,
float[][] va)
Translates (shifts) the given vertex array by the given values. |
static float[][] |
translate(float xt,
float yt,
float zt,
float[][] va)
Translates (shifts) the given vertex array by the given values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PORTION_RED
public static final int PORTION_GREEN
public static final int PORTION_BLUE
public static final int PORTION_ALPHA
public static final int PORTION_LUMINANCE
Method Detail |
---|
public static float[][] quadsToTrianglesTexCoord(float[][] tc, float[][] quads)
tc
- the Quads-based texture coordinate array.quads
- the Quads-based vertex array.public static float[][] quadsToTriangles(float[][] quads)
quads
- the Quads-based vertex array.public static float[][] copy(float[][] va)
public static void copy(float[][] src, int srcPos, float[][] dst, int dstPos, int len)
public static float[][] buildSphereTexCoord(int slices, int stacks)
slices
- the number of slices the sphere should have.stacks
- the number of stacks the sphere should have.public static void normalize(float[][] va)
va
- the vertex array. NOTE: va is modified directly by this
method.public static float[][] subdivideTriangles(float[][] va)
va
- a vertex array intended for a Triangles object.
java.lang.IllegalArgumentException
- if you pass in a vertex array whose
length is not a multiple of 3.public static float[][] buildTetrahedron()
public static float[][] buildOctahedron()
public static float[][] buildIcosahedron()
public static float[][] buildSphere(int slices, int stacks)
slices
- the number of slices the sphere should have.stacks
- the number of stacks the sphere should have.public static float[][] buildCylinder(int slices, int stacks)
slices
- the number of slices the cylinder should have.stacks
- the number of stacks the cylinder should have.public static float[][] buildPlaneTexCoord(int slices, int stacks)
slices
- the number of slices the plane should have.stacks
- the number of stacks the plane should have.public static float[][] buildPlane(int slices, int stacks)
slices
- the number of slices the plane should have.stacks
- the number of stacks the plane should have.public static float[][] buildSphereMapTexCoord(java.awt.image.BufferedImage map)
public static float[][] buildSphereMapMesh(java.awt.image.BufferedImage map, int portion)
portion
- the PORTION_* constant denoting which portion of the image
to use for the height values.map
- the BufferedImage to use to get height values from.public static float[][] buildSphereMapMesh(java.awt.image.BufferedImage map, int portion, float hr)
portion
- the PORTION_* constant denoting which portion of the image
to use for the height values.map
- the BufferedImage to use to get height values from.hr
- the height ratio; this determines the maximum depth for the
darker areas of the map. This should be a value between zero and one.
java.lang.IllegalArgumentException
- if hr is greater than one or less than
zero.public static float[][] buildSphereMapMesh(java.awt.image.BufferedImage map, int portion, float hr, float pr)
portion
- the PORTION_* constant denoting which portion of the image
to use for the height values.map
- the BufferedImage to use to get height values from.hr
- the height ratio; this determines the maximum depth for the
darker areas of the map. This should be a value between zero and one.pr
- the polar rolloff factor; anything this distance away from the
equator along the z axis on the unit sphere will begin to use a weighted
average of the average of the pixels in the map on that row and the
particular pixel that's been mapped (for height). The weighting of the
two is based on distance between the rolloff point and the pole, with the
rolloff point being 100% the pixel and the pole being 100% the average of
the row. The top and bottom points on the mapped sphere will always use
the average of the points on the row.
java.lang.IllegalArgumentException
- if hr is greater than one or less than
zero.public static float[][] buildHeightMapTexCoord(java.awt.image.BufferedImage map)
public static float[][] buildHeightMapMesh(java.awt.image.BufferedImage map, int portion, float xDist, float yDist, float hFactor)
map
- a BufferedImage that is to be used as a height map.portion
- indicates which portion of the image to use for height
data. This can be any one of the PORTION_* constants.xDist
- the distance in the X direction between each vertex.yDist
- the distance in the Y direction between each vertex.hFactor
- the height multiplier.
public static float[][] reverseTriangles(float[][] va)
va
- the vertex array to use for source data.
public static float[][] scale(float r, float[][] va)
r
- the value to resize by.va
- the vertex array.
public static float[][] scale(float[] scale, float[][] va)
scale
- a length three float array to use for scaling values.va
- the vertex array.
public static float[][] scale(float xs, float ys, float zs, float[][] va)
xs
- the value to scale the vertices by along the x axis.ys
- the value to scale the vertices by along the y axis.zs
- the value to scale the vertices by along the z axis.va
- the vertex array.
public static float[][] translate(float[] trans, float[][] va)
trans
- the vector to add to each vertex.va
- the vertex array.
public static float[][] center(float[][] va)
va
- the vertex array.public static float[][] translate(float xt, float yt, float zt, float[][] va)
xt
- the value to add to all x values in the vertex array.yt
- the value to add to all y values in the vertex array.zt
- the value to add to all z values in the vertex array.va
- the vertex array.
public static float[][] rotate(float x, float y, float z, float[][] va)
x
- the angle around the x axis by which to rotate.y
- the angle around the y axis by which to rotate.z
- the angle around the z axis by which to rotate.va
- the vertex array.
public static float[][] join(float[][] va1, float[][] va2)
va1
- the first vertex array.va2
- the second vertex array.
public static float[][] join(float[][] va1, float[][] va2, float[][] va3)
va1
- the first vertex array.va2
- the second vertex array.va3
- the second vertex array
public static int reduce(float[][] va)
va
- the vertex array to reduce.
public static float[][] swapXY(float[][] va)
va
- the vertex array.
public static float[][] swapXZ(float[][] va)
va
- the vertex array.
public static float[][] swapYZ(float[][] va)
va
- the vertex array.
public static float getRadius(float[][] va, float[] center)
va
- the vertex array.
public static float[] getCenter(float[][] va)
va
- the vertex array.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |