Blender ODE physics script (Beta)

This ODE script will let the average gameengine python scripter to learn how to use ODE api… Bloded is very similar to pyode and has trimesh support. Understanding how this ODE script works will allow you to make your own realtime ODE scripts.

Demo with ODE script

Bloded = ODE library for Blender. I place this file in my Blender directory.

It’s fairly easy to use. I will explain how ode.blend was created. In the center there is an Empty with an always sensor that fires all the time attached to a python controller that calls ODE. This Empty needs to have 2 properties a timer named time, and a float named prevtime. You have to option to have an int named quickStep to specify how many iterations to perform each step (improves percision but slows down game)

Now for all the objects that you want to have ODE collisions, you have to set properties on it. An object will have the property bool dynamic. Dynamic objects will have dynamic = true. Dynamic objects move due to collisions and gravity. Setting dynamic to false will make it static and it will not move. Another property an object is a float bounce … setting it to 1.0 = perfect elastic body (A good value is 0.1).

Also for your object, depending on how you want the collision detection to work for the object, you must specify the shape and additional properties. Note that just because the shape is set to sphere, doesn’t mean that your mesh has to be a sphere, it’s just how collisions are handled. So here are the property setups that you can use…

for a dynamic sphere:
Bool dynamic True
String shape sphere
Int density 5000 (any number from 1 to 10000 will work… maybe higher)
Float size 1.00
Float bounce 0.10

for not dynamic box:
Bool dynamic False
String shape box
Int density 5000 (any number from 1 to 10000 will work… maybe higher)
Float lenx 2.00
Float leny 2.00
Float lenz 2.00
Float bounce 0.10

for dynamic cylinder:
Bool dynamic True
String shape cylinder
Int density 5000 (any number from 1 to 10000 will work… maybe higher)
Float radius 1.00
Float length 1.00
Int direction 3 (1 = x axis, 2 = y axis, 3 = z axis of mass…)
Float bounce 0.10

for cylinder it’s probably best to always model it going up and down along z axis and then rotating it… (who uses cylinders anyways…)

for static complex meshes (requires triangulate your mesh to only use triangles) :
Bool dynamic false
String shape complex
Float bounce 0.10

I only made one joint so far… the balljoint. Create an empty and set the properties:
Bool balljoint True
String body1 nameOfBody1Obj
String body2 nameOfBody2Obj
*notes: the position of the empty is where the anchor of the joint is. If there is no body2 property, the anchor will be fixed to the environment world…

So there’s lots of things left to do:

  1. Add more joints (HingeJoint, SliderJoint, maybe FixedJoint)
  2. Figure out why objects swing forever, where is air resitance?
  3. Add motors option to joints.

Stuff to try:

  1. Create realtime cloth using a network of joints and dynamic spheres.
    need some way of assigning vertex coordinates of a mesh in realtime?

Find LunarKnight in #gameblender if you want to contribute to the script or helpout.

Helpful links

Bloded api

Pyode… see tutorials near bottom

ODE Documentation

2.25 or 2.34?

I tried it on 2.34, and I got this error:

Traceback (most recent call last)
  File "ODE", line 33, in ?
AttributeError: 'Bloded.World' object has no attribute 'quickstep'


I use 2.34
And no… shouldn’t be quickstep should be quickStep. Not sure if that helps, maybe make sure you have latest Bloded too.

:expressionless: I misspelled!

How do I get the latest version of Bloded?

I place this file in my blender.exe directory
Not sure what to do with it in linux. The archives said put it in… %home%/python23/lib/ but my friend tried that and it didn’t work. May have to consult the Bloded thread in the Python Scripts forum section. Or ask ppl in IRC (they seem to use linux a lot …)

I’m on windows.

So, what version of python do I use? 2.3?


This is cool, works Perfect :smiley:

Yay! I got it working! :smiley:

Really nice! Works fine!

Nice , but it only works with python path installed.
How can I make it work without python been installed?


Aah, that’s why is doesn’t run on my pc. I ahev python but not the full pythonpath installed. :-?

It works, but it kinda seems to work strangly. The cube that hits the ground rotates a bit funny, with edges giong into the sides of the ground, and then there’s a sphere swinging off a cube, was that supposed to happen? I tried deleting all the vertices on the ground object and added just a plane (it did have all the properties that were on the original ground thingy that you provided because i didn’t delete the object, just the mesh) and when the objects hit the plane blender crashed.

Cool though,


hey pooba you make good name to your avatar :smiley:

ye it’s cool example but I don’t understan why would use another engine in engine.
Isn’t better way implement this engine instead solid ?
just a conception.


Could I use balljoints to make a ragdoll? (Not that I knew HOW TO do it…)
If it’s possible, then is it possible to make some kindo of constraints to the limbs? (Of course the constraints have to move with the parent limb of the part that’s movement is being constrained.)???

Yeah you could use ball/joints to make ragdoll.
I wouldn’t use this approach though
I think there’s import PhysicsConstraints where you can make constraints using blender’s ODE but it doesn’t work yet.

Why not? is it too heavy on the engine?

for your cloth ideal… make a triangulated devided plane…

for softbodies, I am almost done with the script and will move a vertex of all faces, its done just clenaing up but too tired 2:00am

its vert basic but better then what I had in vertex modifier blend…

I can work on it more but I am not sure what you want to do really

can you post a video?