Class ShapeCollection

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection

public class ShapeCollection extends Object
Root container that holds all 3D shapes in a scene and orchestrates their rendering.

ShapeCollection is the top-level scene graph. You add shapes to it, and during each render frame it transforms all shapes from world space to screen space (relative to the camera), sorts them by depth, and paints them back-to-front.

Usage example:


 // Get the root shape collection from the view panel
 ShapeCollection scene = viewPanel.getRootShapeCollection();

 // Add shapes to the scene
 scene.addShape(new Line(
     new Point3D(0, 0, 100),
     new Point3D(100, 0, 100),
     Color.RED, 2.0
 ));

 scene.addShape(new WireframeCube(
     new Point3D(0, 0, 200), 50,
     new LineAppearance(5, Color.GREEN)
 ));
 

The addShape(eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape) method is synchronized, making it safe to add shapes from any thread while the rendering loop is active.

See Also:
  • Constructor Details

    • ShapeCollection

      public ShapeCollection()
  • Method Details

    • addShape

      public void addShape(AbstractShape shape)
      Adds a shape to this collection. This method is thread-safe.
      Parameters:
      shape - the shape to add to the scene
    • getShapes

      public Collection<AbstractShape> getShapes()
      Returns the list of all shapes currently in this collection.
      Returns:
      unmodifiable view would be safer, but currently returns the internal list
    • clear

      public void clear()
      Removes all shapes from this collection.
    • paint

      public void paint(ViewPanel viewPanel, RenderingContext renderingContext)
      Renders all shapes in this collection for the current frame.

      This method performs the full render pipeline:

      1. Resets the aggregator and transform stack
      2. Applies the camera rotation (avatar's viewing direction)
      3. Applies the camera translation (avatar's position in the world)
      4. Transforms all shapes to screen space
      5. Sorts shapes by depth and paints them back-to-front
      Parameters:
      viewPanel - the view panel providing the camera state
      renderingContext - the rendering context with pixel buffer and frame metadata