Get rendering mesh¶
Note
If you haven’t already done so, make sure you’ve completed the steps in Basic before starting this tutorial. This tutorial will be based on SAPIEN assets and rendering.
Get rendering mesh from visual bodies¶
For any Actor
in SAPIEN, call get_visual_bodies()
to get all visual body
associated with it. For each visual body, call get_render_shapes
to get all
shapes associated to this visual body. the local pose of the shape relative to
the Actor
is in its pose
variable, and it also has a mesh
variable
providing vertices, triangle indices, normals, uvs, tangents and bitangents.
The following code snippet shows how to get all the meshes of an articulation and display them with open3d.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | meshes = []
for link in asset.get_base_links():
visual_bodies = link.get_visual_bodies()
for v in visual_bodies:
shapes = v.get_render_shapes()
for s in shapes:
pose = link.pose * s.pose
scale = s.scale
T = pose.to_transformation_matrix()
T = T @ np.diag(list(scale) + [1])
vertices = s.mesh.vertices
indices = s.mesh.indices
mesh = open3d.geometry.TriangleMesh(
open3d.utility.Vector3dVector(vertices),
open3d.utility.Vector3iVector(indices.reshape(-1, 3)),
)
mesh.transform(T)
meshes.append(mesh)
open3d.visualization.draw_geometries(meshes)
|
Note
Getting rendering meshes from SAPIEN involves reading the meshes from GPU thus being very slow. The user is responsible for caching them for future use.