import eu.svjatoslav.sixth.e3d.renderer.raster.texture.TextureBitmap;
/**
- * Texture object that is always oriented towards the viewer.
+ * Base class for textures always facing the viewer.
+ * <p>
+ * This class implements the "billboard" rendering technique where the texture
+ * remains oriented towards the camera regardless of 3D position. The visible size
+ * is calculated based on distance from viewer (z-coordinate) and scale factor.
+ * <p>
+ * The texture mapping algorithm:
+ * 1. Calculates screen coverage based on perspective
+ * 2. Clips to viewport boundaries
+ * 3. Maps texture pixels to screen pixels using proportional scaling
*/
public class ForwardOrientedTexture extends AbstractCoordinateShape {
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
+/**
+ * A glowing 3D point rendered with a circular gradient texture.
+ * <p>
+ * This class creates and reuses textures for glowing points of the same color.
+ * The texture is a circle with an alpha gradient from center to edge, ensuring
+ * a consistent visual appearance regardless of viewing angle.
+ * <p>
+ * The static set of glowing points enables texture sharing and garbage
+ * collection of unused textures via WeakHashMap.
+ */
public class GlowingPoint extends ForwardOrientedTexture {
private static final int TEXTURE_RESOLUTION_PIXELS = 100;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape;
+
/**
- * Line in 3D space.
- *
- * Line is represented by two points, width and color and width.
+ * A 3D line segment with perspective-correct width and alpha blending.
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ * <p>
+ * 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.
*/
public class Line extends AbstractCoordinateShape {
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
+
+/**
+ * Factory for creating Line objects with consistent appearance settings.
+ * <p>
+ * This class encapsulates common line styling parameters (width and color) to
+ * avoid redundant configuration. It provides multiple constructors for
+ * flexibility and ensures default values are used when not specified.
+ */
public class LineAppearance {
private final double lineWidth;
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line;
+/**
+ * Interpolates between two points along a line for scanline rendering.
+ * <p>
+ * This class calculates screen coordinates and depth values (d) for a given Y
+ * position. It supports perspective-correct interpolation by tracking the
+ * distance between points and using it to compute step increments.
+ * <p>
+ * The comparison logic prioritizes interpolators with greater vertical coverage
+ * to optimize scanline ordering.
+ */
public class LineInterpolator {
private double x1, y1, d1, x2, y2, d2;
import static eu.svjatoslav.sixth.e3d.geometry.Polygon.pointWithinPolygon;
/**
- * polygon with solid color.
+ * A solid-color triangle renderer with mouse interaction support.
+ * <p>
+ * 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
+ * <p>
+ * The static drawPolygon method is designed for reuse by other polygon types.
*/
public class SolidPolygon extends AbstractCoordinateShape {
import static java.lang.Math.abs;
+/**
+ * Interpolator for textured polygon edges with perspective correction.
+ * <p>
+ * This class maps screen coordinates to texture coordinates while maintaining
+ * perspective accuracy.
+ * It's used to create texture-mapped scanlines that adjust for depth (z) to
+ * prevent texture distortion.
+ * <p>
+ * The comparison logic ensures proper scanline ordering based on vertical
+ * coverage and horizontal span.
+ */
public class PolygonBorderInterpolator implements
Comparable<PolygonBorderInterpolator> {