TriangleMesh¶
Qualified name: algan.mobs.three\_d\_models.mesh.TriangleMesh
- class TriangleMesh(vertices, faces, normals=None, uvs=None, texture=None, vertex_colors=None, material_texture_map=None, material_texture_flags=0, normal_texture_map=None, ignore_normals=False, recompute_normals=False, **kwargs)[source]¶
Bases:
MobAn arbitrary indexed triangle mesh with optional per-corner normals, UVs and a texture map.
- Parameters:
vertices (torch.Tensor[V, 3]) – Vertex positions.
faces (torch.Tensor[F, 3]) – Triangle vertex indices into
vertices.normals (torch.Tensor[V, 3], optional) – Per-vertex normals (in the mesh’s local frame). When omitted, flat per-face normals are computed from the geometry each frame (so they stay correct under rotation and deformation).
uvs (torch.Tensor[V, 2], optional) – Per-vertex texture coordinates. Required to show
texture/material_texture_map/normal_texture_map.texture (torch.Tensor, optional) – Either a
[W, H, 5]texture map already in engine layout (as built byimage_to_texture_map()) or a raw image[H, W, C]which is converted automatically. Provides the surface albedo; replaces the per-vertex color where present.vertex_colors (torch.Tensor[V, 5], optional) – Per-vertex colors (RGB + glow + opacity). Ignored when a
textureis given. Falls back to a singlecolorotherwise.material_texture_map – Optional per-texel material-property / tangent-space normal maps, forwarded to the ray tracer exactly as for
Surface.material_texture_flags – Optional per-texel material-property / tangent-space normal maps, forwarded to the ray tracer exactly as for
Surface.normal_texture_map – Optional per-texel material-property / tangent-space normal maps, forwarded to the ray tracer exactly as for
Surface.ignore_normals (bool) – If True the mesh carries zero normals (no lighting interaction).
*args – Passed to
Mob.**kwargs – Passed to
Mob.
Methods
Get the color this Mob uses when none was given.
get_render_primitivesPer-triangle connected-component id, or
Nonefor a single shell.Attributes
animation_managerThis mob's scene-owned animation manager.
basisThe Mob's orientation and scale, as a flattened 3x3 matrix of shape
(*, 9).casts_shadowsWhether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.
childrenThe Mobs attached below this one, in attachment order.
closed_shellWhether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.
draws_descendantsWhether
get_render_primitivesreturns geometry belonging to this Mob's DESCENDANTS as well as its own.forwardGet the direction the Mob is facing.
lifespanThis mob's [spawn, despawn) interval on its Scene timeline (a
Lifespan).locationThe Mob's position in world space, shape
(*, 3).normalized_basisThe Mob's orientation with scale divided out, shape
(*, 9).parentsThe Mobs this one is attached to, in attachment order.
receives_shadowsWhether this Mob's surfaces are darkened by shadows cast onto them.
rightGet the Mob's own rightward direction.
scale_coefficientThe Mob's scale along its own right, up and forward axes, shape
(*, 3).two_sidedWhether this Mob's geometry should be lit from whichever side the ray arrives on.
upGet the Mob's own upward direction.
xThe Mob's x coordinate in world units, shape
(*, 1).xyThe Mob's x and y coordinates in world units, shape
(*, 2).yThe Mob's y coordinate in world units, shape
(*, 1).zThe Mob's z coordinate in world units, shape
(*, 1).- get_default_color()[source]¶
Get the color this Mob uses when none was given.
Override in a subclass to give a shape its own default; the built-in shapes do exactly that.
- Returns:
BLACKfor the base class.- Return type:
- triangle_shell_ids()[source]¶
Per-triangle connected-component id, or
Nonefor a single shell.An imported file’s mesh routinely holds several disconnected parts, and treating them as one surface lets the analytic-AA run rule sum coverage across parts that merely overlap on screen.
corner_indexalready carries the topology the loader read (it is kept for smooth normals), so the components are a graph walk over shared EDGES – not shared vertices, which would fuse two cones meeting at a single apex.Computed once and cached: the result depends only on construction-time topology, never on the animated positions.