Animation Phyisics Script

Hello. I was wondering if a script exists, that applys physics to specified objects, useful for animation? If not, it seems not too terribly difficult to write a heuristic evaluation script, set for OnFrameChange, noting position, velocity, and mass for specified objects. Since you cant render animations using the game engine, this seems like it would be the next best thing.

I just downloaded the python ode module to see if I could do something like what you describe. I haven’t even compiled it though so don’t get your hopes up yet. It shouldn’t be too difficult to get some bouncing spheres though. If you or somebody else wanted to play around with the ode module this is the url:

Has some tutorials and stuff too…


ok, this is what i needed. now, to get it to interface with blender. anyone?

more reasearch. afaik, ode has to be integrated, and there isnt a simple interface script. Its apparently integrated into Tuhopuu.

here is a build of tuhopuu with ode

but i cannot figure(if its possible) to use the hinges, etc from ode AND how can i use ode at rendertime (ie, convert motion to ipo curves)?

The ODE in tuhopuu AFAIK is only for the game engine. It cannot currently be used to generate animations.

I was going to use Object.getSelected() to collect objects, then run a simulation and add keys to the objects loc and rot ipos. Just to test out/get used to ODE. Using joints would require more code/ some kind of interface except for the simplest proof of concept sort of things. Integrated ODE would be a much nicer solution to phisics simulation. Maybe with a special edit-mode for physics setup or joint based constraints…

On a side note the ODE tests are very fun, I especially like the test_crash demo…

A test (rather old now) with normal python API and pyODE:

If i understand correctly you want the newly fixed ‘game2ipo’ script. it’s about three pages back.

A test (rather old now) with normal python API and pyODE:

well, not exactly. id like to use ode purely as a way to generate animations, w/o the gameengine go-between.

also, with that test .blend, i get an “dynamic module does not define init function”

Thanks for the blend Jms! your always there with the cool scripts :smiley:

I got it to run without much trouble. It was just using some depreciated methods, and for some reason it was trying to set the frame to zero at one point so I made it check that the frame it was setting was > 0.

here is the “updated” blend:

It shouldn’t be too difficult to write some ipos from this though.

trogdor wrote:
also, with that test .blend, i get an “dynamic module does not define init function”

Where did you get your pyODE? Did you compile a fresh ODE or did you nick one from the blender distro? I’m using ODE 0.5 on linux with the latest pyODE and all is well…

im using the ode-bin-0.5-msvc-dll-DOUBLE-release-notrimesh ODE and the latest pyODE, with the latest builld of tuhopuu with ODE afaik, see link below; although now, with your updated blend, i get an error on line 10, AttributeError: getRenderingContext

unfortunately the pyode python bindings for ode doesn’t support trimesh, so it’s not that efficient, nor inetresting, A real python bindings to blender physics system would be much better, so I wonder if anybody knows of a project to do so.

Hmmm, well you don’t need tuhopuu, the ode in tuhopuu is just for the game engine. i would guess the error you get is because the tuhopuu you have doesn’t have some of the new API modules like Scene.Render.

Here is the simplest script that will do something with ode:

import Blender
import ode

box = Blender.Object.getSelected()[0]

Create world

world = ode.World()

Add a body to the world

body = ode.Body(world)
M = ode.Mass()


Do the simulation

tot_time =0.0
time_delta = .02
while tot_time < 2.0:
box.LocX,box.LocY,box.LocZ = body.getPosition()
tot_time += time_delta


It assumes that the first item you have selected is a cube, but any object should work. Put this into the text window any way you want/can, in a 3d window pick some object, move the mouse into the text window and hit alt-p…

unfortunately the pyode python bindings for ode doesn’t support trimesh, so it’s not that efficient, nor inetresting,

While its true direct access to Blender internal physics would be best, but I wouldn’t throw pyode away just yet. Firstly ODE isn’t a collision system, the collision detection in ODE is just for conveniance. ODE is a library for modelling masses in motion. Its ineffecency at collision detection is a given, that is why Blender uses SOLID/Ketsji for collision detection. Besides the best reason to use pyode currently is that there isn’t any other tool availible to animate physics simulations in Blender. The game engine is seperate and (mostly) in-accessable and probably will be until it becomes more stable/complete (guess).

Have you seen this?

I don’t think it has been updated in a long time, but it may be a start :slight_smile:


how do you make ode work with b233?

I have an older prebuilt .dll for b232 that works fine with said 232, but refuses to work with b233.

In the meantime I downloaded both pyode and the ode from sourceforge - what exactly do I have to do to enable them/make work in blender233?

can someone of the enlightened please just write steps in form do a), do b) …?

i ran this…no apparent effect…