Posts Tagged ‘python bindings’

h1

the python modules are available

October 17, 2008

At long last, I have something for you to get!  These Python modules are compiled against Rat Physics rev. 286.  In the Windows package, you will find three directories, each labeled win32-2.x.  Replace the ‘x’ with your version of Python, go to that directory, and run wrapper_test.py.

If a Python error says that the module is linked to the wrong version of Python, which is unlikely, simply change the version in the makefile.  The makefile is like 5 lines long, I doubt you’ll have problems with it.  Please note that you MUST have SWIG installed to rebuild the module.

The GNU/Linux version is the same deal, except there are no version options, it is just compiled with the latest version.  You can modify the makefile to suit your version if you don’t have Python 2.5.

Here are the downloads:

GNU/Linux Rat Physics rev. 286 bound against Python 2.5
Win32 Rat Physics rev. 286 bound against Python 2.4, 2.5, and 2.6

h1

omg, A PHYSICS UPDATE

October 16, 2008

So, I’ve been hard at work, and here’s what I’ve done.  First off, on campus, Dr. Liow REALLY wanted me to do a python project.  Why?  Because in some strange way it made me a freeloader to hang around in a club where the point was messing with python without actually doing Python.  I was really just there to talk to other people, mostly students there.  So, what I did to make him happy, was Python bindings for my physics engine and  a small demo.  YAY!  Here are some shots of knocking over a tower.  Remember, running in Python, but using my physics engine, which as you probably know is in C.  Check this shit:

oh, yeah, it's a tower.

oh, yeah, it's a tower

let's get ready to rumble, bitches!

let's get ready to rumble, bitches!

steady now...

steady now...

we're down, son!

we're down, son!

It wasn’t that hard.  I used SWIG based on the apparently valid opinions on it from this guy and this guy.  I was really pleased with the results! 🙂  The one thing I had trouble coming to terms with though, was callbacks.  I have world_something_callback(rat_world *world,whateverargs) calls, and setting up a callback system was hard  and ultimately something I failed at.  Here’s why:

I have a function used to set the callback: rat_world_set_body_left_world_callback(rat_world *world,body_left_world_callback *cb).   What I wanted to do was pass a C function that could call a python callable object and convert the arguments properly.  The store the PyObject somewhere I could get back to it.  All went according to plan, until I tried to set up the arguments.  I found I simply didn’t know how I could convert the C (rat_world *) pointer in to the PyObject rat_world class set up by SWIG.  No matter how I diced it, I just couldn’t find a way to pull the whole thing together.  I messed with the idea of SWIG_NewPointerObj, but even with that external runtime header, I could access the type information, because it only defined functions.  Still, the rest of it looks fine.  I’ll be in touch.  And on the C front, I’ve fixed all that sloppy inlining and some really major memory problems with constraints.  So, back to work.

Bye. :3