dhart.geometry.MeshInfo

class dhart.geometry.MeshInfo(indices_or_pointer: List[Tuple[int, int, int]] | List[int] | c_void_p | str, vertices: List[Tuple[float, float, float]] | List[float] | None = None, name: None | str = '', id: None | int = 39)

A mesh stored in C++ as a 3*n array.

MeshInfo is required in order to create Embree BVhs

__init__(indices_or_pointer: List[Tuple[int, int, int]] | List[int] | c_void_p | str, vertices: List[Tuple[float, float, float]] | List[float] | None = None, name: None | str = '', id: None | int = 39)

Create a new meshinfo from either a pointer to an existing mesh object or vertices for a mesh.

Parameters:
  • indices_or_pointer – Either a pointer to a valid mesh object from LoadOBJ, or indicies as a list of 3 element tuples or a flat list of integers representing the faces of the mesh. Also supports passing a filepath to an OBJ

  • vertices – a flat list of floats or a list of 3 index tuples representing the vertices of the mesh. If this is specified then the first argument MUST be a list of indices

  • name – The name of the mesh. Only supported if not supplying a pointer

  • id – Assign a specific ID to this mesh. Only supported if not supplying a pointer

Raises:

InvalidOBJException – The list of indices/vertices don’t create a valid mesh

Examples

Manually construct a flat plane, by giving the vertices and triangles straight to the mesh info constructor.

>>> from dhart.geometry import MeshInfo
>>> vertices = [(-10, 0.0, 10), (-10, 0.0, -10),(10, 0.0, 10),(10, 0.0, 10),]
>>> tris = [[3, 1, 0], [2, 3, 0]]
>>> MI = MeshInfo(tris, vertices)

Methods

Rotate(rotation)

Rotate this mesh by the given rotation

SetupVertAndIndexArrays()

Update name, id, and vert/index arrays from C++