picogl.renderer.mesh_builder

Accumulate indexed mesh parts into a single MeshData.

Attributes

MeshPart

Classes

MeshBuilder

Accumulate mesh parts into one indexed mesh with face-index offsets.

Functions

solid_color_mesh_part(vertices, faces, normals[, color]) → MeshPart

Build a MeshPart with a single RGB colour tiled per vertex.

mesh_part_from_pnc(pnc, faces) → MeshPart

Attach face indices to a PNCPart.

stack_mesh_parts(parts) → Optional[MeshPart]

Concatenate mesh parts with face-index offsets.

Module Contents

picogl.renderer.mesh_builder.MeshPart[source]
picogl.renderer.mesh_builder.solid_color_mesh_part(vertices: numpy.ndarray, faces: numpy.ndarray, normals: numpy.ndarray, color: Tuple[float, float, float] = (0.7, 0.7, 0.7)) → MeshPart[source]

Build a MeshPart with a single RGB colour tiled per vertex.

Parameters:
  • vertices – (N, 3) positions

  • faces – (M, 3) or flat index buffer

  • normals – (N, 3) normals

  • color – RGB triple in [0, 1]

Returns:

MeshPart tuple

picogl.renderer.mesh_builder.mesh_part_from_pnc(pnc, faces: numpy.ndarray) → MeshPart[source]

Attach face indices to a PNCPart.

Parameters:
  • pnc – (positions, normals, colors)

  • faces – (M, 3) or flat index buffer

Returns:

MeshPart (positions, faces, normals, colors)

class picogl.renderer.mesh_builder.MeshBuilder[source]

Accumulate mesh parts into one indexed mesh with face-index offsets.

Each part is (vertices, faces, normals, colors). Face indices in subsequent parts are offset so they remain valid after concatenation.

vertices: List[numpy.ndarray] = [][source]
faces: List[numpy.ndarray] = [][source]
normals: List[numpy.ndarray] = [][source]
colors: List[numpy.ndarray] = [][source]
vertex_offset = 0[source]
add_part(part: MeshPart | None) → None[source]

Append one mesh part, skipping None / empty vertex arrays.

Parameters:

part – (vertices, faces, normals, colors) or None. faces may be (M, 3) triangles or a flat index buffer.

build() → MeshPart | None[source]

Stack accumulated parts into (vertices, faces, normals, colors).

Returns:

Stacked MeshPart, or None when no parts were added

mesh_data() → picogl.renderer.meshdata.MeshData | None[source]

Build a MeshData from parts.

Returns:

MeshData, or None when no parts were added

__enter__() → MeshBuilder[source]
__exit__(exc_type, exc_value, traceback) → bool[source]
__repr__() → str[source]
picogl.renderer.mesh_builder.stack_mesh_parts(parts: Sequence[MeshPart | None]) → MeshPart | None[source]

Concatenate mesh parts with face-index offsets.

Parameters:

parts – Sequence of mesh parts (None / empty skipped)

Returns:

Stacked MeshPart, or None