Class TexturedPolygonTessellator

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.tessellation.TexturedPolygonTessellator

public class TexturedPolygonTessellator extends Object
Recursively tessellates 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 TexturedPolygonTessellator addresses this by recursively splitting triangles along their longest edge until no edge exceeds maxDistance.

The tessellation 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

    • TexturedPolygonTessellator

      public TexturedPolygonTessellator(double maxDistance)
      Creates a new tessellator 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<TexturedTriangle> getResult()
      Returns the list of tessellated polygons produced by the tessellation process.
      Returns:
      an unmodifiable view of the resulting TexturedTriangle list
    • tessellate

      public void tessellate(TexturedTriangle originalPolygon)
      Tessellates 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 tessellate