Class LodGenerator
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
reductionMethod-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumerate criteria for removing triangles. -
Constructor Summary
ConstructorDescriptionLodGenerator
(Geometry geom) Constructs an LodGenerator for the given Geometry.LodGenerator
(Mesh mesh) Constructs an LodGenerator for the given Mesh. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bakeLods
(LodGenerator.TriangleReductionMethod reductionMethod, float... reductionValues) Computes the LODs and bakes them into the mesh.computeLods
(LodGenerator.TriangleReductionMethod reductionMethod, float... reductionValues) Computes the LODs and returns an array of VertexBuffers that can be passed to Mesh.setLodLevels().
-
Constructor Details
-
LodGenerator
Constructs an LodGenerator for the given Mesh.- Parameters:
mesh
- the mesh for which to generate LODs.
-
LodGenerator
Constructs an LodGenerator for the given Geometry.- Parameters:
geom
- the geometry for which to generate LODs.
-
-
Method Details
-
computeLods
public VertexBuffer[] computeLods(LodGenerator.TriangleReductionMethod reductionMethod, float... reductionValues) Computes the LODs and returns an array of VertexBuffers that can be passed to Mesh.setLodLevels().
This method must be fed with the reduction methodLodGenerator.TriangleReductionMethod
and a list of reduction values.
for each value a LOD will be generated.
The resulting array will always contain at index 0 the original index buffer of the mesh.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.
- Parameters:
reductionMethod
- the reduction method to usereductionValues
- the reduction value to use for each LOD level.- Returns:
- an array of VertexBuffers containing the different index buffers representing the LOD levels.
-
bakeLods
public void bakeLods(LodGenerator.TriangleReductionMethod reductionMethod, float... reductionValues) Computes the LODs and bakes them into the mesh.
This method must be fed with the reduction methodLodGenerator.TriangleReductionMethod
and a list of reduction values.
for each value a LOD will be generated.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.
- Parameters:
reductionMethod
- the reduction method to usereductionValues
- the reduction value to use for each LOD level.
-