A Python wrapper for PhysX 2.8.1

What is this?

This is a distribution of a wrapper for the PhysX game physics API by NVIDIA.
It is designed for version 2.8.1 of the SDK, and will build and load with the
May 2008 PhysX runtime. Note that the September/October 2008 PhysX runtime
that is CUDA accelerated will NOT run on most machines (this is a "feature"
of that runtime, not just of this wrapper). This is Windows only, but chances
are good that you could get it to build on Linux with the NVIDIA PhysX SDK
for Linux.

The distribution is built using SWIG, and as such requires some machinations
to use properly. For example, the physx module has a global SDK instance,
which is called "physx.cvar.sdk" -- the "cvar" is a wrapper for a C global.

Rather than give the modules proper names (physx.physics, etc), I had to
give them underscore names, because of what appears to be a limitation in
SWIG. Or I just don't know how to use it right. In releases after 2008-10-08,
docstring support is included (yay!).

Now, what's cool about this distribution? First of all, it is totally non-
intrusive. You can build this without changing any NVIDIA headers at all! This
is quite important, because the NVIDIA sources have a EULA that you can't use
for redistribution. It's also useful, because it should be easy to keep it up
to date for newer versions of the PhysX SDK.

Second, it's quick to maintain. Literally, I've never used SWIG before in my
life, and this wrapper took about 6 hours to put together one late October
evening, with some additional improvements over the next few days.
This is a feature, because I don't mind releasing the hack into the public
domain. That's right! The code, and the Windows binaries, are all released
into the public domain by the author, me! (I don't know if Microsoft wants to
keep the rights to whatever loader code is embedded in the DLLs, and I don't
know what license the generated SWIG code is under, but the stuff I wrote is
totally free for any use. Have fun!)

Third, there are a few simple helper functions included. These mostly have to
do with converting to/from tuples/sequences for the NxVec3, NxQuat, NxMat33
and NxMat34 classes, supporting float array as a type (see newFloatArray())
without using ctypes, and finally supporting all flavors of ShapeDesc, even
when the SWIG argument resolver seems to not understand up-casts (see
NxActorDesc.addShapeDesc())

There is a small test program which uses Panda3D to render two cubes falling
onto a plane and rolling off each other. It proves that this approach at
least works and is usable, although I'd have to see something bigger built
before I'd consider the system release quality. To run it, make sure that the
Panda3D python is first in your path, and run:

python pandatest.py

You should see a gray window with two cubes on the right hand side, falling
down onto each other.

Finally, if you want to build the integration yourself, you can do so with
Microsoft Visual Studio. Make sure you've executed VCVARS32.BAT so that the
compiler/linker are in the path, then just type "build" to built it using
the included batch file (no makefile, sorry!) Alternatively, you can clean
the directory of temprary files using "clean.bat" or you can build just one
of the wrappers by doing "build foundation," "build physx" or "build physics."
There is also a wrapper for PhysX cooking, but I have no idea whether it
works.

For more information, please see my web site:

http://www.enchantedage.com/python-physx

Jon Watte, October 8 2008

AttachmentSize
physx_swig_20081008.zip586.61 KB