Class AbstractCoordinateShape
- Direct Known Subclasses:
CanvasCharacter,ForwardOrientedTexture,Line,SolidPolygon,TexturedPolygon
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 Summary
FieldsModifier and TypeFieldDescriptionfinal Vertex[]The vertex coordinates that define this shape's geometry.doubleAverage Z-depth of this shape in screen space after transformation.final intUnique identifier for this shape instance, used as a tiebreaker when sorting shapes with identical Z-depth values.Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
mouseInteractionController -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCoordinateShape(int pointsCount) Creates a shape with the specified number of vertices, each initialized to the origin (0, 0, 0).AbstractCoordinateShape(Vertex... vertexes) Creates a shape from the given vertices. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetZ()Returns the average Z-depth of this shape in screen space.abstract voidpaint(RenderingContext renderBuffer) Paints this shape onto the rendering context's pixel buffer.voidtransform(TransformStack transforms, RenderAggregator aggregator, RenderingContext renderingContext) Transforms this shape from world space to screen space and queues it for rendering.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
setMouseInteractionController
-
Field Details
-
shapeId
public final int shapeIdUnique identifier for this shape instance, used as a tiebreaker when sorting shapes with identical Z-depth values. -
coordinates
The vertex coordinates that define this shape's geometry. Each vertex contains both the original world-space coordinate and a transformed screen-space coordinate computed duringtransform(eu.svjatoslav.sixth.e3d.math.TransformStack, eu.svjatoslav.sixth.e3d.renderer.raster.RenderAggregator, eu.svjatoslav.sixth.e3d.gui.RenderingContext). -
onScreenZ
public double onScreenZAverage Z-depth of this shape in screen space after transformation. Used by theRenderAggregatorto sort shapes back-to-front for correct painter's algorithm rendering.
-
-
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
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
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.transformedCoordinateto 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
RenderAggregatorfor 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:
transformin classAbstractShape- Parameters:
transforms- the current stack of transforms (world-to-camera transformations)aggregator- collects transformed shapes for depth-sorted renderingrenderingContext- provides frame dimensions, graphics context, and frame metadata
-