picogl.renderer.mesh_builder ============================ .. py:module:: picogl.renderer.mesh_builder .. autoapi-nested-parse:: Accumulate indexed mesh parts into a single MeshData. Attributes ---------- .. autoapisummary:: picogl.renderer.mesh_builder.MeshPart Classes ------- .. autoapisummary:: picogl.renderer.mesh_builder.MeshBuilder Functions --------- .. autoapisummary:: picogl.renderer.mesh_builder.solid_color_mesh_part picogl.renderer.mesh_builder.mesh_part_from_pnc picogl.renderer.mesh_builder.stack_mesh_parts Module Contents --------------- .. py:data:: MeshPart .. py:function:: 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 Build a :data:`MeshPart` with a single RGB colour tiled per vertex. :param vertices: ``(N, 3)`` positions :param faces: ``(M, 3)`` or flat index buffer :param normals: ``(N, 3)`` normals :param color: RGB triple in ``[0, 1]`` :return: MeshPart tuple .. py:function:: mesh_part_from_pnc(pnc, faces: numpy.ndarray) -> MeshPart Attach face indices to a :data:`~picogl.renderer.meshdata.PNCPart`. :param pnc: ``(positions, normals, colors)`` :param faces: ``(M, 3)`` or flat index buffer :return: MeshPart ``(positions, faces, normals, colors)`` .. py:class:: MeshBuilder 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. .. py:attribute:: vertices :type: List[numpy.ndarray] :value: [] .. py:attribute:: faces :type: List[numpy.ndarray] :value: [] .. py:attribute:: normals :type: List[numpy.ndarray] :value: [] .. py:attribute:: colors :type: List[numpy.ndarray] :value: [] .. py:attribute:: vertex_offset :value: 0 .. py:method:: add_part(part: Optional[MeshPart]) -> None Append one mesh part, skipping ``None`` / empty vertex arrays. :param part: ``(vertices, faces, normals, colors)`` or ``None``. ``faces`` may be ``(M, 3)`` triangles or a flat index buffer. .. py:method:: build() -> Optional[MeshPart] Stack accumulated parts into ``(vertices, faces, normals, colors)``. :return: Stacked :data:`MeshPart`, or ``None`` when no parts were added .. py:method:: mesh_data() -> Optional[picogl.renderer.meshdata.MeshData] Build a :class:`~picogl.renderer.meshdata.MeshData` from parts. :return: MeshData, or ``None`` when no parts were added .. py:method:: __enter__() -> MeshBuilder .. py:method:: __exit__(exc_type, exc_value, traceback) -> bool .. py:method:: __repr__() -> str .. py:function:: stack_mesh_parts(parts: Sequence[Optional[MeshPart]]) -> Optional[MeshPart] Concatenate mesh parts with face-index offsets. :param parts: Sequence of mesh parts (``None`` / empty skipped) :return: Stacked :data:`MeshPart`, or ``None``