You can get the source code for my Silverlight 1.1 alpha 2D physics demo here. It includes the BulletX source (original available here) as a Silverlight 1.1 class library; the CJC.XnaToWpf library (which I plan to clean up and rename) provides a very simple implementation of the XNA math classes (so we can use the BulletX source files unchanged).
Enjoy!


11 comments
Comments feed for this article
August 3, 2007 at 12:33 pm
Matthew Hanks
Thank you for your source code, but could you have a look at the example I asked for (you removed my comment, I know, couldn’t find a mail form on your site, sorry!!). I would like to extend the Silverlight Surface demo. Thank you for your reply!
August 3, 2007 at 12:56 pm
Chris Cavanagh
Matthew – I’d not removed your comment; just hadn’t approved it yet
(looks like WordPress highlighted it because there was a link in it). Could you explain a little more clearly what you mean? Sounds like you want the dragging to have some inertia?
August 3, 2007 at 2:06 pm
Matthew Hanks
Michael has a demo at http://silverlight.schwarz-interactive.de/ex04/, this example I would like to add some physics. Do you know Surface? You could start reszising a picture and if you stop resizing it will do a short slow down and stop, like an effect that will not stop immediately. If you have a look on some of the Microsoft Surface demos you will hopefully understand what I mean. Michael put the source online, ex04.zip in the root folder.
August 3, 2007 at 2:48 pm
Chris Cavanagh
Matthew – That’d be pretty easy to do without the complexity of a physics engine… Just grab the last two mouse locations when the button was released, then subtract one from the other to get a direction vector you can store with the instance being dragged. In the per-frame render method, just add that vector to the current location and then multiply it (the vector) by 0.8 or so (obviously it’ll hit zero eventually).
Or did you have something more sophisticated in mind?
August 3, 2007 at 3:46 pm
Matthew Hanks
Yes, maybe it is as easy, my problem is that I don’t understand enough, will do some tests during the weekend. Thank you for your answers.
August 3, 2007 at 3:51 pm
Matthew Hanks
Well, one thing more: the physics engine I thought to use to move other elements away if I move a picture over them, like if you have some pictures over others they will be moving, too, if you move the upper image. Does this make sense?
August 3, 2007 at 5:01 pm
Chris Cavanagh
Matthew – Yeah that could be pretty cool
It’d be interesting to see how well the engine could model something like paper (it’d be stiff; more like cardboard than paper). There could certainly be some interesting interactions going on
Let me know how far you get; if I get chance/time I’ll try to put together a sample to help out.
August 6, 2007 at 4:36 pm
Silverlight Cream for August 6, 2007
[...] updated his 2D Physics sample to 1.1 latest and added a few more enhancements as well. He also has the source on his site.. Thanks Chris! MLB.com is using Silverlight 1.0 RC Mike Harsh has blogged that MLB.com has [...]
August 8, 2007 at 2:52 pm
advertboy
Can’t remember how i got to this blog but im glad i got here. Congrats on a great demo, i should be working on my own blog and own demo but because of this cool app i can see ill be spending the rest of the week disecting the sourcode..
I look forward to your future post’s!
August 8, 2007 at 3:22 pm
Chris Cavanagh
advertboy – Glad you like it!
Apologies in advance for any sloppy code you find; that’s the “demo factor” or something
August 30, 2007 at 6:30 am
Silverlight physics engine | travellinghead
[...] Now, as I alluded to earlier, it turns out that there is at least one other physics engine for Silverlight out there – if you are interested in this kind of stuff then you should check it out too: ChrisCavanagh [...]