Class ShapeCollection
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddShape(AbstractShape shape) Adds a shape to this collection.voidclear()Removes all shapes from this collection.Returns the list of all shapes currently in this collection.voidpaint(ViewPanel viewPanel, RenderingContext renderingContext) Renders all shapes in this collection for the current frame.
-
Constructor Details
-
ShapeCollection
public ShapeCollection()
-
-
Method Details
-
addShape
Adds a shape to this collection. This method is thread-safe.- Parameters:
shape- the shape to add to the scene
-
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
Renders all shapes in this collection for the current frame.This method performs the full render pipeline:
- Resets the aggregator and transform stack
- Applies the camera rotation (avatar's viewing direction)
- Applies the camera translation (avatar's position in the world)
- Transforms all shapes to screen space
- Sorts shapes by depth and paints them back-to-front
- Parameters:
viewPanel- the view panel providing the camera staterenderingContext- the rendering context with pixel buffer and frame metadata
-