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

Advertisements

2 comments

  1. Glad to see you got over your recent depression funk… Well, the reason I think SWIG kicked ass is because I used it, at a lab where I use to work at. It’s just something that I was used to, and it worked for me.

    Anyway, the screenies kicks ass. That 2D physics things is so cool. It’s not easy to write a physics engine. I’ve never done it myself. I like the way you are doing it yourself though. You will really understand how it works, and the stuff you may do in the future will be a breeze. As for myself, I’m just too lazy to roll my own, so I use ODE or Bullet.


  2. looks really cool. i haven’t even added any physics yet to mine(well not real physics). I’d probably end up using bullet too.

    Oh check out phun (it realy is) http://www.phunland.com



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: