newton.Mesh#
- class newton.Mesh(vertices, indices, compute_inertia=True, is_solid=True)#
Describes a triangle collision mesh for simulation
Example mesh creation from a triangle OBJ mesh file:#
See
load_mesh()
which is provided as a utility function.import numpy as np import warp as wp import newton import openmesh m = openmesh.read_trimesh("mesh.obj") mesh_points = np.array(m.points()) mesh_indices = np.array(m.face_vertex_indices(), dtype=np.int32).flatten() mesh = newton.Mesh(mesh_points, mesh_indices)
- vertices#
Mesh 3D vertices points
- Type:
List[Vec3]
- I#
3x3 inertia matrix of the mesh assuming density of 1.0 (around the center of mass)
- Type:
Mat33
- com#
The center of mass of the body
- Type:
Vec3
Methods
__init__
(vertices, indices[, ...])Construct a Mesh object from a triangle mesh
finalize
([device, requires_grad])Constructs a simulation-ready
Mesh
object from the mesh data and returns its ID.- __init__(vertices, indices, compute_inertia=True, is_solid=True)#
Construct a Mesh object from a triangle mesh
The mesh center of mass and inertia tensor will automatically be calculated using a density of 1.0. This computation is only valid if the mesh is closed (two-manifold).
- Parameters:
vertices (Sequence[list[float] | tuple[float, float, float] | vec3f]) – List of vertices in the mesh
indices (Sequence[int]) – List of triangle indices, 3 per-element
compute_inertia – If True, the mass, inertia tensor and center of mass will be computed assuming density of 1.0
is_solid – If True, the mesh is assumed to be a solid during inertia computation, otherwise it is assumed to be a hollow surface