tag:blogger.com,1999:blog-52174454960198280872024-03-13T09:49:05.678-05:00pybox2d2D Game Physics for Pythonknehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-5217445496019828087.post-43281326220170893522011-06-11T09:16:00.000-05:002011-06-11T09:16:22.861-05:00(Mostly) Pure Python Physics<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-bbMHC0F0xUY/TfN3c2Nve8I/AAAAAAAADG8/X7MCTFwUZLU/s1600/pypybox2d-profile.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="120" src="http://2.bp.blogspot.com/-bbMHC0F0xUY/TfN3c2Nve8I/AAAAAAAADG8/X7MCTFwUZLU/s200/pypybox2d-profile.png" width="200" /></a></div><br />
Continuing my work on the <a href="http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python">Pure Python port</a>, I did a small amount of profiling with the outstanding <a href="http://www.vrplumber.com/programming/runsnakerun/">runsnakerun</a> to determine what was bogging it down. As expected, the slow speed of Python's math operations -- and especially the matrix and vector operations -- were the major bottleneck.<br />
<br />
Having said that, it would appear that there's very little I can do for the <i>Pure</i> Python port to speed it up. If you followed the previous post, you'll know that I tried <a href="http://pypy.org/">PyPy</a> (it works after a large number of iterations) and <a href="http://cython.org/">Cython</a> (faster, but still not so great). I considered using some library like <a href="http://numpy.scipy.org/">NumP</a>y to get its matrix and vector functionality, but including such a massive library just for this tiny physics library just felt wrong.<br />
<br />
I stumbled upon quite a few matrix and vector C extensions for Python, notably <a href="http://eatthedots.blogspot.com/">Casey Duncan</a>'s excellent <a href="https://bitbucket.org/caseman/planar/">Planar</a> project. However, there were always issues with all of the ones I found: not supporting tuples in place of vector and matrix types, immutable vectors (though this can be a good thing for other projects which don't expect it), and just the general headache of requiring restructuring all of the pypybox2d code that already relies on vector and matrix classes with certain properties and functions. [side-note: were it not for this project, I would definitely be using the Planar library.]<br />
<br />
In short, and for better or worse, I re-invented the wheel, creating pure <a href="http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python%2Fpypybox2d%2Fsrc">C extensions</a> for the Vec2, Mat22, Transform, and AABB types (should be compatible with Python 2.5~3.2, but let me know your results). Performance significantly improved (sorry, I don't have any benchmarks right now -- but run any of the testbed tests and you'll feel it). Most of the <a href="http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python%2Ftestbed">testbed</a> tests run "fast enough". Exceptions include the pyramid and vertical stack ones, which have altogether too many contacts, and the solver gets very slow.<br />
<br />
After adding pickling support for the above classes, I then really wanted to give <a href="http://docs.python.org/library/multiprocessing.html">multiprocessing</a> a go. I made a simple test with a set of processes dedicated to doing shape distance calculations (i.e., consumers). I passed in thousands and thousands of shapes and transforms, and it properly generated the results. Unfortunately, comparing it to the single process version, regardless of the number of input sets, the multi-process version was on the order of 10-50x (!) slower -- not even including the time it took to start the processes. All of the overhead, presumably from synchronization and pickling the objects to pass between processes is just too expensive. It looks as if this will not be a viable option for a real-time physics engine.<br />
<br />
Now, where to go from here? I'm stumped -- err, I mean -- I'm open to suggestions!knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com11tag:blogger.com,1999:blog-5217445496019828087.post-70795854884531139452011-05-19T15:50:00.001-05:002011-05-20T11:27:20.669-05:00Pure Python physics?<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-6cDiCrPRgy8/TdWB4uD7SPI/AAAAAAAADGk/e4pBF4fOpos/s1600/pypybox2d-sshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="156" src="http://4.bp.blogspot.com/-6cDiCrPRgy8/TdWB4uD7SPI/AAAAAAAADGk/e4pBF4fOpos/s200/pypybox2d-sshot.png" width="200" /></a></div><br />
Recently I tried to get pybox2d compiled and running with <a href="http://pypy.org/">PyPy</a>, but it failed for whatever reason. I had it in my head to just give up and port the whole bloody thing to pure Python and see how that would go. Not wanting to waste inspiration, I gave that a shot. Fast forwarding to today, and it's pretty much done.<br />
<br />
So, what's in the port? (almost) All features of Box2D up to <a href="http://code.google.com/p/box2d/source/detail?r=175">r175</a>:<br />
<ul><li>All <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/pypybox2d/shapes.py">shape</a> types (polygons, circles, edges, and loops)</li>
<li>All <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/pypybox2d/joints.py">joint</a> types (distance, revolute, friction, prismatic, weld, rope, wheel, mouse, pulley, gear)</li>
<li>A <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/pypybox2d/dynamictree.py">dynamic tree</a> class for AABBs</li>
<li><a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/pypybox2d/collision.py">Collisions</a>, <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/pypybox2d/contact.py">contacts</a>, shape <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/pypybox2d/distance.py">distance </a>calculations, etc.</li>
<li>A mostly Pythonic interface to all of the useful classes</li>
<li>The <a href="http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python%2Ftestbed">testbed</a>, in simplified form</li>
</ul><br />
Before you jump for joy, there are many reasons to not use this:<br />
<br />
<ul><li>It's slow.</li>
<li>It's <i>really</i> slow.</li>
<li>It has a bad name (<a href="http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python">pypybox2d</a> -- changing it is on the <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/todo">TODO</a> list)</li>
<li>It's still early, though almost everything has worked well enough in my tests. I'm positive there are plenty of typos and minor bugs.</li>
<li>Some source files are much too big, because I haven't gotten around to splitting them up</li>
<li>It uses __slots__ for my own debugging purposes. I have no qualms about (almost wholly) removing their usage eventually.</li>
</ul><div>"Why do this, then, if it's so slow and unusable?" Do you <i>really </i>have to ask? Why not?</div><div><br />
</div><div>So, what of PyPy after all that hard work? Unfortunately, in my few tests, it's been slower than CPython **. Perhaps one day it will be sped up by another means. Or maybe I'll figure out a way to get <a href="http://cython.org/">Cython</a> working with it such that it won't totally screw everything up. If you have any ideas, please do get in touch with me.</div><div><br />
</div><div>Find the source <a href="http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python">here</a>. The testbed requires pygame, but there's a (very) simple graphic-less <a href="http://code.google.com/p/pybox2d/source/browse/branches/pure_python/examples/hello.py">hello.py</a> in examples/ if you simply must run something.<br />
<br />
** edit May 20th: But those tests were superficial, only testing for a few iterations. Increase the number of iterations, and PyPy wins, hands-down. See Antonio Cuni's helpful comment below for more information.</div>knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com13tag:blogger.com,1999:blog-5217445496019828087.post-66768446563567910912011-03-13T19:48:00.003-05:002011-04-07T13:36:38.950-05:00Simple examples? oh yeah, and an alpha release for you...So, not everyone likes the testbed. It's big, C++-ish, and not so pretty. And we all hate searching around in multiple files for function definitions.<br />
<br />
Making some simple examples has been on the back-burner since I started on pybox2d a few years back. I've finally started on some examples, but I need your input on how to make them easily digestible for everyone else:<br />
<br />
<div style="text-align: center;"><a href="http://code.google.com/p/pybox2d/source/browse/trunk/examples/simple_01.py">simple_01.py</a></div><div style="text-align: center;"><a href="http://code.google.com/p/pybox2d/source/browse/trunk/examples/simple_01.py"></a><a href="http://code.google.com/p/pybox2d/source/browse/trunk/examples/simple_02.py">simple_02.py</a></div>Is it worth going down this path?<br />
<br />
To hopefully rouse up some interest, <s>I will provide another alpha release</s>. This time, I'll make it available to a larger audience by including builds for the platforms I have access to (sorry, OSX users -- you might not get any installer release for 2.2 at all).<br />
<br />
So, read the <a href="http://code.google.com/p/pybox2d/wiki/GettingStartedManual">manual</a>, download from below, and try it out. Without your help, this version will never see daylight, I assure you!<br />
<br />
<div style="text-align: center;"><br />
<s>win32 2.6, 2.7, 3.0, 3.1</s><br />
<s>linux-i686 2.6, 2.7, 3.1</s><br />
<s><br />
</s><br />
</div>Edit 4/7/2011: OK, so -- not a single comment in a month, and I recently fixed a major leak affecting all versions since 2.0.x, so I just removed those versions from the svn. 2.0.x has also seen its first update in a few years.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com4tag:blogger.com,1999:blog-5217445496019828087.post-26041524908607995562011-02-26T19:46:00.001-06:002011-03-01T20:29:56.833-06:002.1 on the move?<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/jTW9jj-9Y6E?feature=player_embedded' frameborder='0'></iframe></div><div style="text-align: center;"><i>test_Car.py</i></div><div style="text-align: center;"><i><br />
</i></div>Hi,<br />
<br />
So, I've moved the 2.1 branch into the trunk. I've also spent more than half my Saturday fixing and writing documentation.<br />
<br />
Here's the 2.1 manual <a href="http://code.google.com/p/pybox2d/wiki/GettingStartedManual">on the wiki</a>! If you have some time, please read through it. It's a lot of work -- hopefully someone will appreciate it. :)<br />
<br />
I also re-uploaded the 2.0.2 bugs-n-stuff that were on the Box2D wiki, <a href="http://code.google.com/p/pybox2d/w/list">here</a>. A couple of other <a href="http://code.google.com/p/pybox2d/w/list">wiki</a> entries got updated, too. Notice anything strange? Please do let me know.<br />
<br />
There's a few changes upstream that I'll get around to including soon, but I'm a bit burnt out after the above. Nothing huge, though.<br />
<br />
Warm wishes,<br />
<br />
kneknehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com2tag:blogger.com,1999:blog-5217445496019828087.post-9554980326926962772010-12-15T23:54:00.000-06:002010-12-15T23:54:53.338-06:00Found in the wild: Bricks Knock OffI just happened upon a decently polished little game called <a href="http://jasonuniverse.appspot.com/str/pokaz/ag1qYXNvbnVuaXZlcnNlchkLEhFQb2plZHluY3phX3N0cm9uYRihlgMM">Bricks Knock Off</a> (English translation <a href="http://translate.google.com/translate?hl=en&sl=pl&u=http://jasonuniverse.appspot.com/str/pokaz/ag1qYXNvbnVuaXZlcnNlchkLEhFQb2plZHluY3phX3N0cm9uYRihlgMM&ei=3acJTcWGDMGs8AaVm9SfAQ&sa=X&oi=translate&ct=result&resnum=1&ved=0CBkQ7gEwAA&prev=/search%3Fq%3Dhttp://jasonuniverse.appspot.com/str/pokaz/ag1qYXNvbnVuaXZlcnNlchkLEhFQb2plZHluY3phX3N0cm9uYRihlgMM%26hl%3Den%26safe%3Doff%26sa%3DG%26qscrl%3D1%26prmd%3Div">here</a>) that's actually using the 2.1 branch of pybox2d. Cool!<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_8BgF4kTEi5Y/TQmpBVj6hRI/AAAAAAAACsA/0dkhQFSgsBw/s1600/bricks_knock_off.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="261" src="http://4.bp.blogspot.com/_8BgF4kTEi5Y/TQmpBVj6hRI/AAAAAAAACsA/0dkhQFSgsBw/s400/bricks_knock_off.png" width="400" /></a></div><br />
As you might have guessed, it's a game about bricks. Shooting them off some platform to get a decent enough score to continue to the next level. It features music, sound effects, a few levels, and even a scrolling background.<br />
<br />
I only have one comment from the pybox2d-end of things, and it's that the position/velocity iterations need to be tweaked to get the bricks to stack stably. If you check it out, change main.py around line 115ish to be something like:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> vel_iters, pos_iters = 15,15 </span>knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0tag:blogger.com,1999:blog-5217445496019828087.post-70105197577273260132010-11-04T22:49:00.000-05:002010-11-04T22:49:02.137-05:00ProgressYes, there has been some progress. Only a bit though. I know you love it when I make bullet points, so here you go:<br />
<br />
<ul><li>Most importantly, I fixed up a few things thanks to issues pointed out by users. Thanks mikkelin, Fahri, dabski, and anyone else that I might have forgotten!</li>
<li>Updated to the latest Box2D SVN r141 -- there were some changes upstream, including:</li>
<ul><li>A new RopeJoint (maximum distance constraint)</li>
<li>Allocator, joint and some other fixes and improvements</li>
</ul><li>Working b2LoopShapes -- featuring smooth collision both inside and out (you can see these in the <a href="http://code.google.com/p/pybox2d/source/browse/branches/box2d_2.1/examples/test_CharacterCollision.py">character collision test</a>)</li>
<li>Added the <a href="http://code.google.com/p/pybox2d/source/browse/branches/box2d_2.1/examples/test_Rope.py">rope joint test</a></li>
<li>PyQt4 framework fixes</li>
<ul><li>Some properties are changeable now (*)</li>
<li>Fixed updated circle radii between calls</li>
</ul><li><a href="http://pybox2d.googlecode.com/svn/branches/box2d_2.1/doc/epydoc/Box2D.Box2D-module.html">Epydoc</a> documentation for the 2.1 branch was generated by using the Doxygen <a href="http://pybox2d.googlecode.com/svn/branches/box2d_2.1/doc/doxygen/html_output/index.html">documentation</a> for the C++ side (which, although it is included in the SVN, is usually not at all necessary for pybox2d users).</li>
<li>An up-to-date version of the compiled library is included on the SVN</li>
<ul><li>It's <a href="http://pybox2d.googlecode.com/svn/branches/box2d_2.1/library/Box2D/">here</a>. For those of you who would like to help test, is this convenient enough? Or is it "give me an archive or test the damn thing yourself"? :)</li>
</ul></ul>I think it's almost time that the trunk from early last year to be finally overwritten. I don't think there are too many project requirements with the old library anymore. Thoughts?<br />
<div><br />
</div><div><span class="Apple-style-span" style="font-size: x-small;">(*) Any idea how to properly size a QListWidget in a QTreeWidget cell? I think sizing widgets appropriately is what most frustrates me about Qt.</span></div>knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com13tag:blogger.com,1999:blog-5217445496019828087.post-86312280718316129982010-10-01T10:56:00.000-05:002010-10-01T10:56:50.548-05:00Not quite what you were hoping for, but...Recently, I haven't had much time to work on pybox2d. And when I say 'not much', I mean just about zero.<br />
<br />
In any case, I know that there are probably a couple people out there that are anxious to try the new version but don't want to go through installing SWIG, compiling, etc. It's a pain, I realize.<br />
<br />
The other day Fahri, creator of <a href="http://mekanimo.net/">Mekanimo</a> --- the only commercial product to use pybox2d that I know of -- asked me if I had a binary he could test of the new branch. I threw a simple Python 2.6 (win32) package together, and thought that the rest of you might like to give it a go also.<br />
<br />
The library itself is contained in the archive, so there's no need to install it. The redesigned testbed examples are in there, and you can experiment with the new syntax to your heart's content. For any of the tests, simply run: <span style="font-family: "Courier New",Courier,monospace;">python test_Web.py</span> . You can also specify the (incomplete) pyglet or pyqt4 back-ends with: <span style="font-family: "Courier New",Courier,monospace;">python test_Web.py --backend pyglet</span> or '--backend pyqt4' for example.<br />
<br />
I only ask that if you give it a try, please at least run <span style="font-family: "Courier New",Courier,monospace;">python run_unit_tests.py</span> and see if you get any errors. Also, please note that this is alpha-quality and does not have much documentation.<br />
<br />
Download <a href="http://code.google.com/p/pybox2d/downloads/detail?name=pybox2d-2.1-alpha-test.zip&can=2&q=#makechanges">here</a>.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com2tag:blogger.com,1999:blog-5217445496019828087.post-83990814856104342272010-07-11T20:54:00.000-05:002010-07-11T20:54:37.812-05:002.1.0 Branch Status<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_8BgF4kTEi5Y/TDp1BMgCzXI/AAAAAAAACmg/wMOS47sEkUk/s1600/pyqt4_testbed.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/_8BgF4kTEi5Y/TDp1BMgCzXI/AAAAAAAACmg/wMOS47sEkUk/s320/pyqt4_testbed.png" /></a></div><br />
Hi!<br />
<br />
How's everything? Make any games lately? Me? Oh, I'm still alive and kicking over here.<br />
<br />
So anyway, here are some of the updates following my last <a href="http://pybox2d.blogspot.com/2010/01/svn-r246-210-branch.html">post</a> about r246 a good 6 months ago (all of those changes are still mostly true).<br />
<br />
<ul><li>Updated to the latest Box2D svn, added loop/edge shapes (edges work, loops do not)</li>
<li>kwargs for all functions</li>
<li>Reworked the framework system to be more OO-friendly -- pyglet/pygame frameworks are derived from a base class now</li>
<li>Pyglet is basically working with the newest version 1.1.4 -- but it's got some major issues that need to be dealt with. If there are any Pyglet experts out there, let me know.</li>
<li>Added a PyQt4 framework with basic functionality. I have a few plans for it... [pictured above] </li>
<li>world.CreateCircleShape, world.CreatePolygonShape, and so on, which allow kwargs for both the shapes and the fixture, so that things like this are possible:<code><br />
world=b2World<br />
world.CreatePolygonFixture(box=(1, 1), friction=0.2, density=1.0)<br />
</code><br />
remember that 'box' is a property from the polygon shape, and 'friction' and 'density' are from the fixture definition.</li>
<li>Experimental 'b2' namespace:<code><br />
> from Box2D.b2 import *<br />
> vec2(1,1)<br />
b2Vec2(1,1)<br />
</code></li>
<li>CreateStaticBody and CreateDynamicBody, and <a href="http://code.google.com/p/pybox2d/source/detail?r=256">other changes</a> to CreateBody and CreateFixture. There's also world.Create*Joint(), body.CreateShapesFromFixtures, and probably some others</li>
</ul>New tests:<br />
<ul><li>Tiles</li>
<li>Pinball</li>
<li>CharacterCollision</li>
<li>Bullet</li>
<li>Most of the old ones, converted to the new style</li>
</ul>Still needs a lot of work. But if you ever want this version to see the light of day, please do give it a try and let me know what you think (and of course if you have any issues, which you likely will):<br />
<code>% svn checkout http://pybox2d.googlecode.com/svn/branches/box2d_2.1/ pybox2d-svn </code><br />
<br />
Also, given that the Box2D wiki has been down for ages, I guess it's a good time to find a new place to host a pybox2d wiki. Any recommendations?knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com5tag:blogger.com,1999:blog-5217445496019828087.post-50138728271712782262010-01-16T10:44:00.002-06:002010-01-16T10:55:35.182-06:00So, I've gotten this far...I have spent a good month now redoing everything in the project, but I've hit a bit of a wall. It's pretty much in a "good enough" state for a release, minus a few of the testbed examples I have yet to port. Oh, and all of the documentation. Ugh. Now with Box2D's wiki down, it makes it even more difficult.<br /><br />There's that old adage "release early; release often", but I find it hard to jump on that bandwagon. Releases are very difficult to do in the first place for multiple platforms and multiple versions of Python. And then support them afterward? Forget it. Oh well. I might continue at a slow pace for a while and wrap some more things up for a release whenever I manage to get a bunch of free time again, or maybe not. There's a bunch more changes on the <a href="http://code.google.com/p/pybox2d/source/list">SVN</a> since the last blog post if you have any interest.<br /><br />Perhaps <a href="https://bitbucket.org/elemel/pysics/wiki/Home">this</a> will take over in the meantime?knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com24tag:blogger.com,1999:blog-5217445496019828087.post-19406573971857239792010-01-10T17:48:00.006-06:002010-01-13T18:15:18.075-06:00svn r246 (2.1.0 branch)As I mentioned in the previous <a href="http://pybox2d.blogspot.com/2009/12/end-of-year-status.html">post</a>, I've been working on the new version of pybox2d, based on the work-in-progress C++ library <a href="http://code.google.com/p/box2d/">Box2D</a> 2.1.0.<br /><br />With all of the upstream changes (see the previous post), it gave me a good opportunity to start anew. SVN r246 offers these benefits over previous versions of pybox2d, in no particular order:<br /><ul><li><span style="font-weight: bold;">Python 3k</span> (3.1 tested) support. Many would argue that you wouldn't want to use it, but I have seen very little fps difference in my tests.</li><li>Significantly<span style="font-weight: bold;"> increased performance</span>. I get a steady 55-60fps on test_Pyramid with the menu drawing disabled, on both Python 2.6 and 3.1. I never got above 40fps on 2.0.1.</li><li>The above is partly related to the <span style="font-weight: bold;">new</span> (optional) <span style="font-weight: bold;">b2DebugDrawExtended </span>class. It adds slightly to the base b2DebugDrawClass by doing world->screen coordinate conversions in C++ before passing them to Python. Possibly not very useful in the OpenGL case, but very useful for SDL-based systems. I think in my small tests it offered a gain of 5-10fps.</li><li><span style="font-weight: bold;">DebugDraw flags</span> are also implemented as <span style="font-weight: bold;">keywords </span>now, so it's unnecessary to pass a bitmask to it.</li><li><span style="font-weight: bold;">Callback </span>functions that used to get b2Vec2s now <span style="font-weight: bold;">get tuples</span> -- so you don't risk a crash when holding on to a b2Vec2 instance created on the stack.<br /></li><li><span style="font-weight: bold;">kwarg support</span> for all class __init__ routines. This means you can do things like:<br /><code><br />self.world.CreateBody(<br /> b2BodyDef(<br /> type=b2_staticBody,<br /> position=(0,3),<br /> fixtures=[b2CircleShape(radius=0.5),<br /> b2PolygonShape(box=(0.5, 0.5))],<br /> )<br /> )</code><br /><br /><br />Which would create a static body at (0,3) with a circle (of radius 0.5) and a box (with half-dimensions 0.5,0.5). You can still create things the old fashioned way, if you like. Just remember with the new Box2D there are no b2ShapeDefs.<br /></li><li>kwarg support extended to allow for <span style="font-weight: bold;">b2JointDef creation</span>. In the past, you would have had to do <code>b2RevoluteJointDef.Initialize(bodyA, bodyB, anchorpoint)</code> to get all of the necessary elements properly set, but now the same is possible with <code>b2RevoluteJointDef(bodyA=a, bodyB=b, anchor=pt, other_kwargs=blah)</code>.<br /></li><li><span style="font-weight: bold;">Additional properties</span> for polygon shapes, so that <code>b2PolygonShape(box=(2.0, 2.0))</code> is sugar for:<br /><code>s=b2PolygonShape()<br />s.SetAsBox( (2.0, 2.0) )</code><br />(or in the current version, <code>s.box = (2.0, 2.0)</code> )<br /></li><li>You can do: <span style="font-style: italic;">point in b2AABB </span>to see if a vector is inside an AABB.<br /></li><li><span style="font-weight: bold;">Unit tests</span>. You should be able to tell just after installation whether or not the library is working properly.<br /></li><li>A mechanism so that you don't have to keep a reference to the callback classes (e.g., b2DebugDraw). In most cases you would want to have access to it, but it <span style="font-weight: bold;">shouldn't crash</span> anymore without it being stored on the Python side. [still need to test this more to ensure it works properly]<br /></li><li><span style="font-weight: bold;">dir() listings are clean</span> for almost every class, so you should be able to see what's possible with a specific<br /></li><li><span style="font-weight: bold;">Improved vector</span> and matrix classes, with more operator support. b2Vec2s are also indexable -- so: <code>b2Vec2(1,2)[0] = 1</code><br /></li><li>b2Color has also been enhanced to allow for operators, and useful things like <code>b2Color.byte</code> to get color components clamped in the [0,255] range are also there.<br /></li><li><code>getAsType()</code> is <span style="font-weight: bold;">no longer necessary</span>. Joints and shapes are properly downcast in all instances.</li><li>Plenty of other things from the new C++ code.<br /></li><li>I've been doing my best to keep everything accessible in properties when possible.<br /></li><li>Unused classes are also hidden, and the rest have been gone through and at least basically checked for accessibility/usability.<br /></li><li>[... and all of the other stuff that I've forgotten.]<br /></li></ul>Note that this version is <span style="font-weight: bold;">largely source-incompatible </span>with older versions.<br /><br />You can try out this SVN version with:<br /><br /><code>svn checkout http://pybox2d.googlecode.com/svn/branches/box2d_2.1/ pybox2d<br />cd pybox2d<br />python setup.py develop test<br />cd examples<br />python test_ApplyForce.py<br /></code><br />Or just browse the code <a href="http://code.google.com/p/pybox2d/source/browse/#svn/branches/box2d_2.1">here</a>.<br /><br />Keep in mind that this will overwrite your current installed version. The testbed is likely to go through more changes, but the basic API shouldn't be changing much more from now on (unless something unexpected comes from the upstream library).<br /><br />Like it? Hate it? Lemme know.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0tag:blogger.com,1999:blog-5217445496019828087.post-50308694496243328692009-12-28T13:36:00.009-06:002009-12-29T14:35:28.524-06:00End of the year statusHello to the loyal couple of you who continue to refresh this lonely blog. :)<br /><br />I scrapped the branch I started on 6 months ago of the new version of pybox2d. The upstream library <a href="http://code.google.com/p/box2d/">Box2D</a> (now also hosted on Google Code) has seen a good deal of changes since then.<br /><br />The most notable changes are:<br /><ul><li>The new dynamic tree-based broadphase</li>This makes it such that there will no longer be a maximum proxy count. So, you won't see b2_maxProxies assertion errors when you try to create too many colliding shapes.<br /><li>Normalized and simplified class interfaces</li>The improved interface makes for an easier time in creating Pythonic properties.<br /><li>Kinematic bodies</li>These special bodies are essentially static in that they don't respond to collisions, but they can have their velocities set. I'd imagine they would be most useful as, for example, rotating platforms in some side-scroller.<br /><li>The removal of shape definitions and the addition of fixtures</li>I don't see this as offering much benefit to us on the Python end, but it allows shapes to be created and used without being attached to bodies. It makes for a great deal of changes for those attempting to port their code to the most recent version.<br /><li>One-sided platforms</li><li>No more SetMassFromShapes() nonsense</li><li>New collision callback system</li><li>Weld and friction joints</li><li>Controllers have been removed</li>This is unfortunate, but was anyone actually using them?<br /></ul><br />Here are some things I'm trying to do with the upcoming version of pybox2d:<br /><ul><li>Unit tests</li>I'm attempting to use unit tests (suggestions would be welcome on this, as I'm fairly new to it) as I go along to ensure all of the properties work and I don't break things along the way. <br /><li>Hide all getters and setters, while keeping things accessible in properties</li>I like this a lot, but I hate seeing the ugly <span style="font-style:italic;">__ClassName_GetterHere</span>-type things when doing a dir(). Should I just skip the hiding and make it semi-private with _Getter to avoid the lengthy name-mangling? Should I re-implement __dir__ to hide these? I would just rather not have users calling the functions when there are perfectly good properties in place.<br /><li>Properly downcast joints/shapes</li>So calls like <span style="font-style:italic;">b2Joint</span>.downcast() (or previously getAsType()) are no longer necessary.<li>Custom __setattr__?</li>I've been toying with the possibility of using a custom setattr to keep the user from trying to set shadow class instance variables that don't exist in the real class. Maybe I'll make it an option or decide after performance tests.<li>Eventual 64-bit and Python 3.x compatibility</li><li>Pythonic-ish initializers?</li>I've also been considering having the ability to do, for example:<br /> body.CreateFixture(b2FixtureDef(shape=b2CircleShape(radius=1), density=1, friction=0.3))<br />Any interest in that? It's simple sugar, but it could be useful.<li>Scrapping deprecated stuff, hiding unusable classes, pickling, etc.</li><br /></ul><br /><br />Any thoughts? What would you like to see in the new version? Yell at me and tell me what I'm doing wrong before I get too far into it.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com8tag:blogger.com,1999:blog-5217445496019828087.post-34185803341869870472009-06-09T09:35:00.003-05:002009-06-09T09:48:18.953-05:00Status?pybox2d isn't dead just yet.<br /><br />A few days ago, I started porting the bleeding-edge <a href="http://box2d.svn.sourceforge.net/viewvc/box2d/trunk/?view=log">version</a> of the library.<br /><br />Some changes include the addition of b2Fixture, contact listener changes, a new way to create edge chains, and significant algorithm changes. More information on these C++-specific changes can be found on the <a href="http://www.box2d.org/forum/viewtopic.php?f=2&t=3201">forums</a> and the Box2D SVN <a href="http://box2d.svn.sourceforge.net/viewvc/box2d/trunk/?view=log">changelog</a>.<br /><br />As it is a departure from the previous builds, it will stay as a <a href="http://code.google.com/p/pybox2d/source/browse/#svn/branches/box2d_r211+">branch</a> on here at least until it's significantly improved over the trunk. I'm not entirely happy about the significant API changes that are occurring, but I'm just bringing to Python what Erin Catto and others are making available to the C++-world. I guess what I'm trying to say is, well, don't shoot the messenger.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com5tag:blogger.com,1999:blog-5217445496019828087.post-77896892918253758082009-03-06T16:52:00.003-06:002009-03-06T17:32:44.283-06:00Project spotlight: Mekanimo<a style="border: 0;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://mekanimomedia.s3.amazonaws.com/binaryadder.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 381px; height: 420px;" src="http://mekanimomedia.s3.amazonaws.com/binaryadder.gif" alt="" border="0" /></a><br /><blockquote><a href="http://www.mekanimo.net/">Mekanimo</a> is a 2D physics simulator. In minutes, you can create simulations, interactive games and puzzles, dazzling graphics and share them with others through the Internet.<br /></blockquote>Mekanimo really surprised me with its professional-looking user interface. It allows for the creation of worlds with customizable <a href="http://mekanimomedia.s3.amazonaws.com/screenshot5.png">scripting</a>, various <a href="http://mekanimomedia.s3.amazonaws.com/screenshot3.jpg">plots</a>, and so many other things. I enjoyed trying out the exhibits like the <a href="http://www.mekanimo.net/exhibit/marble-pump/">marble pump</a>, which require you to copy and paste the code into Mekanimo for now -- I think the author Fahri has been putting much more into the application itself than its website.<br /><br />It's still got a ways to go and unfortunately is (for now?) closed source, but keep an eye on it. I expect it to turn into a really nice and polished learning/design tool some day.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com2tag:blogger.com,1999:blog-5217445496019828087.post-91681287543323666672009-03-06T10:21:00.002-06:002009-03-06T10:31:31.795-06:00pybox2d svn r184Bugfix: Linux/x64 build issue.<br />Updated to Box2D r204:<br />b2Body now has these additional functions:<br /><ul><li>SetLinear/AngularDamping (additionally accessible by body.linearDamping = (x,y) )</li><li>SetStatic</li><li>SetFixedRotation (additionally accessible by body.fixedRotation = True)</li></ul>b2Shape:<br /><ul><li>SetSensor</li></ul>A few functions' names changed since some of the 2.0.2b1 accessor code was my own, but chances are you were using the properties anyway:<br /><br />IsRotationFixed -> IsFixedRotation (property fixedRotation)<br />CanSleep -> IsAllowSleeping (property allowSleep)knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0tag:blogger.com,1999:blog-5217445496019828087.post-79550590725915201312009-02-25T11:15:00.003-06:002009-02-25T11:46:04.130-06:002.0.2b1 Released!Since 2.0.2b0, there have been a good deal of changes to pybox2d:<ul><br /><li>Code structure completely reorganized</li><li>Doxygen comments converted to docstrings (should be a bit more friendly now, but still a bit C++'ish in places)</li><li>Lists and tuples may be used anywhere in place of b2Vec2's, and all of the tests have been updated to reflect this</li><li>Save/load state (pickling support for worlds)</li><li>Bug fix: Seg faults during DebugDraw/etc callbacks</li><li>Bug fix: userData reference counting causing leaks</li><li>Bug fix: getType() didn't work on line joints</li><li>Bug fix: TestSegment now returns from (-1,0,1) and not a bool</li><li>b2PolygonDef.setVertices() added, supports either b2Vec2 or list/tuple, so no need to specify. Old setVertices_tuple/b2Vec2() are deprecated.</li><li>New pretty printing style. It takes up a good deal of space, but it's actually readable.</li><li>New examples: <a href="http://code.google.com/p/pybox2d/source/browse/trunk/testbed/test_BezierEdges.py">bezier edges</a> with thin line segments, a simple <a href="http://code.google.com/p/pybox2d/source/browse/trunk/testbed/test_Belt.py">belt</a>, basic <a href="http://code.google.com/p/pybox2d/source/browse/trunk/testbed/test_pickle.py">pickling</a> example (might needs some updating)</li><li>(Optionally compilable) C++ assertion failures turned into Python exceptions<br>Additional properties and accessors to make coding easier (see below)</li><li>Many tests were updated and rewritten to be cleaner</li><li>Added b2CheckPolygonDef and deprecated the Python ported version. This version adds (optional) additional checks to ensure that your shape is convex and properly sized to not have strange results</li><li>Added GetVertices() for b2EdgeShapes. Creating one b2ChainDef results in many b2EdgeShapes, so this properly loops through each connected shape and gets the vertices in order</li><li>Box2D source updated, b2GravityController fixed</li><li>A fix for not allowing b2Body/Joint/Controller/Shapes as dictionary keys. Don't know how I missed this one. Still won't be picklable unfortunately.</li><li>Basic iterators have been added: b2World (iterates over bodies), b2Body (iterates over shapes), b2Controller (iterates over bodies), b2PolygonShape (iterates over vertices)</li></ul>There are several code-breaking features that you might run into:<br /><ul><br /><li>The library is now called <span style="font-weight:bold;">Box2D</span> (and not the cumbersome Box2D2)</li><li>Controllers now follow the factory style (see the <a href="http://code.google.com/p/pybox2d/source/browse/branches/new_setup/testbed/test_Buoyancy.py">buoyancy</a> test for more information)</li><li>b2Distance updated (see <a href="http://code.google.com/p/pybox2d/source/detail?r=137">here</a> if this affects you)</li><li>b2Body.GetShapeList() used to return only first shape, now returns actual list</li><li>b2World.GetBodyList/Joint() used to return only first body, now returns actual list</li><li>All occurences of the ugly 'm_' have been removed. This might require some changes in your code, since this applies to all b2Joint.m_* and others, not just testbed stuff.</li></ul><br />The following are the additional properties added. Most are just for convenience and make the definition (e.g., b2ShapeDef) symmetric with the output (e.g., b2Shape). Ones with * are changeable; the rest are read-only:<br /><table><tbody><tr><td>b2World</td><td>gravity*, jointList, bodyList, groundBody, worldAABB, doSleep</td></tr><tr><td>b2Shape</td><td>filter*, friction*, restitution*, density*</td></tr><tr><td>b2Joint</td><td>type, userData, body1, body2, collideConnected</td></tr><tr><td>b2CircleShape </td><td>radius, localPosition</td></tr><tr><td>b2PolygonShape</td><td>vertices, coreVertices, normals</td></tr><tr><td>b2Body</td><td> massData*, position*, angle*, linearDamping, angularDamping, allowSleep*, isSleeping, IsRotationFixed, isBullet*, angularVelocity*, linearVelocity*, shapeList</td></tr></tbody></table><br />Basic epydoc documentation is now available <a href="http://pybox2d.googlecode.com/svn/epydoc/html/index.html">here</a>. The testbed is no longer included in the installer, so please download it separately <a href="http://pybox2d.googlecode.com/files/pybox2d-testbed-2.0.2b1.zip">here</a>.<br /><br />Releasing for all these operating systems all by myself is time consuming, confusing, and tough at times. I'm sure I got something wrong, so please go easy on me. :) Do let me know if something doesn't work for you, though.<br /><br />Enjoy!knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com9tag:blogger.com,1999:blog-5217445496019828087.post-52605931530151812902009-01-20T21:40:00.003-06:002009-01-20T21:52:50.375-06:00Update on PicklingAs of this post, the latest svn revision, <a href="http://code.google.com/p/pybox2d/source/detail?r=148">r148</a>, has pickling support which is working great on the testbed. I'm rather excited about it, as it's somewhat of a powerful and unique feature.<br /><br />For those who can compile the library, check out the testbed. It works like your regular quicksave (F5)/quickload (F7) system. There's an additional test, test_pickle.py, that shows how easy it is to load a pickled world. As far as the code itself goes, there's still some commenting to be done, but it should be readable.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com6tag:blogger.com,1999:blog-5217445496019828087.post-34612422235290608242009-01-12T17:31:00.005-06:002009-01-14T18:16:43.336-06:00SWIG and PickleI have yet to see any site that explains how to pickle swig objects well enough. SWIG objects exist both on the Python and C++ side. <br /><br />Without calling the __init__ function on the Python class instance of a SWIG object, it doesn't exist as far as SWIG is concerned. So you'll get a TypeError on the 'self' parameter of your functions.<br /><br />If we were using old-style classes, __getinitargs__ would work well enough. Since we aren't, as far as I can tell, it's necessary for us to call the initializer ourselves. <br /><pre>def generic_setstate(self, dict):<br /> self.__init__()<br /> for key, value in dict.iteritems():<br /> setattr(self, key, value)<br /><br />def generic_getstate(self):<br /> return dict((var, getattr(self, var)) for var in <br /> __pickle_vars__[self.__class__.__name__])<br /></pre>If you have the dict __pickle_vars__ set up such as:<br /><pre>__pickle_vars__ = { 'myclass' : ['x', 'y'], 'myclass2' : ['zz'], ... }<br /></pre>You can then set:<pre>myclass.__getstate__=generic_getstate<br />myclass.__setstate__=generic_setstate</pre><br /><br />EDIT 2009/1/14:<br />If you use properties for all those C++ getters/setters (as you should be doing), you can then iterate over all of the properties for a much cleaner solution. It takes even more tweaking to get pickling to work with outputs from <a href="http://en.wikipedia.org/wiki/Factory_method_pattern">factory</a> products (e.g., trying to pickle a b2Body instead of a b2BodyDef). Expect something like this to show up soon in pybox2d. :)knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com1tag:blogger.com,1999:blog-5217445496019828087.post-32560873177866370682009-01-09T23:23:00.003-06:002009-01-09T23:36:35.941-06:00pybox2d svn r136Added something I've wanted to for a long time.<br /><br />Anywhere there's a b2Vec2, you should now be able to pass in a [length-2] list, tuple, or None -- (0,0). As I learn more about SWIG every time I try to throw some more functionality into Box2D.i, I'm more and more impressed with how much can be done with it.<br /><br />Changes can be seen in <a href="http://code.google.com/p/pybox2d/source/diff?spec=svn136&r=136&format=side&path=/trunk/testbed/test_ApplyForce.py">test_ApplyForce.py</a> and <a href="http://code.google.com/p/pybox2d/source/diff?spec=svn136&r=136&format=side&path=/trunk/testbed/test_Web.py">test_Web.py</a>. I'll eventually update the rest of the testbed examples.<br /><br />Oh yeah, also fixed a longtime standing bug with unset userData causing seg faults.<br /><br />Any other things you can think of that would be convenient? I'll probably allow matrices in list format.<br /><br />If you notice any side-effects, please let me know as always.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com2tag:blogger.com,1999:blog-5217445496019828087.post-16489703814212248182009-01-02T18:12:00.003-06:002009-01-03T20:19:04.704-06:00distutils, oh how I hate you...It took me forever and a day to get the original setup.py working for pybox2d, and then some people came along and told me how it was unnecessarily complex. And that it didn't work in the standard way and was somewhat confusing. Great.<br /><br />With a push from the user <a href="http://code.google.com/p/pybox2d/issues/detail?id=12">snickell</a>, I worked on restructuring the code-base to get it to conform to standard distribution methods.<br /><br />I've decided that I will no longer install the testbeds and things to c:\Python2x\Box2D for Windows users and will simply just offer them in a separate archive as I see some other libraries do.<br /><br />*EDIT*<br />My problem has been resolved and everything is apparently working now. I'm ready for another release -- but with nothing really new on the Box2D end, I guess there's nothing to do but wait.<br /><br />A few questions for you faithful few who reload this page every once in a while:<br />Windows users: Do you prefer MSI's or executables for your libraries?<br />Linux users: Any interest in an RPM distribution?<br /><br />Any other comments/etc. about the releases are always welcome.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com3tag:blogger.com,1999:blog-5217445496019828087.post-89549117216308584422008-10-23T16:26:00.008-05:002008-10-23T16:52:06.725-05:002.0.2b0 Released!<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_8BgF4kTEi5Y/SQDtO1gCiHI/AAAAAAAABUw/Ef_6BJKoEPU/s1600-h/buoyancy.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 200px; height: 156px;" src="http://4.bp.blogspot.com/_8BgF4kTEi5Y/SQDtO1gCiHI/AAAAAAAABUw/Ef_6BJKoEPU/s200/buoyancy.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5260465203904153714" /></a><br />With nearly no response from the community, this time-consuming project might end at this version.<br /><br />I'm also hoping that the OS X installers work well enough for everyone. It took a good amount of time to figure out how to (properly?) release for it.<br /><br />In any case, here's the changelog:<br /><blockquote>First release that's not based on a major Box2D release. It combines Box2D SVN r177 and contributions from shaktool (thin line segment) and BorisTheBrave (controllers/buoyancy).<br /><br /> * Thin line segment support (forum <a href="http://www.box2d.org/forum/viewtopic.php?f=3&t=1577">post</a>)<br /> * Buoyancy with generic controller support (forum <a href="http://www.box2d.org/forum/viewtopic.php?f=3&t=1664">post</a>)<br /> * Pyglet 1.1 testbed (still has some issues. run convert-from-pygame.py to convert the tests from pygame)<br /> * OS X <a href="http://code.google.com/p/pybox2d/wiki/Installer">Installer</a><br /> * Python 2.6 support<br /> * Line joints (see LineJoint test)<br /> * Raycasts (see RayCast test and BoxCutter test)<br /> * TestSegment support<br /> * BreakableBody test (forum <a href="http://www.box2d.org/forum/viewtopic.php?f=3&t=836">post</a>)<br /> * Fixed: == was working, but != comparisons weren't.<br /> * Access to polygon normals, core vertices, etc.<br /> * cvar list fixed<br /> * Off by one bug fixed for vertices<br /><br />New time step will require a few minor updates to your code:<br /><br />Old:<br />world.Step(timeStep, iterationCount)<br /><br />New:<br />world.Step(timeStep, velocityIterations, positionIterations)<br /><br />velocityIterations is usually 10, and positionIterations is usually 8.<br /></blockquote>knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com20tag:blogger.com,1999:blog-5217445496019828087.post-72152571407063946692008-10-10T11:19:00.006-05:002008-10-10T12:12:09.291-05:00pybox2d r86 - Thin Line Segment Shapes<div style='text-align:center;margin:0px auto 10px;'><a href='http://4.bp.blogspot.com/_8BgF4kTEi5Y/SO-AqEmudOI/AAAAAAAABUE/pJK0phaUbT4/s1600-h/Python+Box2D+Testbed+-+DynamicEdges+10102008+111819+AM.jpg'><img src='http://4.bp.blogspot.com/_8BgF4kTEi5Y/SO-AqEmudOI/AAAAAAAABUE/pJK0phaUbT4/s160/Python+Box2D+Testbed+-+DynamicEdges+10102008+111819+AM.jpg' border='0' alt='' /></a> </div><br /><br />Thanks to shaktool, <a href="http://www.box2d.org/forum/viewtopic.php?f=3&t=1577">thin line segments</a> are now available for Box2D! I've ported them to pybox2d, which you can see if you use svn <a href="http://code.google.com/p/pybox2d/source/detail?r=86">r86</a>. It's still in beta in the C++ form, so API changes can be expected.<br /><br />This is great news for creating platformer games, and even terrain in general. No longer will you have to worry about tesselating non-convex shapes to get the slopes and such that you want. See the new testbed demos, <br /><a href="http://code.google.com/p/pybox2d/source/browse/trunk/Python/testbed/test_DynamicEdges.py">test_DynamicEdges.py</a><br /><a href="http://code.google.com/p/pybox2d/source/browse/trunk/Python/testbed/test_PyramidStaticEdges.py">test_PyramidStaticEdges.py</a><br /><a href="http://code.google.com/p/pybox2d/source/browse/trunk/Python/testbed/test_StaticEdges.py">test_StaticEdges.py</a><br /><br />They are very simple to use, also:<br /><code><br />(Assuming a b2Body, body, at the origin)<br />verts = [ (50.0,0.0), (-50.0,0.0) ] <br />edgeDef = box2d.b2EdgeChainDef()<br />edgeDef.setVertices(verts)<br />edgeDef.isALoop = False<br />body.CreateShape(edgeDef)<br /></code><br />Creates a big, static line at the bottom of your world. If you want to make a dynamic one, simply use body.SetMassFromShapes() afterward. However, there are some problems with the dynamic versions (see the <a href="http://www.box2d.org/forum/viewtopic.php?f=3&t=1577">forum post</a>)knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com1tag:blogger.com,1999:blog-5217445496019828087.post-78538061136508350022008-09-16T23:18:00.003-05:002008-09-17T09:41:22.821-05:00pybox2d svn r70Totally restructured the SVN. The full Box2D source is now included, making compiling from SVN very easy. Python 2.6rc1 is also verified working and the steps are in place for a release on that version.<br /><br />On another note, I think the next actual Box2D release will be a long way off, given that Erin Catto is so busy. Perhaps once <a href="http://www.box2d.org/forum/viewtopic.php?f=8&t=1436">b2BuoyancyController</a> makes its way into the C++ port, I'll make an interim release for win32 Python 2.4-6 and OS X.<br /><br />I like the way <a href="http://code.google.com/p/pymunk/">pymunk</a> has binaries for all platforms included in his redistribution version. I don't think I could do that with pybox2d, given that SWIG will create a different library for each Python version. Plus, the size would just be too big. Any thoughts?<br /><br />Anybody out there? もしもし・・・?まっ、いいや。knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0tag:blogger.com,1999:blog-5217445496019828087.post-57028814148568913962008-09-14T12:07:00.006-05:002008-09-14T16:55:40.794-05:00pybox2d svn r60<div style='text-align:center;margin:0px auto 10px;'><a href='http://1.bp.blogspot.com/_8BgF4kTEi5Y/SM1EuWEw3hI/AAAAAAAABTw/oBnnmyVwm-I/s1600-h/Python+Box2D+Testbed+-+fluiDemo+9132008+82718+PM.jpg'><img src='http://1.bp.blogspot.com/_8BgF4kTEi5Y/SM1EuWEw3hI/AAAAAAAABTw/oBnnmyVwm-I/s160/Python+Box2D+Testbed+-+fluiDemo+9132008+82718+PM.jpg' border='0' alt='fluiDemo from Blaze' /></a> <a href='http://4.bp.blogspot.com/_8BgF4kTEi5Y/SM1EuozK5SI/AAAAAAAABT4/04iiAM8mDao/s1600-h/Python+Box2D+Testbed+-+UFOCatcher+9142008+115559+AM.jpg'><img src='http://4.bp.blogspot.com/_8BgF4kTEi5Y/SM1EuozK5SI/AAAAAAAABT4/04iiAM8mDao/s160/Python+Box2D+Testbed+-+UFOCatcher+9142008+115559+AM.jpg' border='0' alt='My UFOCatcher Test' /></a> </div><br /><a href="http://code.google.com/p/pybox2d/source/detail?r=60">svn r60</a> changelog:<br /><blockquote>Interface:<br />b2PolygonShape: getNormals_b2Vec2, getNormals_tuple added<br />b2Vec2.dot(v2) added.<br /><br />Miscellaneous:<br />fluiDemo: Port of Blaze's fluid physics. Too slow in Python to be used in a game. More of a proof of concept. Mostly works, some kinks still there though.<br /><br />UFOCatcher: Sprites working with <a href="http://matthewmarshall.org/projects/rabbyt/">Rabbyt</a>, looks pretty but the grip is still not great.<br /><br />Both require a copy of the data/pgu directories from trunk/testbed to work.<br /></blockquote><br /><br />GetNormals() for b2PolygonShape was previously not wrapped, so it was inaccessible from Python. There was always box2d.b2Dot() available for use, but having it built into the b2Vec2 is perhaps more convenient: dotproduct = vec1.dot(vec2) instead of dotproduct = box2d.b2Dot(vec1, vec2).<br /><br />The fluiDemo, ported from <a href="http://www.dsource.org/projects/blaze/">Blaze</a>, is pretty fun to play with. Hopefully the last few bugs can be squashed. I'm sure it'll end up in Box2D itself eventually, at which point we'll be able to use it at full speed! It's just a proof of concept, really, or an extra example of how to use pybox2d.<br /><br />As far as using <a href="http://matthewmarshall.org/projects/rabbyt/">Rabbyt</a> for the UFOCatcher game/test, I didn't want to really add another dependency, but it was just too pretty to pass up. If I can find out a good way to get the grip joints working, maybe I'll make an actual little game out of it. I'd like to port it to the <a href="http://laptop.org/laptop/">XO</a>, but that'll require not using Rabbyt or OpenGL.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0tag:blogger.com,1999:blog-5217445496019828087.post-34466995449101437062008-09-02T21:10:00.002-05:002008-09-02T21:19:37.918-05:00OLPC Physics Jam<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://wiki.laptop.org/images/thumb/c/c6/Activity-Rollcats.svg/40px-Activity-Rollcats.svg.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 30px;" src="http://wiki.laptop.org/images/thumb/c/c6/Activity-Rollcats.svg/40px-Activity-Rollcats.svg.png" border="0" alt="" /></a><br />The jam (which used pybox2d on the One Laptop per Child XO) finished up this past weekend. Their final presentations are <a href="http://physicsjam.blogspot.com/2008/09/final-presentations.html">here</a>.<br /><br />I'm rather partial to the <a href="http://www.rollcats.com/">Rollcats</a>. :)knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0tag:blogger.com,1999:blog-5217445496019828087.post-15266804235054913502008-09-02T11:34:00.004-05:002008-09-14T12:19:59.511-05:00pybox2d svn r57<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_8BgF4kTEi5Y/SL1sSkz4AfI/AAAAAAAABRU/lp25bSsOB94/s1600-h/linejoint.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_8BgF4kTEi5Y/SL1sSkz4AfI/AAAAAAAABRU/lp25bSsOB94/s200/linejoint.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5241464607703826930" /></a><br /><br />* Updated to Box2D SVN r173.<br />* Note that r173's Makefile needs to be modified to include b2LineJoint.cpp<br />* Line joints! Testbed ported, formatting updated.knehttp://www.blogger.com/profile/01886171929967978645noreply@blogger.com0