com.jme.util.geom
Class GeometryInfo

java.lang.Object
  extended by com.jme.util.geom.GeometryInfo

public class GeometryInfo
extends java.lang.Object

This class allows for optimalization of indexed geometry. In most cases it will be filled with GeometryCreator.fillGeometryInfo, processed and result geometry will be retrieved.


Constructor Summary
GeometryInfo()
          Constructs new GeometryInfo
GeometryInfo(TriMesh mesh)
           
 
Method Summary
 CompositeMesh createChunkedStripArray(java.lang.String name)
          Create indexed triangle strip array with geometry contained in this object.
 int[] createContinousStrip()
          Create continous triangle strip with separate substrips connected by degenerate triangles.
 CompositeMesh createContinousStripMesh(java.lang.String name)
          Create indexed triangle strip array with geometry contained in this object.
 CompositeMesh createMixedArray(java.lang.String name, int minStripLen, boolean stitchStrips)
           
 TriMesh createTrimesh(java.lang.String name)
          Create indexed triangle array with geometry contained in this object.
 int getVertexCacheSize()
           
 GeometryInfo optimizeTrianglesForCache()
          This method reorders face indices to fit well into vertex cache of GPU.
 GeometryInfo recalculateFlatNormals()
          This method computes normal for each face in flat mode - every vertex is duplicated for each face and assigned separate normal belonging to this face.
 GeometryInfo recalculateSmoothGroupNormals()
          This method computes smoothened normals for each vertex.
 void setVertexCacheSize(int vertexCacheSize)
          This method sets size of vertex cache on gpu for which strips/triangle lists should be optimized.
 GeometryInfo unweldVertices()
          Duplicate vertex data for each face, so it is not shared between them.
 GeometryInfo weldVertices()
          Find vertices with same parameters and merge them into one.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryInfo

public GeometryInfo()
Constructs new GeometryInfo


GeometryInfo

public GeometryInfo(TriMesh mesh)
Method Detail

recalculateFlatNormals

public GeometryInfo recalculateFlatNormals()
This method computes normal for each face in flat mode - every vertex is duplicated for each face and assigned separate normal belonging to this face. As side effect of this method, indices are 'split'. Merging them will probably not do much, as vertices with same coords will have different normals because of flat shading.


recalculateSmoothGroupNormals

public GeometryInfo recalculateSmoothGroupNormals()
This method computes smoothened normals for each vertex. Normal of each face from same smoothing group is averaged to compute value of vertex. This means that vertex will be duplicated if it belongs to faces belonging to more than one smooth group. After this operation, vertices will be mostly welded - unless there is a case where two neighbour faces from different smoothing group have same normal.


weldVertices

public GeometryInfo weldVertices()
Find vertices with same parameters and merge them into one. Allows sharing of data between faces, which is a requirement for performance benefit from GPU vertex cache.

See Also:
unweldVertices()

unweldVertices

public GeometryInfo unweldVertices()
Duplicate vertex data for each face, so it is not shared between them. Allows for allocating per-face normal (flat shading).

See Also:
weldVertices()

optimizeTrianglesForCache

public GeometryInfo optimizeTrianglesForCache()
This method reorders face indices to fit well into vertex cache of GPU. This operation is meaningful if you plan to use non-strip triangle array later - in other case, use one of strip generation methods, which are cache-aware by default. Note: this method destroys smoothGroups info and it cannot be recovered, as order of faces is changed. If you want to use smoothing group info for generating normals, you need to do it _before_ you call this method.

See Also:
setVertexCacheSize(int)

createContinousStrip

public int[] createContinousStrip()
Create continous triangle strip with separate substrips connected by degenerate triangles. Please note that unless vertices are welded before (explicitly by weldVertices or implictly by recalculateSmoothGroupNormals) stripification will not help with perfomance, as same vertex will have different index for different face.

Returns:
indices of triangle strip

getVertexCacheSize

public int getVertexCacheSize()
Returns:
Returns the vertexCacheSize.

setVertexCacheSize

public void setVertexCacheSize(int vertexCacheSize)
This method sets size of vertex cache on gpu for which strips/triangle lists should be optimized. This is the "actual" cache size, so 24 for GeForce3 and 16 for GeForce1/2 You may want to play around with this number to tweak performance. Default value: 16 In case of doubt it is better to underestimate size of cache. If you don't care about vertex cache and want strips as long as possible, put very high value here - but be warned, because stripification algorithm is O(n^2*m) [doublecheck - is it true?], where n is number of indices, and m is size of vertexCacheSize. On the other hand, with too small value, you will get too many small strips and cost of degenerate triangles will rise.

Parameters:
vertexCacheSize - The vertexCacheSize to set.

createTrimesh

public TriMesh createTrimesh(java.lang.String name)
Create indexed triangle array with geometry contained in this object. It is best to call weldVertices (if needed) and then optimizeTrianglesForCache before calling this method.

Parameters:
vertexFormat -
Returns:

createContinousStripMesh

public CompositeMesh createContinousStripMesh(java.lang.String name)
Create indexed triangle strip array with geometry contained in this object. It is best to call weldVertices (if needed) before calling this method. Strip array will have one long strip, with substrips connected by degenerate triangles. It uses createContinousStrip method.

Parameters:
vertexFormat -
Returns:
See Also:
createContinousStrip()

createChunkedStripArray

public CompositeMesh createChunkedStripArray(java.lang.String name)
Create indexed triangle strip array with geometry contained in this object. It is best to call weldVertices (if needed) before calling this method. Strip array will have multiple short strips, possibly even single-triangle, so it is not very fast solution. It is better to create continous strip array or mixed array (when it will be implemented).

Parameters:
vertexFormat -
Returns:
See Also:
createContinousStrip()

createMixedArray

public CompositeMesh createMixedArray(java.lang.String name,
                                      int minStripLen,
                                      boolean stitchStrips)