UPDATE: This sample has been updated for Silverlight 2 beta 1. See it in action here – now with heads!🙂
Are you tired of physics demos yet? I hope not because I’ve just made another one It’s using the Managed Bullet Physics library I ported to WPF, tweaked slightly to run with Silverlight 1.1. This might be the world’s first cross-platform physics demo! (umm, except Flade of course, and probably a million others I’m unaware of).
Points of interest:
- You’ll need the Silverlight 1.1 Alpha runtime (or the SDK) for Windows. Mac users can get it here. Alternatively, if you just click the image above it might give you a direct download link…
It’s using an HtmlTimer to provide a ‘tick’ event for the animation. Curiously HtmlTimer is already marked obsolete; hopefully when Silverlight 1.1 releases it’ll have something like WPF’s CompositionTarget.Rendering event.See below.
- Similar to my original 2D physics demo, this is using a full 3D physics library but clamps it to 2D.
- There’s a strange ‘pause’ that occurs every few seconds in the animation. I can’t see anything in my code that’s causing it (it’s almost identical to the 3D XBAP demo I published earlier). On IE it’s about 250ms, but on Firefox it’s more like a couple of seconds. I’m assuming this is just related to Silverlight 1.1’s alpha status and will soon be fixed (don’t let me down guys! ).
- It listens to the BrowserHost.Resize event to adjust the scale and translation to fit the window. I’ve not added a full-screen toggle, but you can hit F11 to maximize the browser for full effect.
- This has been sitting on my PC a few weeks already; I came up against some really dumb bugs (of mine, related to my ‘XnaToWpf’ bridge) and wussed out a few times. It’s amazing how much easier it gets when the initial hurdles are gone…
Click the image above or this link to try it out. Source code will be coming soon!
UPDATE: No longer using the HtmlTimer; source code now available! (see later post).