8
$\begingroup$

Blender has physics options which we can enable for our objects - cloth , fluid etc. Is there a way I can add a custom physical behavior to my objects, where this behavior is modeled as a python script. For example, I'd like to add a new button to the physics tab like "My Physics", and when it is attached as a modifier to objects , the objects follow the behavior as modeled in the script.

Basically, I want to test some physics algorithms and want to use blender for that. So I'd be relying on blender to do the rendering and other things, but the physics will be provided by my code.

Is something like this possible?

$\endgroup$
  • $\begingroup$ Use blender game engine. In the logic bricks, you select "always" with positive pulse, the "and" goes in the center, then add "python". In there you can manipulate objects positions etc via your own python scripts. $\endgroup$ – beiller Dec 15 '14 at 21:30
9
$\begingroup$

Yes it is possible, there are 2 ways of doing this, but there are also 2 big drawbacks for both methods:

  • method 1: You can script your own modifier in c++, here is how to start. The drawback is you need to build your own Blender version yourself. Modifiers cannot be add with python or addons. If your modifier gets approved it can be added in the trunk (official release).

  • method 2: You can add your physics simulation code in the app handlers. This way your code gets executed for example every frame change. You can manipulate objects, change mesh etc. This will work from addon but the code will be very slow and you will unlikely get real-time fps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.