Direct Known Subclasses:
LightmappedTriangle

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

Quake-style subdivided perspective correction: (u/z, v/z, 1/z) are interpolated linearly in screen space and the exact texture coordinate is recovered with one reciprocal per subdivision interval, with affine stepping in between. This makes screen-size tessellation unnecessary — triangles of any size render with correct perspective.

See Also:
  • 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

    • setPerspectiveCorrectionEnabled

      public static void setPerspectiveCorrectionEnabled(boolean enabled)
      Enables or disables perspective-correct texture mapping. When disabled, rendering falls back to plain affine mapping, which visibly warps textures on large on-screen triangles at steep angles.
      Parameters:
      enabled - true for perspective-correct mapping
    • isPerspectiveCorrectionEnabled

      public static boolean isPerspectiveCorrectionEnabled()
      Returns whether perspective-correct texture mapping is enabled.
      Returns:
      true when perspective correction is active
    • getTexture

      public Texture getTexture()
      Returns the current texture.
      Returns:
      the texture
    • setTexture

      public void setTexture(Texture texture)
      Atomically swaps the texture. Painters pick up the new texture at the next paint call; a triangle in flight finishes with the old one.
      Parameters:
      texture - the new texture
    • refreshTextureDistance

      protected final void refreshTextureDistance()
      Recomputes the mipmap-selection metric after texture coordinates are replaced post-construction (used by generated-UV subclasses like lightmapped triangles).
    • paint

      public void paint(RenderingContext renderBuffer)
      Description copied from class: AbstractCoordinateShape
      Paints this shape onto the rendering context's pixel buffer.

      This method is called after all shapes have been transformed and sorted by depth. Implementations should use the transformed screen-space coordinates from Vertex.transformedCoordinate(eu.svjatoslav.sixth.e3d.gui.RenderingContext) to draw pixels.

      Specified by:
      paint in class AbstractCoordinateShape
      Parameters:
      renderBuffer - the rendering context containing the pixel buffer and graphics context
    • 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