picogl.renderer.glmesh
A module for GPU-resident indexed triangle meshes.
This module defines the GLMesh class, which represents a 3D mesh stored on the GPU. It provides mechanisms for defining a mesh’s vertices, faces, colors, normals, UVs, and vertex layout, along with functionality for uploading these attributes to GPU buffers and expanding indexed meshes into per-triangle vertex lists if needed.
Classes
GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. |
Module Contents
- class picogl.renderer.glmesh.GLMesh(vertices: numpy.ndarray, faces: numpy.ndarray, colors: numpy.ndarray | None = None, normals: numpy.ndarray | None = None, uvs: numpy.ndarray | None = None, use_indices: bool = True, *, shader_type: Literal[picogl.shaders.type.ShaderType.ISOSURFACE, picogl.shaders.type.ShaderType.RIBBONS] = ShaderType.ISOSURFACE)[source]
GPU‐resident mesh: owns VAO/VBO/EBO/CBO/NBO for an indexed triangle mesh. It does not know anything about shaders or matrices.
- _get_buffer_data(vbo_type: picogl.buffers.vertex.vbo.vbo_class.VBOType) numpy.ndarray | None[source]
get_buffer_data(vbo_type) -> np.ndarray
- _expand_to_non_indexed() None[source]
Expand the mesh so that every triangle has its own copy of vertices/colors/normals/uvs. This converts indexed data (shared vertices) into a per-triangle vertex list suitable for glDrawArrays. The API remains the same; just keep the EBO empty and set index_count accordingly.
- classmethod from_mesh_data(mesh: picogl.renderer.meshdata.MeshData, *, vertex_layout: picogl.shaders.type.ShaderType.ISOSURFACE | picogl.shaders.type.ShaderType.RIBBONS = ShaderType.ISOSURFACE) GLMesh[source]
Construct a GLMesh from a MeshData container.
- Parameters:
mesh (MeshData) – Must have .vertices (Nx3), .ebo (Mx1), optional .cbo (Nx3), .nbo (Nx3), uvs (Nx2)
vertex_layout –
surface→ attr order pos, color, normal (surface_with_lighting/ mesh).ribbon→ pos, normal, color (ribbons/ RibbonVAO).
- Returns:
Ready-to-upload mesh (GPU buffers are allocated only when upload() is called).
- Return type:
- update_colors(colors: numpy.ndarray)[source]