public class TexturedTriangle extends AbstractCoordinateShape
A textured triangle renderer with perspective-correct texture mapping.

This class renders triangles with UV-mapped textures. For large triangles, the rendering may be tessellated into smaller pieces for better perspective correction.

Perspective-correct texture rendering:

  • Small triangles are rendered without perspective correction
  • Larger triangles are tessellated into smaller pieces for accurate perspective
See Also:
  • Field Details

    • texture

      public final Texture texture
      The texture to apply to this triangle.
  • Constructor Details

    • TexturedTriangle

      public TexturedTriangle(Vertex p1, Vertex p2, Vertex p3, Texture texture)
      Creates a textured triangle with the specified vertices and texture.
      Parameters:
      p1 - the first vertex (must have textureCoordinate set)
      p2 - the second vertex (must have textureCoordinate set)
      p3 - the third vertex (must have textureCoordinate set)
      texture - the texture to apply
  • Method Details

    • paint

      public void paint(RenderingContext renderBuffer)
      Renders this textured triangle to the screen.

      This method performs:

      • Backface culling check (if enabled)
      • Mouse interaction detection
      • Mipmap level selection based on screen coverage
      • Scanline rasterization with texture sampling
      Specified by:
      paint in class AbstractCoordinateShape
      Parameters:
      renderBuffer - the rendering context containing the pixel buffer
    • isBackfaceCullingEnabled

      public boolean isBackfaceCullingEnabled()
      Checks if backface culling is enabled for this triangle.
      Returns:
      true if backface culling is enabled
    • setBackfaceCulling

      public void setBackfaceCulling(boolean backfaceCulling)
      Enables or disables backface culling for this triangle.
      Parameters:
      backfaceCulling - true to enable backface culling