Class GeometryUtils
java.lang.Object
org.web3d.vrml.renderer.common.nodes.GeometryUtils
Utilities for handling generic geometry actions.
Make sure all pointer vars that are added get cleared in the reset method. Proposed Optimization: Compact the tesselation arrays when inside a StaticGroup Compact them when max_polygon size > 5 as our estimate might be really off NOTE: It seems even with tris the array sizes are off.
- Version:
- $Revision: 1.21 $
- Author:
- Alan Hudson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyData(GeometryHolder gh, org.j3d.geom.GeometryData gd) Performs a shallow copy of data from a GeometryHolder to a GeometryData structure.booleangenerateTriangleArrays(float[] coord, float[] color, float[] normal, float[] texture, int changeFlags, boolean genTexCoords, boolean genNormals, int[] vfCoordIndex, int numCoordIndex, int[] vfColorIndex, int[] vfNormalIndex, int[] vfTexCoordIndex, boolean ccw, boolean convex, boolean colorPerVertex, boolean normalPerVertex, int numColorComponents, float creaseAngle, boolean initialBuild, GeometryHolder geomData) Take an indexed geometry and flatten to a triangle array.booleangenerateTriangleArrays(int changeFlags, boolean genTexCoords, boolean genNormals, VRMLCoordinateNodeType vfCoord, VRMLColorNodeType vfColor, VRMLNormalNodeType vfNormal, VRMLTextureCoordinateNodeType vfTexCoord, int[] vfCoordIndex, int numCoordIndex, int[] vfColorIndex, int[] vfNormalIndex, int[] vfTexCoordIndex, boolean ccw, boolean convex, boolean colorPerVertex, boolean normalPerVertex, float creaseAngle, boolean initialBuild, GeometryHolder geomData) Take an indexed geometry and flatten to a triangle array.voidgetCounts(int[] counts) Get the counts of triangle, quad, ngons and maxIndexCount.voidreset()Reset all local variables to decrease memory usage.
-
Constructor Details
-
GeometryUtils
public GeometryUtils()
-
-
Method Details
-
reset
public void reset()Reset all local variables to decrease memory usage. -
copyData
Performs a shallow copy of data from a GeometryHolder to a GeometryData structure. Any multitexture data will be clipped to the first set.- Parameters:
gh- The GeometryHoldergd- The GeometryData
-
generateTriangleArrays
public boolean generateTriangleArrays(float[] coord, float[] color, float[] normal, float[] texture, int changeFlags, boolean genTexCoords, boolean genNormals, int[] vfCoordIndex, int numCoordIndex, int[] vfColorIndex, int[] vfNormalIndex, int[] vfTexCoordIndex, boolean ccw, boolean convex, boolean colorPerVertex, boolean normalPerVertex, int numColorComponents, float creaseAngle, boolean initialBuild, GeometryHolder geomData) Take an indexed geometry and flatten to a triangle array.- Parameters:
coord- replaces vfCoord.getPointRef();color- replaces vfColor.getColor(color);normal- replaces vfNormal.getVector(normal);texture- in theory, a replacement for a vfTexCoord call - I recommend leaving it as null.changeFlags- What arrays changed, defined in BaseComponentGeometrygenTexCoords- Should texture coordinates be generated if none are providedgenNormals- Should normals be generated if none are providedvfCoordIndex- The coordinate indices seperated by -1numCoordIndex- The number of valid coordinate indicesvfColorIndex- The color indices. NULL means use the coord indicesvfNormalIndex- The normal indices. NULL means use the coord indicesvfTexCoordIndex- The texture indices. NULL means use the coord indicesccw- CounterClockWise, true if we are using the right-hand-ruleconvex- true if the data has a convex hull for all facescolorPerVertex- true if the data has colors per vertex, false for facenormalPerVertex- true if the data has normals per vertex, false for facenumColorComponents-creaseAngle- Angle to smooth normals if generating normalsinitialBuild- Force regeneration regardless of change flagsgeomData- Returns the generated geometry here- Returns:
- Did the number of triangles increase. Always true on an initial build
-
generateTriangleArrays
public boolean generateTriangleArrays(int changeFlags, boolean genTexCoords, boolean genNormals, VRMLCoordinateNodeType vfCoord, VRMLColorNodeType vfColor, VRMLNormalNodeType vfNormal, VRMLTextureCoordinateNodeType vfTexCoord, int[] vfCoordIndex, int numCoordIndex, int[] vfColorIndex, int[] vfNormalIndex, int[] vfTexCoordIndex, boolean ccw, boolean convex, boolean colorPerVertex, boolean normalPerVertex, float creaseAngle, boolean initialBuild, GeometryHolder geomData) Take an indexed geometry and flatten to a triangle array.- Parameters:
changeFlags- What arrays changed, defined in BaseComponentGeometrygenTexCoords- Should texture coordinates be generated if none are providedgenNormals- Should normals be generated if none are providedvfCoord- The coordinate datavfColor- The color data, if provided, NULL otherwisevfNormal- The normal data, if provided, NULL otherwisevfTexCoord- The texture data, if provided, NULL otherwisevfCoordIndex- The coordinate indices seperated by -1numCoordIndex- The number of valid coordinate indicesvfColorIndex- The color indices. NULL means use the coord indicesvfNormalIndex- The normal indices. NULL means use the coord indicesvfTexCoordIndex- The texture indices. NULL means use the coord indicesccw- CounterClockWise, true if the data is ccw woundconvex- true if the data has a convex hullcolorPerVertex- true if the data has colors per vertex, false for facenormalPerVertex- true if the data has normals per vertex, false for facecreaseAngle- Angle to smooth normals if generating normalsinitialBuild- Force regeneration regardless of change flagsgeomData- Returns the generated geometry here- Returns:
- Did the number of triangles increase. Always true on an initial build
-
getCounts
public void getCounts(int[] counts) Get the counts of triangle, quad, ngons and maxIndexCount.- Parameters:
counts- An to fill in the counts
-