NVIDIAGameWorks / FleX

Other
650 stars 100 forks source link

Python Bindings for FleX - Open Source Release #66

Open henryclever opened 5 years ago

henryclever commented 5 years ago

I saw a previous thread asking about bindings for FleX, and someone posted in my other thread asking for my bindings to be shared (but the latter is now deleted?). So, I've created a new repository with the bindings and installation instructions.

https://github.com/henryclever/FleX_PyBind11

Take care, Henry C.

Amir-Arsalan commented 5 years ago

It would be more helpful if you can post some examples of what you can do with these bindings as well.

henryclever commented 5 years ago

Hi Amir,

Currently, the bindings are just used to run the FleX demo. I have only published the boilerplate code that lets you initialize the simulator with a single wrapper, update the frame, and send and receive variables in python. For example, there is a function in main_python.cpp that grabs particle positions. The python binding `bindings.grab_x_pos_particle(i)' allows you to grab the x position of any particle in the scene. An example for sending variables to C++ is that you can add variables to the void initialize() function in main_python.cpp and pass directly from python.

I've not posted any more explicit examples as my application is very specific to my research and I will wait until my research is published. The bulk of my work on these bindings was to link the libraries from FleX and CUDA to pybind11 in CMake files, which allows you to create more bindings as needed. I may or may not create a more general purpose set of bindings.

-Henry C.

ryousukenasuno commented 5 years ago

It is very helpful for me!! I want to recompile main_python.cpp but demo/compiler/makelinux64/Makefile does not contain main_python.cpp. How do I recompile this code?

henryclever commented 5 years ago

Hello,

The standard compiler/makefile in my code does not reference main_python.cpp. When you compile and run it with the off-the-shelf executable, it only references main.cpp, which is OK. This should not preclude the bindings from working. Running the pip install ./bindings command compiles the main_python.cpp, so if there are any errors in main_python.cpp, they will show there. You should not have to run the original compiler more than once; rather use pip to re-install the bindings every time you update the main_python.cpp.

Take care, -Henry C.

ryousukenasuno commented 5 years ago

Hi henry, thank you for your response and I understood relationship main.cpp and main_python.cpp.

best regards,