Class TexturedTriangle
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon.TexturedTriangle
- Direct Known Subclasses:
TessellatedTexturedTriangle
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 Summary
FieldsFields inherited from class AbstractCoordinateShape
onScreenZ, shapeId, verticesFields inherited from class AbstractShape
cachedBoundingBox, mouseInteractionController -
Constructor Summary
ConstructorsConstructorDescriptionTexturedTriangle(Vertex p1, Vertex p2, Vertex p3, Texture texture) Creates a textured triangle with the specified vertices and texture. -
Method Summary
Modifier and TypeMethodDescriptiondoubleComputes the maximum screen-space edge length from current vertex screen coordinates.doubleReturns the screen-space edge length from the last tessellation decision.booleanChecks if this triangle has valid screen coordinates from a previous frame.booleanChecks if backface culling is enabled for this triangle.booleanneedsRetessellation(double currentScreenSize) Determines if retessellation is needed based on screen-space size change.voidpaint(RenderingContext renderBuffer) Renders this textured triangle to the screen.voidsetBackfaceCulling(boolean backfaceCulling) Enables or disables backface culling for this triangle.voidsetLastScreenSpaceSize(double size) Updates the recorded screen-space size after tessellation.Methods inherited from class AbstractCoordinateShape
getBoundingBox, getZ, transform, translateMethods inherited from class AbstractShape
invalidateBounds, setMouseInteractionController
-
Field Details
-
texture
The texture to apply to this triangle.
-
-
Constructor Details
-
TexturedTriangle
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
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:
paintin classAbstractCoordinateShape- Parameters:
renderBuffer- the rendering context containing the pixel buffer
-
isBackfaceCullingEnabled
public boolean isBackfaceCullingEnabled()Checks if backface culling is enabled for this triangle.- Returns:
trueif backface culling is enabled
-
setBackfaceCulling
public void setBackfaceCulling(boolean backfaceCulling) Enables or disables backface culling for this triangle.- Parameters:
backfaceCulling-trueto enable backface culling
-
getLastScreenSpaceSize
public double getLastScreenSpaceSize()Returns the screen-space edge length from the last tessellation decision. Used by AbstractCompositeShape to determine if retessellation is needed.- Returns:
- the last recorded screen-space size, or 0 if never tessellated
-
setLastScreenSpaceSize
public void setLastScreenSpaceSize(double size) Updates the recorded screen-space size after tessellation.- Parameters:
size- the screen-space edge length that was used for tessellation
-
hasPreviousScreenCoordinates
public boolean hasPreviousScreenCoordinates()Checks if this triangle has valid screen coordinates from a previous frame. Used to determine if screen-space tessellation can be applied.- Returns:
trueif at least one vertex has non-origin screen coordinates
-
computeMaxScreenEdgeLength
public double computeMaxScreenEdgeLength()Computes the maximum screen-space edge length from current vertex screen coordinates. Used to determine tessellation level based on visual size.- Returns:
- the longest edge length in screen pixels
-
needsRetessellation
public boolean needsRetessellation(double currentScreenSize) Determines if retessellation is needed based on screen-space size change. Uses the same 1.5x ratio threshold as AbstractCompositeShape uses for LOD factors.- Parameters:
currentScreenSize- the current screen-space edge length- Returns:
trueif retessellation should be performed
-