Example on how to read rigid body bin files #305
-
Hello, Thank you for this wonderful simulator. I used it copiously in our work "SurfsUp: Learning Fluid Simulation from Novel Surfaces" (https://surfsup.cs.columbia.edu/), published at ICCV 2023. I'm very grateful for your help with Github issues I raised, and for building and maintaining Splishsplash. Thanks very much. I had a quick question about reading rigid body files exported during a simulation. I'm trying to read the .bin files that are exported, to get the rotation and translation attributes of the rigid body. However, I'm not able to read the bin files in Python. I can try to read the VTK files, but I think it is harder to extract the rotation and translation from those. I've realized some people have asked about the .bin files in the past. Could you provide a minimal Python example of how one could read these .bin files? That would be super helpful if possible. If there's another simple way to get the rotation and translation of the rigid body during the simulation, that would also work. I'd prefer not to write my own exporter, unless it has to come to doing that. Would greatly appreciate any help. Thanks very much. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Hi, Nice Work! The .bin format is very simple and I just introduced it to avoid exporting lots of mesh files. The first file contains information which do not change over time and the following files only contain the translation and rotation matrix for each rigid body. I wrote a Maya Python script to import these files in Maya. You find the relevant function here in line 1244: SPlisHSPlasH/Scripts/Maya/SPlisHSPlasH.py Line 1244 in 9696086 The script loads the whole sequence. First, first frame file is loaded (line 1248). It contains the number of bodies (1254) and then for each body a string containing the name of the mesh OBJ file (1260-1263), the scale (1281-1283), a boolean "isWall" (1287), the color (1288-1291). (I use the isWall flag to make walls invisible since fluids are often occluded by walls.) Then for all bodies: the translation (1306-1308) and the rotation (1311-1314). All following files contain only translation and rotation for all bodies (1324-1348). I would recommend to copy the code and to remove all Maya commands. Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Here are some example files which I generated with the simulator without USE_DOUBLE_PRECISION. I can load the files without problems with the script: |
Beta Was this translation helpful? Give feedback.
Hi,
Nice Work!
The .bin format is very simple and I just introduced it to avoid exporting lots of mesh files. The first file contains information which do not change over time and the following files only contain the translation and rotation matrix for each rigid body. I wrote a Maya Python script to import these files in Maya. You find the relevant function here in line 1244:
SPlisHSPlasH/Scripts/Maya/SPlisHSPlasH.py
Line 1244 in 9696086
The script loads the whole sequence. First, first frame file is loaded (line 1248). It contains the number of bodies (1254) and then for each body a string containing the name of the mesh OBJ file (1260-1263),…