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
Enumerate criteria for removing triangles.
|
Constructor and Description |
---|
LodGenerator(Geometry geom)
Constructs an LodGenerator for the given Geometry.
|
LodGenerator(Mesh mesh)
Constructs an LodGenerator for the given Mesh.
|
Modifier and Type | Method and Description |
---|---|
void |
bakeLods(LodGenerator.TriangleReductionMethod reductionMethod,
float... reductionValues)
Computes the LODs and bakes them into the mesh.
|
VertexBuffer[] |
computeLods(LodGenerator.TriangleReductionMethod reductionMethod,
float... reductionValues)
Computes the LODs and returns an array of VertexBuffers that can
be passed to Mesh.setLodLevels().
|
public LodGenerator(Mesh mesh)
mesh
- the mesh for which to generate LODs.public LodGenerator(Geometry geom)
geom
- the geometry for which to generate 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 on the given mesh. Also, the reduction values are approximate, and the algorithm won't always achieve the specified reduction.
reductionMethod
- the reduction method to usereductionValues
- the reduction value to use for each LOD level.