Class CSGPolygon

java.lang.Object
eu.svjatoslav.sixth.e3d.csg.CSGPolygon

public class CSGPolygon extends Object
An N-gon polygon used for CSG BSP tree operations.

During BSP tree traversal, polygons may be split by planes, resulting in polygons with varying vertex counts (3 or more). The polygon stores its vertices, the plane it lies on, and material properties (color).

The color is preserved through CSG operations - split polygons inherit the color from their parent.

See Also:
  • Field Details

    • vertices

      public final List<Vertex> vertices
      The vertices defining this polygon's geometry. For CSG operations, this can be 3 or more vertices (N-gon).
    • plane

      public final CSGPlane plane
      The plane that contains this polygon. Cached for efficient BSP operations.
    • color

      public Color color
      The color of this polygon. Preserved through CSG operations; split polygons inherit this color.
  • Constructor Details

    • CSGPolygon

      public CSGPolygon(List<Vertex> vertices, Color color)
      Creates a polygon with vertices and a color.
      Parameters:
      vertices - the vertices defining this polygon (must be at least 3)
      color - the color of this polygon
      Throws:
      IllegalArgumentException - if vertices is null or has fewer than 3 vertices
  • Method Details

    • clone

      public CSGPolygon clone()
      Creates a deep clone of this polygon.

      Clones all vertices and preserves the color.

      Overrides:
      clone in class Object
      Returns:
      a new CSGPolygon with cloned data
    • flip

      public void flip()
      Flips the orientation of this polygon.

      Reverses the vertex order and negates vertex normals. Also flips the plane. Used during CSG operations when inverting solids.