public class LodGenerator
extends java.lang.Object
This class is the java implementation of the enhanced version of Ogre engine Lod generator, by Péter Szücs, originally based on Stan Melax "easy mesh simplification". The MIT licenced C++ source code can be found here https://github.com/worldforge/ember/tree/master/src/components/ogre/lod more information can be found here http://www.melax.com/polychop http://sajty.elementfx.com/progressivemesh/GSoC2012.pdf
The algorithm sorts vertices according to their collapse cost in
ascending order. It collapses from the "cheapest" vertex to the more expensive.
Usage :
LodGenerator lODGenerator = new LodGenerator(geometry); lODGenerator.bakeLods(reductionMethod,reductionValue);reductionMethod type is VertexReductionMethod described here
LodGenerator.TriangleReductionMethod
reduction value depends on the
reductionMethodModifier and Type | Class and Description |
---|---|
static class |
LodGenerator.TriangleReductionMethod
Describe the way triangles will be removed.
|
Constructor and Description |
---|
LodGenerator(Geometry geom)
Construct a LodGenerator for the given geometry
|
LodGenerator(Mesh mesh)
Construct a LodGenerator for the given mesh
|
Modifier and Type | Method and Description |
---|---|
void |
bakeLods(LodGenerator.TriangleReductionMethod reductionMethod,
float... reductionValues)
Computes the lods and bake them into the mesh
This method must be fed with the reduction method LodGenerator.TriangleReductionMethod and a list of reduction values.for each value a lod will be generated. |
VertexBuffer[] |
computeLods(LodGenerator.TriangleReductionMethod reductionMethod,
float... reductionValues)
Computes the lod and return a list of VertexBuffers that can then be used
for lod (use Mesh.setLodLevels(VertexBuffer[]))
This method must be fed with the reduction method LodGenerator.TriangleReductionMethod and a list of reduction values.for each value a lod will be generated. |
public LodGenerator(Mesh mesh)
mesh
- the mesh to consider to generate de Lods.public LodGenerator(Geometry geom)
geom
- the geometry to consider to generate de Lods.public VertexBuffer[] computeLods(LodGenerator.TriangleReductionMethod reductionMethod, float... reductionValues)
LodGenerator.TriangleReductionMethod
and a list of reduction values.Important note : some meshes cannot be decimated, so the result of this method can vary depending of the given mesh. Also the reduction values are indicative and the produces mesh will not always meet the required reduction.
reductionMethod
- the reduction method to usereductionValues
- the reduction value to use for each lod level.public void bakeLods(LodGenerator.TriangleReductionMethod reductionMethod, float... reductionValues)
LodGenerator.TriangleReductionMethod
and a list of reduction values.Important note : some meshes cannot be decimated, so the result of this method can vary depending of the given mesh. Also the reduction values are indicative and the produces mesh will not always meet the required reduction.
reductionMethod
- the reduction method to usereductionValues
- the reduction value to use for each lod level.