[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] The introduction of my Google Summer Code Project



Hey,

We are a team also working on 2d physics for python, and I thought I
could maybe post a useful comment :) Congratulations for your GSoC
project btw!!

First of all, I think it's extremely ambitious to write an own physics
engine, especially considering the quality of Box2d and Chipmunk. They
are stable, quick and fully featured -- especially Box2D being grown up
since a while and actively developed and driven by a large community. I
think it will take a few man-years to get to that point in terms of
stability, speed and functionality, although maybe not all functions are
required.

There are Python ports for both, Box2D and Chipmunk. One is "pyMunk"
which is a CTypes Interface to the Chipmunk physics engine
(http://code.google.com/p/pymunk/).

The other project is called "Elements". It's on the one side a python
port of Box2D with a SWIG Interface, on the other side an API for easy
usage of Box2D (even for kids), and a lot of examples and demos. We
spent a lot of time on the SWIG Interface and on speed optimisations, as
we also run it successfully on the XO Laptop. We also ported the (as of
yesterday) current Box2D testbed demos to python and pygame as well as
opengl. I hope you can find a few inspirations from our code:

"svn co http://svn2.assembla.com/svn/elements";. Absolutely use "python
-O ..." -- it improves the performance a lot with these demos (up to
100% with opengl).

I also worked with Chipmunk and did speed tests with both engines
(http://wiki.laptop.org/go/Physic_Engines/Speed_Tests). Box2D (C++) is a
lot faster with Python (SWIG Interface), compared to Chipmunk (C) with
CTypes Bindings.

Another thing: Current 2d physic engines have problems with concave
polygons ([1], [2]). We detect and support both, with breaking a concave
poly up in rectangles. (Not very efficcient, but it's very hard to find
open tessellation algorightms; many developers seem to use the OpenGL
Tessellater ([2]), but it has a strange half-free license [3]).

Also the "Elements" project supports drawing with pygame, opengl and
cairo, and we have compiled box2d libraries with python swig interface
for windows, linux 32 and 64 bit (+ instructions for the other
platforms). You can just copy them and start playing around! :)

Best,
- Chris

[1] http://www.box2d.org/forum/viewtopic.php?f=4&t=83
[2] http://www.box2d.org/forum/viewtopic.php?f=3&t=719
[3] http://www.box2d.org/forum/viewtopic.php?f=3&t=719&p=4200#p4223

--
 \___/    Chris Hager
 |___|    GSoC '08 Mentor for OLPC -- http://wiki.laptop.org
  \___\   Elements Developer -- http://elements.linuxuser.at