ODE Middleware


I really like your work!

particularly, the way you implemented the world manager is very interesting!

Thank you very much for your work.

On a side note, I am trying to learn how to add new objects with physics, using your world manager…

I want to add a box (just the default panda3d box mesh provided with the SDK) and have it roll and react to the character, you get my point, some standard physics.

I am pretty sure I would use Dynamic instead of Kinematic, correct?

Here’s what I’ve done:
used self.worldManager.setGeomData(boxGeom, boxData)

and this works well, I can jump and hit into the box (I’ve placed it in the air)

However, it’s static. No matter what I’ve tried it refuses to fall due to gravity, or to react when I jump and hit into it.

How do I do this? I thought it’d be simple, but I suppose I’m missing something obvious :stuck_out_tongue:


I’m glad you like it :slight_smile:.

Yeah, perhaps I should have made an example of that in the package… Don’t know why I haven’t, so maybe I’ll update it with some boxes.

Anyway, yes, the box, or any other object that you want to be animated by ODE rather than by hand, should be Dynamic. But that’s the default setting when you look at setGeomData method.

It’s actually quite simple to do. You haven’t provided much information (a complete piece of code where you setup stuff would be very helpful next time), but I think I can see what’s wrong.

Instead of setGeomData(boxGeom, boxData) you should have used this:

self.worldManager.setGeomData(boxGeom, boxData, boxModel)

If you take a look into the odeWorldManager code you’ll see that this method takes 4 arguments: geom, data, object, kinematic. Geom is the OdeGeom, data is OdeGeomData and object is the visible 3D model. Kinematic is obviously a switch between kinematic and dynamic.

If you don’t add a value for the “object” argument the code will not crash however, since that’s the way you can add Static objects which are not animated in any way – neither by you nor by ODE. Objects such as walls (you can see setGeomData with None as object argument in main.py when I setup the static environment). In such objects the positions of graphical representation and collision body don’t need to be updated every frame since they do not change. But you need to remember about this, since if you forget the “object” argument you will end up with static objects by accident and no error to warn you (if you want such error you can modify the setGeomData() method to request the object argument and remember to set is to None for Statics).

Try this and let me know if it works.


Hi, and thank you for such a detailed reply!
Sorry about forgetting to post a snippet, I was tired… annd… well yes :smiley:

I tired as you suggested however still no go, so here is my cube.py file, and I just plugged it into main.py (included with your example) by the following code:

box = loader.loadModel("box")  #load model
box.reparentTo(render)         #reparent to render
box.setPos(0, -7, 3)           #set pos because I changed map
cube(self.worldManager, box)   #make a cube (see cube.py)

that’s how its being called. and for the class:

class cube():
	def __init__(self, worldManager, model):
		self.worldManager = worldManager
		self.cubeNP = model

		self.cubemesh = OdeTriMeshData(self.cubeNP, True)	
		self.cubeGeom = OdeTriMeshGeom(self.worldManager.space, self.cubemesh)
		#self.cubeGeom = OdeBoxGeom(self.worldManager.space, 1, 1, 1)

		self.cubeData = odeGeomData()
		self.cubeData.name = "cube"

		self.worldManager.setGeomData(self.cubeGeom, self.cubeData, self.cubeNP)

I’m still lookin’ to see where I’ve went wrong… :wink:


EDIT: fixed cube class (I forgot to change it back to TRI mesh)


Seems to me like you didn’t set an OdeBody for that cube. Remember that my code is one thing, but you need to create an OdeBody with OdeMass to have an actual Dynamic object. You do that exactly the same way as described in the Panda Manual. The OdeWorldManager only makes the rest of the process automatic (updating positions of 3d models and stuff), but creation of an OdeBody is your job.


I’ve just started using p3d so I search through forum looking for examples to study.

Just tried your code - seems cool for me since it could be a good base for making a game!

I’ve experienced some problems:

  • while walking on the roof player sometime’s shifts forward for some distance.
  • when lamp is switched off, FPS meter shows ~120, when I switch a lamp on - framerate drops to ~58-60.
  • player walk’s through the desk sometimes
    I’ve used panda 1.7.0 and directx9 windowed rendering

Other stuff works fine, I think, and I’d like to thank you for the code.



~I could be wrong about this, but I think it’s correct~

the reason you see a drop from ~120 FPS to the mid 50s is because lighting requires shaders, which will cut the FPS down to about 50 on most graphics cards, but note that you can probably do infinite lighting without losing the 50 FPS you did before, also your graphics card (if any) may likely have little to no shader support, which may also cause the problem


I think I’ll try to add more light sources to test…btw, should there be shadows in this sample?

About videocard - it’s an old device(2006), but it understands shader model 1…I think=)…at least it has Hardware T&L support…


This is probably caused by the room’s trimesh. ODE is quite sensitive in this regard, so the models for trimeshing must be very nice and clean, otherwise you get strange results sometimes. I will update the map asap with a better version.

