ODE Middleware


I’m getting this error when I run it:

ODE INTERNAL ERROR 1: assertion "Stride >= (int)sizeof(dContactGeom)" failed in dCollideBTL() [collision_trimesh_box.cpp]

I’m guessing you passed wrong arguments to OdeUtil.collide ?
This is a debug build of ODE, which probably explains why I’m getting the error and why you aren’t.


Thanks everyone for your interest and replies. I really appreciate it.


I guess I could. What exactly do you mean by “more tutorial friendly”? Except for making the map look less provisional. It’s the first time I put out a piece of code like that, so I’d really be thankful for more directions on this.


Crouch makes you fly? That’s strange… I’ve run the code here again, checked it and I see there is something wrong with crouching, but I don’t fly… You’re supposed to “fly” only when inside the ladder trigger. Can you tell me a little more about what exactly happens? Do you just take of and go up (up and away) higher and higher when control is pressed? Do I understand correct?


Yeah, that didn’t happen to me… I have the standard Panda 1.6.2 built from the Ubuntu package. I’d be very thankful though if you gave me a little direction on how to eliminate this problem - it’d be hard for me alone since I simply don’t get this error. Thanks very much in advance.


Yeah, when control is pressed you just continue moving at a constant velocity straight up, and upon releasing fall back down due to gravity–although it would appear that the camera moves down first for an instant (almost like one would expect when crouch is pressed). Simply tapping control gives a weird down up down bunny hop like thing.


This is really weird… and I cannot reproduce it :/. Crouching works as it should for me here (except that walking up stairs doesn’t work when crouching ATM). It also does for a friend I just asked to check it. Very strange…


Ok, time for a little update.

There’s a new map (still placeholders, but more obvious, the way I personally like them, dunno if you will too :wink: ).

Some bugs are fixed such as the player being unable to walk up steps when crouching. Also, now the KCC will correctly react to multiple collision contact points with the same object. I have also added a… chair. So you can sit and relax a little bit (I love Panda’s sequences, intervals and so on). I’m sure some more things were fixed but I can’t remember now… And I still haven’t been able to reproduce the “crouching-flying” error, so I’m very curious if it will happen again with this version.

There’s also more comments in the code files.

I guess that’s all.

The package is under the same link: dl.dropbox.com/u/196274/ODE_Cust … ork.tar.gz




Yea, I’ll look at the code, but I’m getting that couch error too. When you press it, you just go “fly” into the air as you hold the key down. I’m using a windows OS, so that may have to do with the problem maybe? Again, I’ll see what I can do.

Edit. Ok Not 100% sure, but you put 1.2 for self.crouchLevitation, so I changed it to .2 and then it seem to go down as normal, but when you hold on to it to long you’ll go thow the floor or the wall. This means it’s not locking after you press the key. I mean, it’s still going in the loops to go down. Maybe its gravity + couch, it says I hit the floor with a -5.


Hmm… I actually haven’t tested that on Windows, nor has anyone of my friends I sent it to, only on Linux. It would be very strange though if that was an OS-related problem, but who knows. I will have to test it there.

Adr, have you tried the new version? Is the bug still there? I haven’t made much of changes to the crouching code, but again, who knows.


Hmm… That gives me a clue on what’s wrong. The crouch levitation has to be a high value (though it does look like it’s too high at the first glance, but it’s not) because otherwise you won’t be able to climb stairs. Once I figure out what the flying deal is of course. Anyway, my guess is that instead of setting the levitation value it increases it in every step. That might be the case. I’ll dig into that, but first I must get into Windows and see if I get that glitch as well.


Yea thats with the new version. If you change that value, nothing else seems to get effected other then couch. It’s adding to the point where you skip a frame and go though something. Maybe you have something backwords? Like a If else statament. I’ll see what happens if I make it a -1.2

Edit. K, yea making it -1.2 works, but you still go thow a wall or the floor if you hold it to long. So something keeps adding to the value and you have something flip around inside.

It could be that windows keeps sending the ctrl command while that os only sends it onces?


Ok, checked it on Windows and fixed it. At least apparently, need confirmation. It seems like the problem was in fact OS-specific, in a way, but I think it’s more probable it was some difference between the Linux and Windows Panda built that was causing the glitch. I just don’t see how the system by itself could’ve caused it.

Anyway, the thing was that when crouching there was a collision between the footRay and the capsuleGeom. As a result the KCC thought you’re lower than levitation, and pushed you upwards. Hence the “we have lift-off to the International Space Station” thing. I’ve added an if to the ray collision callback to check if we’re not colliding with the capsule. I could’ve done that using masks, but that was quicker.

I’ve updated the package and it should work now.


Other then you can’t open the door while crouch and maybe naming the file testMapODE.py to just Main.py, it works great! I’m going to study it for my own game :slight_smile: My collision and gravity sucks butt, but with your example I’ll get it working and I hope even faster then it has been.


Ok, another update than, into version 0.2.2.

Fixed the problem with not being able to use objects when crouching (or more precisely when holding control). And changed the name of the starter file to main.py :wink:.

dl.dropbox.com/u/196274/ODE_Cust … ork.tar.gz


finally found some time to test this.

it looks and feel great!
thank you very much for sharing

i hope this will become an official sample one day


Excellent! works great, and well commented.


Thanks for your opinions guys, I really appreciate them. Please tell me if there’s anything you’d like to see added there, not to mention if you find any bugs of course.

I have nothing against this code ending up as an official sample, I’m really all for that obviously :wink:. I just don’t know what I should do to get it there ATM, but it would be great.

Thanks again and enjoy.


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