jannik
jannik

Reputation: 21

Tracking the Mesh of Deformables (3D .obj files) in PyBullet Simulation (Python)

I am using PyBullet to simulate the behavior of deformable objects. The objects are loaded using PyBullets loadSoftBody() function. I load the deformable from a 3D .obj file where the vertex positions as well as the faces are defined (mesh).

I tried to track the vertex positions over time using PyBullets getMeshData(). To have the complete information about the mesh, I need the order of the indices to be the same as in the .obj file to know which vertices are connected.

The problem is that the function getMeshData() returns way more vertices than I actually have (with many duplicates) and therefore makes it impossible to find out which of the returned vertices are connected.

Does anyone have an idea how to get this working?

Upvotes: 1

Views: 344

Answers (1)

jannik
jannik

Reputation: 21

I got it working myself.

Somehow the following code works:

"""Returns num mesh vertices and vertex positions."""
kwargs = {}
if hasattr(pybullet, "MESH_DATA_SIMULATION_MESH"):
    kwargs["flags"] = pybullet.MESH_DATA_SIMULATION_MESH
num_verts, mesh_vert_positions = pybullet.getMeshData(deform_id, **kwargs)

(source: https://github.com/contactrika/dedo/blob/main/dedo/utils/mesh_utils.py)

Upvotes: 1

Related Questions