Class AbstractCoordinateShape

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
Direct Known Subclasses:
CanvasCharacter, ForwardOrientedTexture, Line, SolidPolygon, TexturedPolygon

public abstract class AbstractCoordinateShape extends AbstractShape
Base class for shapes defined by an array of vertex coordinates.

This is the foundation for all primitive renderable shapes such as lines, solid polygons, and textured polygons. Each shape has a fixed number of vertices (Vertex objects) that define its geometry in 3D space.

During each render frame, the transform(eu.svjatoslav.sixth.e3d.math.TransformStack, eu.svjatoslav.sixth.e3d.renderer.raster.RenderAggregator, eu.svjatoslav.sixth.e3d.gui.RenderingContext) method projects all vertices from world space to screen space. If all vertices are visible (in front of the camera), the shape is queued in the RenderAggregator for depth-sorted painting via the paint(eu.svjatoslav.sixth.e3d.gui.RenderingContext) method.

Creating a custom coordinate shape:


 public class Triangle extends AbstractCoordinateShape {
     private final Color color;

     public Triangle(Point3D p1, Point3D p2, Point3D p3, Color color) {
         super(new Vertex(p1), new Vertex(p2), new Vertex(p3));
         this.color = color;
     }

     public void paint(RenderingContext ctx) {
         // Custom painting logic using ctx.graphics and
         // coordinates[i].transformedCoordinate for screen positions
     }
 }
 
See Also:
  • Field Details

  • Constructor Details

    • AbstractCoordinateShape

      public AbstractCoordinateShape(int pointsCount)
      Creates a shape with the specified number of vertices, each initialized to the origin (0, 0, 0).
      Parameters:
      pointsCount - the number of vertices in this shape
    • AbstractCoordinateShape

      public AbstractCoordinateShape(Vertex... vertexes)
      Creates a shape from the given vertices.
      Parameters:
      vertexes - the vertices defining this shape's geometry
  • Method Details

    • getZ

      public double getZ()
      Returns the average Z-depth of this shape in screen space.
      Returns:
      the average Z-depth value, used for depth sorting
    • paint

      public abstract void paint(RenderingContext renderBuffer)
      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 to draw pixels.

      Parameters:
      renderBuffer - the rendering context containing the pixel buffer and graphics context
    • transform

      public void transform(TransformStack transforms, RenderAggregator aggregator, RenderingContext renderingContext)
      Transforms this shape from world space to screen space and queues it for rendering.

      This method is called once per frame for each shape in the scene. Implementations should apply the current transform stack to their vertices, compute screen-space coordinates, and if the shape is visible, add it to the RenderAggregator for depth-sorted painting.

      Transforms all vertices to screen space by applying the current transform stack. Computes the average Z-depth and, if all vertices are visible (in front of the camera), queues this shape for rendering.

      Specified by:
      transform in class AbstractShape
      Parameters:
      transforms - the current stack of transforms (world-to-camera transformations)
      aggregator - collects transformed shapes for depth-sorted rendering
      renderingContext - provides frame dimensions, graphics context, and frame metadata