simvx.core.mesh_instance_2d

MeshInstance2D: custom 2D mesh rendering node.

Renders arbitrary 2D geometry defined by vertices, indices, UVs, and per-vertex colours. Useful for deformable shapes, terrain slices, soft-body visuals, and any geometry that doesn’t fit a simple sprite or polygon.

Module Contents

Classes

Mesh2D

Immutable-ish 2D mesh data: vertices, triangle indices, UVs, and per-vertex colours.

MeshInstance2D

Renders a custom 2D mesh defined by a :class:Mesh2D.

Data

API

simvx.core.mesh_instance_2d.log

‘getLogger(…)’

simvx.core.mesh_instance_2d.__all__

[‘Mesh2D’, ‘MeshInstance2D’]

class simvx.core.mesh_instance_2d.Mesh2D[source]

Immutable-ish 2D mesh data: vertices, triangle indices, UVs, and per-vertex colours.

Vertices and UVs are stored as (N, 2) float32 arrays. Colours are (N, 4) float32 RGBA. Indices are a flat uint32 array where every three consecutive values form one triangle.

Factory class-methods create common primitives with correct winding and UVs.

vertices: numpy.ndarray

‘field(…)’

indices: numpy.ndarray

‘field(…)’

uvs: numpy.ndarray

‘field(…)’

colours: numpy.ndarray

‘field(…)’

__post_init__()[source]
property vertex_count: int[source]
property triangle_count: int[source]
property is_empty: bool[source]
get_aabb() → tuple[simvx.core.math.types.Vec2, simvx.core.math.types.Vec2][source]

Axis-aligned bounding box as (min_corner, max_corner).

classmethod from_polygon(points: list | numpy.ndarray) → simvx.core.mesh_instance_2d.Mesh2D[source]

Fan-triangulate a convex polygon.

Points should be in order (CW or CCW). UVs are derived from the bounding box. All vertices share white colour.

classmethod from_rect(width: float, height: float, centered: bool = True) → simvx.core.mesh_instance_2d.Mesh2D[source]

Axis-aligned rectangle as two triangles.

When centered the origin is at the rectangle centre; otherwise it is at the top-left corner.

classmethod from_circle(radius: float, segments: int = 32) → simvx.core.mesh_instance_2d.Mesh2D[source]

Regular polygon approximating a circle centred at the origin.

classmethod from_grid(width: float, height: float, cols: int, rows: int, centered: bool = True) → simvx.core.mesh_instance_2d.Mesh2D[source]

Subdivided rectangle useful for terrain slices or deformation grids.

Creates a cols x rows quad grid ((cols+1)*(rows+1) vertices).

class simvx.core.mesh_instance_2d.MeshInstance2D(mesh: simvx.core.mesh_instance_2d.Mesh2D | None = None, modulate: tuple = (1.0, 1.0, 1.0, 1.0), position=None, rotation: float = 0.0, scale=None, **kwargs)[source]

Bases: simvx.core.nodes_2d.node2d.Node2D

Renders a custom 2D mesh defined by a :class:Mesh2D.

The mesh vertices are in local space and transformed by the node’s position, rotation, and scale before drawing. A modulate colour tints the output (per-vertex colours, when present, multiply against it).

Example::

mesh = Mesh2D.from_rect(64, 64)
node = MeshInstance2D(mesh=mesh, modulate=(1, 0, 0, 1))
root.add_child(node)

Initialization

modulate

‘Colour(…)’

property mesh: simvx.core.mesh_instance_2d.Mesh2D | None[source]
on_draw(renderer) → None[source]

Emit mesh triangles through the renderer’s immediate-mode API.

position

‘_SpatialVecProperty(…)’

rotation

‘Property(…)’

scale

‘_SpatialVecProperty(…)’

top_level

‘Property(…)’

z_index

‘Property(…)’

z_as_relative

‘Property(…)’

render_layer

‘Property(…)’

set_render_layer(index: int, enabled: bool = True) → None
is_on_render_layer(index: int) → bool
property absolute_z_index: int
property rotation_degrees: float
property world_position: simvx.core.math.types.Vec2
property world_rotation: float
property world_scale: simvx.core.math.types.Vec2
property world_transform: tuple[simvx.core.math.types.Vec2, simvx.core.math.types.Vec2, float]
property forward: simvx.core.math.types.Vec2
property right: simvx.core.math.types.Vec2
translate(offset: tuple[float, float] | numpy.ndarray)
rotate(radians: float)
rotate_deg(degrees: float)
look_at(target: tuple[float, float] | numpy.ndarray)
to_global(point) → simvx.core.math.types.Vec2
to_local(point) → simvx.core.math.types.Vec2
transform_points(points: list[simvx.core.math.types.Vec2]) → list[simvx.core.math.types.Vec2]
wrap_screen(margin: float = 20)
post_processed

‘Property(…)’

property transform_render_dirty: bool
strict_errors: ClassVar[bool]

True

dev_checks: ClassVar[bool]

None

dev_warnings: ClassVar[bool]

None

freeze_check_interval: ClassVar[float]

1.0

dynamic: bool

False

visible

‘Property(…)’

update_mode

‘Property(…)’

focus_mode

‘Property(…)’

drag_threshold

‘Property(…)’

focus_entered

‘Signal(…)’

focus_exited

‘Signal(…)’

__properties__: ClassVar[dict[str, simvx.core.descriptors.Property]]

None

classmethod __init_subclass__(**kwargs)
property name: str
property visible_in_tree: bool
property input_player: simvx.core.input.players.InputPlayer
property input_context: simvx.core.input.contexts.InputContext | None
reset_error() → None
add_child(node: simvx.core.node.T) → simvx.core.node.T
remove_child(node: simvx.core.node.Node) → None
reparent(new_parent: simvx.core.node.Node)
node_at(path, default=_NO_DEFAULT)
find(target, *, direct: bool = False)
find_all(target, *, direct: bool = False)
expect(target, *, direct: bool = False)
ancestor(target)
walk(*, include_self: bool = True) → collections.abc.Iterator[simvx.core.node.Node]
property path: str
property is_scene_root: bool
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) → bool
on_ready() → None
on_enter_tree() → None
on_exit_tree() → None
on_update(dt: float) → None
on_fixed_update(dt: float) → None
on_draw_3d(gizmos) → None
on_picked(event: simvx.core.input.events.PickEvent) → bool | None
on_gui_input(event: simvx.core.input.events.GuiInputEvent) → bool | None
start_coroutine(gen: simvx.core.descriptors.Coroutine) → simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
property focused: bool
property focus_rect: tuple[float, float, float, float] | None
drag_threshold_for(pointer_type: simvx.core.input.enums.PointerType | str) → float
grab_focus() → None
release_focus() → None
capture_pointer(pointer_id: int | None = None) → None
release_pointer(pointer_id: int | None = None) → None
queue_redraw() → None
property render_dirty: bool
clear_children()
destroy()
property destroying: bool
property destroyed: bool
call_deferred(method: collections.abc.Callable[..., Any], *args: Any) → None
property app
property tree: simvx.core.scene_tree.SceneTree
property viewport_size: simvx.core.math.types.Vec2
property viewport_insets: tuple[float, float, float, float]
property physics
property physics_2d
__getitem__(key: str)
classmethod get_properties() → dict[str, simvx.core.descriptors.Property]
__repr__()