Chris Cavanagh’s Blog

Entries from April 2007

XBAP 3D Physics source

April 24, 2007 · 7 Comments

In case you’ve been trying unsuccessfully to get the source code for my demos from CodePlex (their Team Foundation Server experienced some unfortunate operator error) I’ve published the 3D XBAP stuff here.  Note the beachballs now have a nice specular material applied smile_nerd

In my last post I’d forgotten to credit Daniel Lehenbauer for his Sphere3D code (which saved me a lot of effort!).  You can find his original post here.

UPDATE: I’d forgotten to post the “main” part of the source code; d’oh!  You can find it here (source only, or a version with binaries here)..

Categories: .NET

3D Physics XBAP

April 8, 2007 · 35 Comments

I’ve created a small XBAP 3D physics demo for pure geeky delight.  It’s got a long way to go, but it’s got a nice button that lets you drop beachballs on to each other, so I think that makes it morally OK smile_wink

It’s built on a managed version of the Bullet Physics Library, tweaked slightly for WPF (so it’ll run locally as an XBAP).  Give it a try and see what you think.  Some general notes:

  • Performance is fair; it could struggle on slow machines.  There are loads of optimizations we can do with WPF 3D (merging models into one GeometryModel3D can give huge improvements) but I’ll save that for another post smile_shades
  • Dropping too many objects will bring any system to its knees pretty quickly.  It’s not culling anything to a view frustum yet and the sphere models probably have too many vertices, so even if objects roll off screen they’ll still suck your CPU dry.  Just don’t do it smile_regular
  • You’ll get better performance with spheres than boxes.  They generally come to a rest more decisively (the physics engine marks objects as inactive when they’re at rest, at least until something hits them).  Boxes can currently ‘jitter’ a while before they settle down.

I’ve published the source on CodePlex.  Let me know if you’d be interested in contributing!

UPDATE: Did a couple of rendering tweaks and enabled camera movements (drag mouse to move, right-drag to zoom).  Also, thanks for the great feedback!

UPDATE 2: Fixed earlier ‘rolling’ issue (my bad) and added a ‘drop box’ button.  Boxes don’t behave quite as nicely as the beachballs yet (they act like jello cubes) but they’re still a lot of fun smile_party

Categories: .NET