Class Line
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.line.Line
A 3D line segment with perspective-correct width and alpha blending.
This class represents a line between two 3D points, rendered with a specified width that adjusts based on perspective (distance from the viewer). The line is drawn using interpolators to handle edge cases and alpha blending for transparency effects.
The rendering algorithm: 1. For thin lines (below a threshold), draws single-pixel lines with alpha adjustment based on perspective. 2. For thicker lines, creates four interpolators to define the line's rectangular area and fills it scanline by scanline.
Note: The width is scaled by the LINE_WIDTH_MULTIPLIER and adjusted based on the distance from the viewer (z-coordinate) to maintain a consistent visual size.
-
Field Summary
FieldsModifier and TypeFieldDescriptionColor of the line.final doublewidth of the line.Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
shapeId, verticesFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
cachedBoundingBox, mouseInteractionController -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doublegetScreenXMargin(RenderingContext renderingContext) The thick-line widening is perpendicular to the line direction, so it reaches past the vertex range on the X axis exactly as much as on Y.protected doublegetScreenYMargin(RenderingContext renderingContext) The thick-line path widens the line perpendicular to its direction by the projected endpoint radii, reaching beyond the vertex Y range.voidpaint(RenderingContext buffer) Renders this line to the screen using perspective-correct width and alpha blending.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
clippedVertices, getBoundingBox, getBspRank, getZ, getZ, onScreenMaxX, onScreenMaxY, onScreenMinX, onScreenMinY, setBspRank, setZ, transform, translateMethods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
getTransformWeight, invalidateBounds, setMouseInteractionController
-
Field Details
-
width
public final double widthwidth of the line. -
color
Color of the line.
-
-
Constructor Details
-
Line
Creates a copy of an existing line with cloned coordinates and color.- Parameters:
parentLine- the line to copy
-
Line
Creates a line between two points with the specified color and width.- Parameters:
point1- the starting point of the linepoint2- the ending point of the linecolor- the color of the linewidth- the width of the line in world units
-
-
Method Details
-
getScreenYMargin
The thick-line path widens the line perpendicular to its direction by the projected endpoint radii, reaching beyond the vertex Y range. The thin paths stay within the vertex Y range, but there the radius is below 1 pixel anyway.- Overrides:
getScreenYMarginin classAbstractCoordinateShape- Parameters:
renderingContext- the rendering context (provides projection parameters for size computation)- Returns:
- the Y margin in screen pixels (0 = vertex bounds are exact)
-
getScreenXMargin
The thick-line widening is perpendicular to the line direction, so it reaches past the vertex range on the X axis exactly as much as on Y.- Overrides:
getScreenXMarginin classAbstractCoordinateShape- Parameters:
renderingContext- the rendering context (provides projection parameters for size computation)- Returns:
- the X margin in screen pixels (0 = vertex bounds are exact)
-
paint
Renders this line to the screen using perspective-correct width and alpha blending.This method handles two rendering modes:
- Thin lines: When the projected width is below threshold, draws single-pixel lines with alpha adjusted for sub-pixel appearance.
- Thick lines: Creates four edge interpolators and fills the rectangular area scanline by scanline with perspective-correct alpha fading at edges.
- Specified by:
paintin classAbstractCoordinateShape- Parameters:
buffer- the rendering context containing the pixel buffer
-