Class SolidPolygon
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.solidpolygon.SolidPolygon
A solid-color triangle renderer with mouse interaction support.
This class implements a high-performance triangle rasterizer using scanline algorithms. It handles: - Perspective-correct edge interpolation - Alpha blending with background pixels - Viewport clipping - Mouse hover detection via point-in-polygon tests - Optional flat shading based on light sources
The static drawPolygon method is designed for reuse by other polygon types.
-
Field Summary
Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
coordinates, onScreenZ, shapeIdFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
mouseInteractionController -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddrawHorizontalLine(LineInterpolator line1, LineInterpolator line2, int y, RenderingContext renderBuffer, Color color) static voiddrawPolygon(RenderingContext context, Point2D onScreenPoint1, Point2D onScreenPoint2, Point2D onScreenPoint3, MouseInteractionController mouseInteractionController, Color color) getColor()Returns the lighting manager used for shading calculations.booleanbooleanChecks if shading is enabled for this polygon.voidpaint(RenderingContext renderBuffer) Paints this shape onto the rendering context's pixel buffer.voidsetBackfaceCulling(boolean backfaceCulling) voidvoidsetShadingEnabled(boolean shadingEnabled, LightingManager lightingManager) Enables or disables shading for this polygon.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
getZ, transformMethods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
setMouseInteractionController
-
Constructor Details
-
SolidPolygon
-
-
Method Details
-
drawHorizontalLine
public static void drawHorizontalLine(LineInterpolator line1, LineInterpolator line2, int y, RenderingContext renderBuffer, Color color) -
drawPolygon
public static void drawPolygon(RenderingContext context, Point2D onScreenPoint1, Point2D onScreenPoint2, Point2D onScreenPoint3, MouseInteractionController mouseInteractionController, Color color) -
getColor
-
setColor
-
getLightingManager
Returns the lighting manager used for shading calculations.- Returns:
- the lighting manager, or null if shading is not enabled
-
isShadingEnabled
public boolean isShadingEnabled()Checks if shading is enabled for this polygon.- Returns:
- true if shading is enabled, false otherwise
-
setShadingEnabled
Enables or disables shading for this polygon.- Parameters:
shadingEnabled- true to enable shading, false to disablelightingManager- the lighting manager to use for shading calculations
-
isBackfaceCullingEnabled
public boolean isBackfaceCullingEnabled() -
setBackfaceCulling
public void setBackfaceCulling(boolean backfaceCulling) -
paint
Description copied from class:AbstractCoordinateShapePaints 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.transformedCoordinateto draw pixels.- Specified by:
paintin classAbstractCoordinateShape- Parameters:
renderBuffer- the rendering context containing the pixel buffer and graphics context
-