PyODE physics in PyOgre example

Guess it shouldn’t have taken so long for me to get around to doing this, but at least it’s done now.

Attached to this post you’ll find a zip file, containing a small example application which allows you to spawn PyODE physics-enabled cubes with the middle mouse button into a PyOgre world. You can then bounce and roll the cubes around by holding the left or right mouse buttons.

The code is fairly straight-forward, and I’ve included quite a number of comments. Should be easy enough to follow what’s going on if you’ve been through the PyOgre tutorials.

A note of performance and stability - you can safely spawn loads of cubes as long as there are not too many collisions going on at once (after around 50 cubes, things start to get really sluggish if there are too many inter-cube collisions going on). In practice though, I doubt you’d need that many collisions happening at any one time. Also, If you make a large pile of cubes, lift them all up, and let them fall down together, it seems to bomb out as there are too many collisions happening when they all land on top of eachother at once. I haven’t debugged this very much, so I’m not sure yet if it’s a ODE limitation, or something bad I’m doing in the code. If anyone works it out, I’d be interested to know.

Please don’t ask for advice on stuff like per-polygon collisions, terrain collision and the like, I have not really messed with this beyond the state of this example. Once you get the basics going after checking out the example, I’m sure a few questions shot off at the PyOgre Forums would turn up more useful results than asking me :).

Have fun ;).

Technorati Tags: , , , , ,

Attached Files:

Comments

  1. May 19th, 2006 | 03:43

    Hey there!

    I’m not sure if you posted this example in the pyogre forums, if you have, I wasn’t able to find it. If you haven’t done so yet, I suggest you do it, because it seems to solve some of my “I’m too afraid to ask” newbie questions.

    Anyway, very good example, thanks for letting google index you blog! :D

  2. May 19th, 2006 | 16:31

    I’ve tried signing up on the forum there before, but for some reason I never received my activation emails.

    Guess it’s a good thing though, as I signed up (tried to) for the reason of asking about this stuff. In the end I ended up being *forced* to learn it myself, which, despite the frustration involved, I prefer anyway ;).

    I’ll give registering a shot again…

    Thanks for the comment :)

  3. Dave
    August 22nd, 2006 | 04:52

    Cool example, was very helpful.

    One really simple way to allow more collisions is to use quickStep instead of the normal ode step. It’s not as accurate (and you can see a difference right from the start), but it uses an iterative solution and avoids building up a recursive stack. Changing that one line allowed me to increase the pile of boxes from ~50 to ~300.

  4. August 29th, 2006 | 16:41

    Wow, nice :). Thanks for the tip and comment!

Leave a reply