That’s related to lighting and shaders. When you look into the main.py file you’ll see that there’s render.setShaderAuto(). If you disable that you’ll get much better performance at the price of much worse looking flashlight effect. There might be a way to deal with that to some extend (you will always get a frame drop), but I haven’t looked into that yet.
On faster graphic cards it obviously shouldn’t be an issue.

Oh… That’s interesting. Can you provide more details in what situations this happens? It might be, again, related to trimesh – with ODE it’s much better to use in-engine shapes. I used the trimesh extensively in this sample only because I needed a working environment quickly up and running for codding.

No, this is not supposed to look pretty :wink:. There aren’t even static shadows there.


About walking through desk:
It happens accidentally… but I’d like to note 2 cases(when it happens more, I think):

-when player stands up from chair
-when player approaches desk at an angle(I mean at an angle to desk’s bounding box’s sides or something)

I’m sorry but I don’t have my explanation of that :frowning:


That’s actually just an animation. If you look into the code for standing up you’ll see, that it’s just the way camera is moved around with simple Panda intervals set on it. You can tune that as much as you want. The actual ode character controller doesn’t take part in this, it’s just an animation.

Seems like I just forgot to make a collider for it ;D. No idea how I missed that… Anyway, I updated it and should be fine now. Hit me back on the result.



first of all this is a great script, thank you very much.

I have got a problem adding a Cube:

this is my code

Create a box

box = loader.loadModel("box")

boxBody = OdeBody(self.worldManager.world)
M = OdeMass()
M.setBox(50000, 1, 1, 1)
# Create a BoxGeom
boxMesh = OdeTriMeshData(box, True)    
boxGeom = OdeTriMeshGeom(self.worldManager.space, boxMesh)	
boxData.name = "box"
boxData.isTrigger = False
boxData.surfaceFriction = 0.0

self.worldManager.setGeomData(boxGeom, boxData, box)

So there is a cobe added and it is controlled by gravity but, as it hits the ground the box goes crazy and slips on the ground, rotates and is becoming faster and faster till it slips away…

What did I do wrong =/

I also tryed a OdeBoxGeom but that isn’t effected by anything… it just shakes a bit.

Thanks in advance,


My first thought would be that’s because you set the surfaceFriction to zero. Try changing it to a higher value and tell me if it helps.


I’ve tried with friction = 10 / 100 / 1000 and all the same… =(


Ok, here’s a working version:

Create a box 

box = loader.loadModel("box") 
#box.flattenLight() -- don't use.
boxBody = OdeBody(self.worldManager.world) 
M = OdeMass()
M.setBoxTotal(5.0, 1.0, 1.0, 1.0)

# Create a BoxGeom 
boxGeom = OdeBoxGeom(self.worldManager.space, Vec3(1.0, 1.0, 1.0))

boxData = odeGeomData()
boxData.name = "box"
boxData.isTrigger = False
boxData.surfaceFriction = 0.1

self.worldManager.setGeomData(boxGeom, boxData, box)

And a little bit of explanation.

I use setBoxTotal because it feels better for me, but I’ve tried setBox and it should work as well (with correct values).

Don’t use flattenLight. I don’t know why, and I don’t know if it’s the fault of my code of whatever else, but it seems to produce completely unstable results.

Also, for dynamic stuff try to use meshes that have centers in the middle. The “box” mesh that comes with Panda (with that colorful texture) doesn’t, so to see the difference you can use this: dl.dropbox.com/u/196274/companion_cube.egg

And try to use built in shapes for dynamic stuff. In some cases it might not make any difference, but trimesh is not the best (not the most stable) choice here.

Check it and inform me of the result.


Ok, thank you very much it does not have any crazy behaviour anymore, but the cube still slips on the ground, is that intented to be so?

Thanks in advance


You mean that it slides like on an ice rink? That’s a matter of friction set.

I just noticed that this version only takes the ground’s friction into consideration. I’m not sure why ATM (since both are added to the contact), so for now just set your ground’s friction to a higher value while I investigate on the problem.

FIY, I’m planning a major update to this code. The new version will make it easier to add stuff and bring some other nice features. But there’s still some things I need to cross off my to-do list before I can extract the updated framework from the rest of my code and upload it. So just stay tuned.

Also, remember that this is still a work in progress, so keep informing me of any glitches you happen to find.

Thanx for your interest in this code, have fun with it.



Ok, I’ll have a look =)

I’m now rewriting my whole game and wanted to have another collisionsystem and physics. I found this and I think it is realy realy good and useful =)

You’ll find your code in my game, if I am allowed to use it =)



I’m really glad to read that. I hope you won’t be disappointed with it :).

Everyone is, of course ;). Commercial and non-commercial. The licence, as you probably noticed, is the exact same one as for Panda itself.

Also, I’d love to know what kind of game you’re making. It’d be nice to know what this code is used for :).

Have fun with the code,



It’ll be a multiplayer online FPS game.

here some screenshots: filip.hasecke.com/stuff/game-images

The screenshots are all wip (not ingame) images of the models ^^

Do you have an approximate date of the update of your code =) ?



The models look really, really good. I especially like the trees, but the rest looks great too.

As for the release date for the new version, I can’t give you anything exact, but I want to make it in a week or two from now.