k3d

Implement an explicit topology model → derived render meshes → LWJGL3 rendering pipeline. The critical part is keeping editing operations on topology, not on triangle meshes. Triangles are a cache.

1) Architecture layers

1. Model layer (authoritative)

Owns editable geometry and semantics.

Entities

Indexes / adjacency

Edits mutate this graph and update adjacency + spatial index.

2. Derived geometry layer (cache)

Produces renderable buffers, rebuilt incrementally.

Per container (model or group definition):

Dirty flags:

Rules:

3. Rendering layer (libGDX on LWJGL3)

libGDX already wraps LWJGL; you don’t render “with LWJGL” directly unless you want to drop down to custom GL calls. Use:

Keep rendering entirely separate from modeling.

4. Interaction layer

5. Command layer (undo/redo)


2) Why topology-first is mandatory

If you edit only triangle meshes:

So:


3) Concrete base implementation plan

Step A — Minimal model + rendering

  1. Implement Vertex, Edge, Face with adjacency.
  2. Implement “create edge” tool in a single plane (ground plane only).
  3. Face creation:

    • detect closed loop
    • verify planarity
    • create Face
  4. Triangulate face to render mesh:

    • simplest: polygon triangulation in face local 2D coordinates.
  5. Render:

    • faces as triangles (solid shaded)
    • edges as lines overlay

At this stage you already have the “SketchUp feel” starting.

Step A.1 — Implemented Architecture (Current State)

The current implementation follows a modified version of the proposed architecture:

Model Layer:

Derived Geometry Layer:

Rendering Layer:

Interaction Layer:

Command Layer (Partial):

Plugin Layer (Implemented):

Step B — Picking + snapping + inference

Step C — Push/Pull extrusion

Step D — Cutting/splitting


4) Data structures that make this workable

4.1 Stable IDs and reference storage

Use stable IDs for topology objects; selection stores IDs, not pointers.

4.2 Half-edge vs simple adjacency

You can start with “simple adjacency” (edge stores up to 2 adjacent faces) for MVP. If you want robust planar edits and holes, a half-edge structure becomes worth it later.

Pragmatic approach:

4.3 Spatial index

You need this early. Without it, picking and inference will feel broken at scale.


5) Rendering decisions (libGDX + LWJGL3)

Faces

Edges

Default GL lines are inconsistent across platforms and not thick. Better:

Shadows

Directional light shadow mapping:


6) Minimal class map (base)


If you want the next step to be actionable: implement (1) topology for edges/faces, (2) triangulation into a libGDX Mesh, (3) BVH picking with ground-plane fallback, and (4) snap selection. Everything else builds on that