java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.slicer.Slicer

public class Slicer extends Object
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:

  1. For a given triangle, compute the lengths of all three edges.
  2. Sort edges by length and find the longest one.
  3. If the longest edge is shorter than maxDistance, emit the triangle as-is.
  4. 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 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

      public List<TexturedPolygon> getResult()
      Returns the list of subdivided polygons produced by the slicing process.
      Returns:
      an unmodifiable view of the resulting TexturedPolygon list
    • slice

      public void slice(TexturedPolygon originalPolygon)
      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