Python Bullet without using Blender

luke.titley
Posts: 15
Joined: Fri Sep 08, 2006 3:39 pm

Python Bullet without using Blender

Post by luke.titley »

Is there a python binding for Bullet which does not involve using blender?
I've done a little search around the forum and a searched on google, but to no avail.
Just checking before I start wrapping it myself.

Thanks

Luke
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Hi,

It would be very useful if someone can help adding a Python binding for Bullet. There isn't any binding, outside of Blender at the moment.

Do you already have experience with PyODE? Perhaps you can re-use/benefit from that project. I haven't looked into this yet.

One of the plans is to create a C-API. There is a draft starting point in Bullet/include as a headerfile. Wouldn't it be easier to wrap a C-API, instead of C++?

Is PyODE an autogenerated wrapper or manual created?

Thanks,
Erwin
luke.titley
Posts: 15
Joined: Fri Sep 08, 2006 3:39 pm

Post by luke.titley »

I had no part in creating pyODE and I know nothing about how pyODE was made.

I use it a lot however and was considering creating something with a similar API.
At the moment I am in my final year of a 3 year undergradutate degree so I don't have time to commit to maintaining an "offical" python wrapper for Bullet. But I would like to use Bullet in the project I am currently working on and so I need to be able to use the features I currently use in pyODE.

I will investigate the quickest and easiest method for me to do this.

Thanks
Luke
aera
Posts: 2
Joined: Mon Mar 12, 2007 10:57 pm

Post by aera »

I'm also on the hunt for a way to get a nice direct Python binding, and it does seem that there's a gap in this area...

PyODE was written in Pyrex, a python-like language for writing C-based python bindings/extensions. It has limited C++ support, while its C support is great.

I'm currently poking it around and seeing if I can get it to bind anything from Bullet at all - the lack of documentation for C++ and Pyrex is pretty bad, however. I want 'PyBullet' enough that I'm willing to try this, at least...

I'm not sure how much a C API would help; it would make writing a Pyrex extension easier, but then again there are plenty of other ways. SWIG is another option, which I seem to recall playing some part in CrystalSpace's bindings when I looked at them (among other things), but it's not as nice as Pyrex.

I'll report back with whatever I manage to scrape through with, if anything.
aera
Posts: 2
Joined: Mon Mar 12, 2007 10:57 pm

Post by aera »

Well, it seems that Pyrex isn't very nice with C++ yet at all; it was a pain even wrapping something relatively simple like btVector3. However, SWIG's C++ documentation is much better, and so I'm giving that a try; it seems to be a nicer solution on the whole.

I've got as far as a very simple wrap of btVector3, and correct type conversion from python floats to btScalars and back. Hopefully I can get something a little more complex working soon.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

I think I need to put the C-API on a higher priority. That would be better then wrapping C++ I think.

In the meanwhile, if you got spare time to try out SWIGG, that would be interesting too. Still a C-API Pyrex sounds more the way to go.

Thanks for the feedback,
Erwin
Game_Ender
Posts: 2
Joined: Mon Apr 23, 2007 4:45 pm

Post by Game_Ender »

If you don't to throw away the class structure you create and maintain to make the C wrapper only to have to recreate it with pyrex, I would check out Py++ and Boost.Python. They are essentially a better SWIG for python.

The Python-Ogre project (of which I am a developer) has wrapped Ogre, OgreNewt, OgreODE, CEGUI, and OIS with this combination. Current downsides: Large compile times for wrappers and large binary sizes with GCC. I would not be surprised if an OgreBullet wrapper appeared in the next several months.
didu
Posts: 1
Joined: Wed May 16, 2007 3:08 pm

Post by didu »

hi folks,

I'm starting to write a python wrapper for bullet 2.5 using boost.python and scons. I find that the c++ code of bullet is not always compatible with boost.python, and I have to add some additional code to bullet's source code to get things working. On top of the additional code, the python wrapper essentially consists of two additional files:

SConstruct -- the build file that compiles a shared object that python can interface with

interface.cpp -- the boost.python interface code that exposes the boost c++ classes and functions to python.

Since I'm doing this as a side interest, I'd be more than happy to share my code so that those interested can work on it as well. The scons build file and the interface file are extremly easy to understand and use. The build file should already be in its final version, and shouldn't require any changes. The only thing that requires manual labor is the interface file, I've already done btMatrix3x3 and btGeometryUtil, If you are interested in helping out, you can download what I've done from the following url:

http://www.csse.unimelb.edu.au/~jingy/d ... Src.tar.gz

I'm also hoping that once the python wrapper becomes functional, the authors of bullet would incorporate it into the official bullet release and provide incremental maintainance.

Anyway, thanks for reading.

-D
luke.titley
Posts: 15
Joined: Fri Sep 08, 2006 3:39 pm

Post by luke.titley »

Hi dido,

Are you using py++ ?
You should be able to autimate a good part of the wrapping process.

I was able to access all I needed
rigid body primitives
hinge + generic6dof constraints

using swig, which was about two days work.