Hi everyone,
I just released a new addon called “physics_handle_cache”.
It allows you to use via Python data from .bobj.gz/.bvel.gz cache files generated when baking fluid simulations in Blender, especially velocity data.
The addon is built as a generic tool, which simply provides
- a convenient API for loading parsed/listed data from cache files,
- a UI panel for handling/running so-called “client scripts” that use this very API to do whatever they want to.
I also “give away” a client script example that simply draws vertices and velocity vectors (actually, segments) in the 3D view, see below.
It is all freely available from GitHub: https://github.com/qwenger/BAddons/tree/master/Physics_HandleCache.
To use it, you simply need to download the main file (physics_handle_cache.py) and to install it as an addon. Then, open any client script (for example the one provided in the subfolder client_examples) into Blender’s text editor. Refresh the clients list into the Physics Properties -> Handle cache panel and check the one(s) you want to use. At frame changes data from cache files (if available) will be loaded and passed - as common Python structures like lists, etc. - to the client(s) that can thus handle it in any wanted way.
Of course, cache files have to be found, so you may want to bake your simulation.
The API is described in the sources and you can also learn by looking into the example. The general idea is that clients define a class which will be instanced when imported, with an interfacer object as parameter. At frame changes the instance’s update() method will be called, and it can get the available data from the interfacer. Reading and RAM-caching of the data is optimized, i.e. done once only per frame, how many clients are ever running.
Properties are defined per-object. Thus you can handle each simulation object its own way.
Any C&C’s are welcome. You can also ask me for help on using or writing client scripts. I’ll maybe add some more to the subfolder on GitHub.
And some pictures to finish with:
The Handle cache panel in Physics Properties
A simulation mesh with vertices and velocities drawn over by the example client script ogl_velocitiesrenderer.py.