Class AbstractShape

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
Direct Known Subclasses:
AbstractCompositeShape, AbstractCoordinateShape

public abstract class AbstractShape extends Object
Base class for all renderable shapes in the Sixth 3D engine.

Every shape that can be rendered must extend this class and implement the transform(TransformStack, RenderAggregator, RenderingContext) method, which projects the shape from world space into screen space during each render frame.

Shapes can optionally have a MouseInteractionController attached to receive mouse click and hover events when the user interacts with the shape in the 3D view.

Shape hierarchy overview:

 AbstractShape
   +-- AbstractCoordinateShape   (shapes with vertex coordinates: lines, polygons)
   +-- AbstractCompositeShape    (groups of sub-shapes: boxes, grids, text canvases)
 
See Also:
  • Field Details

    • mouseInteractionController

      public MouseInteractionController mouseInteractionController
      Optional controller that receives mouse interaction events (click, enter, exit) when the user interacts with this shape in the 3D view. Set to null if mouse interaction is not needed.
  • Constructor Details

    • AbstractShape

      public AbstractShape()
  • Method Details

    • setMouseInteractionController

      public void setMouseInteractionController(MouseInteractionController mouseInteractionController)
      Assigns a mouse interaction controller to this shape.

      Example usage:

      
       shape.setMouseInteractionController(new MouseInteractionController() {
           public boolean mouseClicked(int button) {
               System.out.println("Shape clicked!");
               return true;
           }
           public boolean mouseEntered() { return false; }
           public boolean mouseExited() { return false; }
       });
       
      Parameters:
      mouseInteractionController - the controller to handle mouse events, or null to disable mouse interaction
    • transform

      public abstract 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.

      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