PY4D Boids
7. August 2009 – 19:17Tags: boids, cinema 4D, flocking, py4d, Python
Sebastian Rath´s PY4D is a new, alternative way to script with or to code plugins for Cinema4D – without COFFE or C++ – but in Python.
The current beta (v0.9.0001) already makes a fine impression and proves itself easy to get started with.
This video shows a little script that was adapted in a twinkling and controls the particles of a TP-storm emitter to behave after the three flocking boids rules.
Don has rendered a much prettyer version of the dummy above.
You can download the C4D-scene here or view the scriptfile.

10 Responses to “PY4D Boids”
I dont know if you will see this but It seem you have plugged into python, I do not know why but cinema still does not have a a decent way to break a object apart based on fractal. It hard for me to explain the simplest method have a look here http://www.mirvadim.com/. This is rayfire. Basically it uses a fractal on a polygon, multiplys and random places it withing a volume( this is the cutter ) this is the cutter, the result are realistic fracture pieces that are made children of dynamics systems Maby you can make something like this for Cinema, after 10 years they still have not done this is it that hard? RayfireTool explains the process, it seems simple enough.
By Jay on Jan 25, 2010
Hi Jay,
I am not sure if other CG suites bring a “decent” solution to this with them, but I do know that there is a marked for 3rd party plugins dealing with dynamic destruction and fragmentation of objects.
The common approach to fragmentation is to cut polys based on a voronoi diagram.
So it´s not that hard – the difficult part is to make it performant.
As for C4D, there is a plugin called “Lehman” in the making, that generates voronoi fragments.
Since Cinema4D R11.5, Mograph2 implements the Bullet engine – so the ridgid body physics involved in blasting an object should be easy to simulate.
By flashgordon on Jan 25, 2010
Hi, I was wondering if there’s a way to incorporate PY4D Boids into a project I’m doing. I need to control several simple planes in a similar way.
I realise the Py4D is in Beta and that Boids is not currently a commercial product, but at the same time, my project is for a charity film and I’m willing to take a few risks.
Great job on this, by the way.
Cheers,
Will
By Will MacNeil on Mar 9, 2010
Hi Will,
if the boids are in any way helpful for your project than please go ahead and feel free to use them.
The whole purpose of that script was to take PY4D for a spin and to encourage others to do the same
The scenefile is already prepared to make it easy to attach any object like your planes.
Btw: just watched your real – nice!
Cheers!
By flashgordon on Mar 9, 2010
Thanks Flash!
Is there a way to control the target movement? It seems to be controlled by the script, yes?
Cheers,
W
By Will MacNeil on Mar 9, 2010
Yes exactly,
there is a global vector “target” that represents the virtual target of the swarm.
It gets bounced around randomly within a box – see the method “movetarget”.
You will find it again at the “rule4″ method which makes the boids follow.
I would suggest to comment out the call to “set_target()” at line 69 and to replace the line 137 within “rule4″ like this:
return (op[ID_USERDATA, 1].get_pos() – bpos[c]) / 100
This should allow you to control the boids movement by moving the null “Target”
(it´s linked to the PY4D Tag via the userdata field 1).
By flashgordon on Mar 9, 2010
Beautiful! Thanks. I know very little about coding, so I may come back with some questions.
This project I’m doing is part of a large multi-studio animated film. I can’t tell you much more about it now, but I look forward to sharing it with you later.
Cheers,
W
By Will MacNeil on Mar 9, 2010
Sorry, I’m getting an error message when I copy the text into line 132. The error links to line 42. Just let me know if I’m disturbing you!
W
By Will MacNeil on Mar 9, 2010
Ooops. It’s fine now. The script didn’t like the text I copied in.
Thanks!
W
By Will MacNeil on Mar 9, 2010
By flashgordon on Mar 9, 2010