simvx.core.graphics.mesh¶
Geometry data with procedural primitives.
High-level: Mesh.cube(), Mesh.sphere(), Mesh.cone() Low-level: Mesh(positions, indices, normals, texcoords) + interleaved_bytes()
Module Contents¶
Classes¶
Vertex data with optional GPU buffers. Pure data until renderer uploads. |
API¶
- class simvx.core.graphics.mesh.Mesh(positions, indices=None, normals=None, texcoords=None, topology='triangles')¶
Vertex data with optional GPU buffers. Pure data until renderer uploads.
Create via class methods: Mesh.cube(), Mesh.sphere(), Mesh.cone(), Mesh.cylinder() Or from raw data: Mesh(positions, indices, normals, texcoords) Or load from file: Mesh.from_obj(“model.obj”)
Initialization
- property vertex_count: int¶
- property index_count: int¶
- property stride: int¶
Bytes per interleaved vertex.
- property has_normals: bool¶
- property has_texcoords: bool¶
- interleaved_bytes() bytes¶
Pack vertex data interleaved (pos[,normal][,uv]) for GPU upload.
- index_bytes() bytes¶
- bounding_box() tuple[numpy.ndarray, numpy.ndarray]¶
Returns (min_corner, max_corner) as vec3 arrays.
- bounding_radius() float¶
Radius of bounding sphere centered at origin.
- generate_normals() simvx.core.graphics.mesh.Mesh¶
Compute smooth vertex normals from face geometry. Returns self.
- classmethod cube(size: float = 1.0) simvx.core.graphics.mesh.Mesh¶
Axis-aligned cube centered at origin. 24 vertices, 36 indices.
- classmethod sphere(radius: float = 1.0, rings: int = 16, segments: int = 16) simvx.core.graphics.mesh.Mesh¶
UV sphere.
- classmethod cone(radius: float = 0.5, height: float = 1.0, segments: int = 16) simvx.core.graphics.mesh.Mesh¶
Cone pointing up +Y, base centered at origin.
- classmethod cylinder(radius: float = 0.5, height: float = 1.0, segments: int = 16) simvx.core.graphics.mesh.Mesh¶
Cylinder along +Y axis, centered at origin.
- classmethod load(path: str) simvx.core.graphics.mesh.Mesh¶
Load a mesh from a file path.
Supports OBJ format. Uses ResourceCache when available for deduplication.
Args: path: File path to load (currently only
.objfiles).Returns: Loaded Mesh instance.
Raises: ValueError: If the file format is unsupported.
- classmethod from_obj(path: str) simvx.core.graphics.mesh.Mesh¶
Load from Wavefront OBJ. Handles v/vt/vn/f directives.