nimblephysics icon indicating copy to clipboard operation
nimblephysics copied to clipboard

Create ShapeNode from Vertex positions and triangular faces

Open Flunzmas opened this issue 2 years ago • 4 comments

Describe the solution you'd like We'd like to have a way of creating shapeNodes given an array of shape (N, 3) (3D vectors for vertex positions) and an array of shape (T, 3) (defining T triangluar faces with the respective vertex indices).

Additional context The format above corresponds to the standard triangle mesh format, so supporting this kind of initialization could help in a lot of scenarios (e.g. we're dealing with non-convex objects, so we obtain the triangle mesh data by using approximate convex decomposition with V-HACD before passing it to a physics engine).

Keep up the good work, I'd be interested in helping out by improving the python side of documentation/API.

Flunzmas avatar Dec 02 '21 14:12 Flunzmas

This would be great to have, and we'd welcome a contribution! The guts of the engine rely on ASSIMP to load meshes, and then use the ASSIMP format to pass meshes around between objects. Either we'd need to work out how to get ASSIMP to create objects from triangle mesh formats in memory, or a big refactor to pass vertex arrays around.

For now, a hack you could try is writing the meshes out to temporary storage, and then reading them back in.

keenon avatar Dec 02 '21 16:12 keenon

@Flunzmas do you use Python API to import the mesh? If so, urdf data format may be of help since you can use that to import .obj or .stl files?

gonultasbu avatar Dec 02 '21 18:12 gonultasbu

@gonultasbu The question is if it is possible to load meshes directly from memory, without opening a file.

AFAIK it's possible to populate ASSIMP structures "by hand". So a patch would have to generate an aiScene struct with one aiMesh instance and feed that into the constructor that takes an aiScene.

Here are links to the API Reference of the involved structs:

  • http://assimp.sourceforge.net/lib_html/structai_scene.html
  • http://assimp.sourceforge.net/lib_html/structai_mesh.html
  • http://assimp.sourceforge.net/lib_html/data.html (general overview)

xqms avatar Dec 03 '21 09:12 xqms

@Flunzmas if you do end up implementing this, we'd welcome a PR!

keenon avatar Dec 03 '21 17:12 keenon