Class Slicer
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.slicer.Slicer
Recursively subdivides textured polygons into smaller triangles for
perspective-correct rendering and level-of-detail management.
When a textured polygon covers a large area of the screen, rendering it as
a single triangle can produce visible texture distortion due to affine (non-perspective)
texture interpolation. The Slicer addresses this by recursively splitting
triangles along their longest edge until no edge exceeds maxDistance.
The subdivision algorithm works as follows:
- For a given triangle, compute the lengths of all three edges.
- Sort edges by length and find the longest one.
- If the longest edge is shorter than
maxDistance, emit the triangle as-is. - Otherwise, split the longest edge at its midpoint (interpolating both 3D and texture coordinates) and recurse on the two resulting sub-triangles.
This class is used by
AbstractCompositeShape
to break large composite shapes into appropriately-sized sub-polygons.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSlicer(double maxDistance) Creates a new slicer with the specified maximum edge length. -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of subdivided polygons produced by the slicing process.voidslice(TexturedPolygon originalPolygon) Slices the given textured polygon into smaller triangles.
-
Constructor Details
-
Slicer
public Slicer(double maxDistance) Creates a new slicer with the specified maximum edge length.- Parameters:
maxDistance- the maximum allowed edge length in world-space units; edges longer than this will be subdivided
-
-
Method Details
-
getResult
Returns the list of subdivided polygons produced by the slicing process.- Returns:
- an unmodifiable view of the resulting
TexturedPolygonlist
-
slice
Slices the given textured polygon into smaller triangles.After calling this method, retrieve the resulting sub-polygons via
getResult(). The original polygon's texture reference and mouse interaction controller are preserved on all sub-polygons.- Parameters:
originalPolygon- the polygon to subdivide
-