Skip to main content

Utilities

The rpts.utils module contains three helper functions. They look up the mesh and material that belong to a node. Access them as rpts.utils.<name>().

Written from source code

These functions have no docstrings in the source yet. The Sphinx output does not include rpts.utils at all. The descriptions on this page are taken from the function bodies in rp_extensions.py (lines 1792 to 1816). If the code changes, update this page to match.

Functions​

get_mesh_material(asset, mesh)​

Returns the material in slot 0 of the given mesh. The function reads the mesh's first material slot index with mesh.material_index(0), then looks up that index on the asset with asset.material(...).

  • asset (Asset): the asset that contains the mesh.
  • mesh (Mesh): the mesh whose material you want.

Returns: the Material at that index on the asset.

get_node_mesh(asset, node)​

Returns the mesh that a node references. The function reads the node's mesh_index. If the index is -1, the node has no mesh, and the function returns None. Otherwise it returns asset.mesh(index).

  • asset (Asset): the asset that contains the node.
  • node (Node): the node to look up.

Returns: the Mesh referenced by the node, or None if the node has no mesh.

get_node_material(asset, node)​

Returns the material of a node's mesh. The function calls get_node_mesh(). If that returns a mesh, the function returns get_mesh_material() for that mesh. Otherwise it returns None.

  • asset (Asset): the asset that contains the node.
  • node (Node): the node to look up.

Returns: the Material in slot 0 of the node's mesh, or None if the node has no mesh.

What the source does not show

The function bodies do not handle a mesh that has no material slots. The source does not show what mesh.material_index(0) returns in that case, so this page does not state it. The bodies also test the mesh with a plain truth check (if node_mesh:), not is not None. The source does not show whether a Mesh object can ever be falsy.