kaolin.conversions.meshconversions¶
-
trianglemesh_to_pointcloud
(mesh: kaolin.rep.Mesh.Mesh, num_points: int)[source]¶ Converts passed mesh to a pointcloud
- Parameters
mesh (kaolin.rep.Mesh) – mesh to convert
num_points (int) – number of points in converted point cloud
- Returns
converted point cloud
- Return type
Example
>>> mesh = kal.TriangleMesh.from_obj('object.obj') >>> points = kal.conversions.trianglemesh_to_pointcloud(mesh, 10) >>> points tensor([[ 0.0524, 0.0039, -0.0111], [-0.1995, 0.2999, 0.0408], [-0.1921, -0.0268, 0.1811], [ 0.1292, 0.0039, 0.2030], [-0.1859, 0.1764, 0.0168], [-0.1749, 0.1515, -0.0925], [ 0.1990, 0.0039, -0.0083], [ 0.2173, -0.1285, -0.2248], [-0.1916, -0.2143, 0.2064], [-0.1935, 0.2401, 0.1003]]) >>> points.shape torch.Size([10, 3])
-
trianglemesh_to_voxelgrid
(mesh: kaolin.rep.Mesh.Mesh, resolution: int, normalize: bool = True, vertex_offset: float = 0.0)[source]¶ Converts mesh to a voxel model of a given resolution
- Parameters
- Returns
voxel array of desired resolution
- Return type
voxels (torch.Tensor)
Example
>>> mesh = kal.TriangleMesh.from_obj('model.obj') >>> voxel = kal.conversions.trianglemesh_to_voxelgrid(mesh, 32) >>> voxel.shape
-
trianglemesh_to_sdf
(mesh: kaolin.rep.Mesh.Mesh, num_points: int = 10000)[source]¶ Converts mesh to a SDF function
- Parameters
mesh (kaolin.rep.Mesh) – mesh to convert.
num_points (int) – number of points to sample on surface of the mesh.
- Returns
a signed distance function
- Return type
sdf
Example
>>> mesh = kal.TriangleMesh.from_obj('object.obj') >>> sdf = kal.conversions.trianglemesh_to_sdf(mesh) >>> points = torch.rand(100,3) >>> distances = sdf(points)