Hi,
I love the Molecular addon, it is the simulation system Blender was missing. But it lacks a way to drive meshes and hair particles with, which makes it not so useful for many people, which like me, want to render the simulations in an actual animation or something… So I decided to take on the task of making that possible!
Here is a simple cloth sim I made with Molecular, and drove the mesh with P-mh driver:
Here is a simple rigid body sim I made with Molecular, and drove the object with P-mh driver:
Currently P-mh driver can only make vertices follow particles at exactly the same position, or make objects follow solid groups of particles, so it can be used for cloth/surface and rigid body sim, but not yet for hair or soft body (I am working on it…). This addon makes a mesh follow the movement of a particle system. It is not a mesher, meaning it does not generate a mesh around the particles. We already have several options for meshers, which are very useful for fluids, but not for clothes, hair, etc.
To use P-mh driver, you can manually set up a cloth or rigid body particle simulation, or press the “Create Particle Cloth”/“Create Particle Rigid Body” button in the “P-mh driver” panel, which will create a particle system already set up for cloth/rigid body sim. Then you can tweak your simulation and bake it. And at last, for cloth sim you can set a custom directory for the bake file (if you don’t, it will save the bake file in the same directory as your .blend file, if your .blend file is not saved, it will save the bake file in your “User” folder), and finally, just press the “Bake Cloth”/“Bake Rigid Body” button, also in the “P-mh driver” panel.
During the baking process, Blender will freeze, but you can track the bake progress in the System Console (don’t forget to open it before you start baking).
P-mh driver uses the “Export Pointcache Format” addon (Included in Blender) for cloth sim, to generate a point cache (.pc2) file. The .pc2 file will have the name of the baked mesh.
And finally here is the Addon itself (compatible with Blender 2.71):
Here is a feature list (YES=Already working, NO=Is not working yet, WIP=What I am currently working on):
-Drive a cloth mesh = YES
-Compensate for misplaced particles = YES
-Drive a rigid body mesh = YES
-Auto set up particle cloth sim = YES
-Auto set up particle rigid body sim = YES
-Cache/bake = YES
-User interface = YES
-Drive hair = WIP
-Generate particles from hair = WIP
-Drive meshes with rips = NO
-Deform a pre-modeled cloth mesh = NO
-Drive a soft body mesh = NO
Thanks to Nghia Ho for his great article on: Finding optimal rotation and translation between corresponding 3D points
Please comment, suggest features, report bugs, etc.
I hope you like it!
Luca Rood
Changelog:
v0.1 2014-07-06
-Mesh vertices follow particles. (cloth/surface)
-Drive vertices with missing particles (loose vertices).
v0.2 2014-07-23
-Auto set up particle cloth sim.
-Bake mesh movement to file.
-Optimized calculation and playback method.
-Local/World space conversion.
-UI.
v0.3 2014-07-30
-Object follow particle groups. (rigid body)
-Auto set up particle rigid body sim.
v0.3.1 2014-09-20
-Particle size calculation error fix.
-Minor interface bug fix.
-Switched particle search method to kd-tree. (performance improvement)
–Start of technical explanation–
Cloth: The addon looks for vertices and particles at the same position using a kd-tree search, and adds them to a correspondence list. It adds a “frame_change” handler, for a function that will set each vertex’s position to the position of its corresponding particle (if a vertex has no corresponding particle it sets it’s position to the average of the adjacent particles). Then it calls the “Export Pointcache Format” addon, which will save the mesh position on each frame to a .pc2 file. And finally it adds a “Mesh Cache” modifier to the mesh, pointing at the generated .pc2 file.
Rigid Body: The addon parents the object to an empty. Then uses the Kabsch algorithm to generate a rotation matrix, and applies it to that empty, it sets the empty’s location to the average of the particle cloud. Finally it adds a locrot keyframe to the empty. It repeats that process for each frame.