Swinging In Silverlight

Note: this sample is now updated to work with Silverlight 1.0

I decided to catch up with the latest Silverlight release. With the WPF/E release last year I dabbled with Conway's Game Of Life, but instead of porting old code I decided to try something new. During my short stint in the video game industry I found Gamasutra to be a great source of technical articles, and the article "Advanced Character Physics" by Thomas Jakobsen gave me an idea. The article describes the verlet integration algorithm used in molecular dynamics models. The subject matter sounds intimidating, but the algorithm turns out to be relatively simple.

Verlet integration (pronounced vehr-LEY (think French)) doesn't track the velocities of each particle in a system. Instead, Verlet calculates a particle's next position using its current and previous positions. The nice feature of Verlet is that enforcing a constraint (like not allowing a particle to move outside of a wall, or not allowing a particle to move too far away from another, attached particle) is almost as easy as repositioning the particle – at least there is no need to calculate a new velocity.

I built a simple, swinging "rope" in Silverlight. The "rope" is composed of 12 Pluralsight logos. Gravity pulls the rope downward, while a left-to-right breeze can blow the rope across the screen. Credit Ian Griffiths for building the Pluralsight eye in XAML . A static screen shot doesn't show the realistic motion ...

... so if you have the Silverlight 1.0 beta install, try the sample here.

You can download the source code here.

Note to Karl Seguin: don't download the code. This was a late night hack on a holiday weekend. If you break into tears then it's not my fault! :)

posted on Monday, May 28, 2007 11:58 PM by scott

Comments

Monday, May 28, 2007 9:14 PM by Stan

# re: Swinging In Silverlight

Way cool, dude. It's mesmorizing!
Tuesday, May 29, 2007 11:49 AM by AzamSharp

# re: Swinging In Silverlight

Hi,

Very good example :)

Great work!
Tuesday, May 29, 2007 7:23 PM by Christopher Steen

# Link Listing - May 29, 2007

RESTful Web Services [Via: Jon Udell ] SCSFContrib is Alive! [Via: bsimser ] Expression Studio on MSDN...
Wednesday, May 30, 2007 6:08 AM by Mike Harsh's Blog

# More Silverlight Physics - K. Scott Allen's Swinging Rope

Last year (well, really early this year), Scott created a version of Conway's game of life in Silverlight
Wednesday, May 30, 2007 7:58 AM by Blogs

# More Silverlight Physics - K. Scott Allen's Swinging Rope

Last year (well, really early this year), Scott created a version of Conway's game of life in Silverlight
Wednesday, May 30, 2007 8:20 AM by Blogs

# More Silverlight Physics - K. Scott Allen's Swinging Rope

Last year (well, really early this year), Scott created a version of Conway's game of life in Silverlight
Wednesday, May 30, 2007 10:40 AM by Community Blogs

# Silverlight Cream for May 30, 2007

Cream , as in 'Pick of the Litter' is always subjective, but this is my list for today as I view
Wednesday, May 30, 2007 10:46 AM by Community Blogs

# Silverlight Cream for May 30, 2007

Cream , as in 'Pick of the Litter' is always subjective, but this is my list for today as I view
Tuesday, February 19, 2008 11:54 PM by Mirrored Blogs

# More Silverlight Physics - K. Scott Allen's Swinging Rope

Last year (well, really early this year), Scott created a version of Conway's game of life in Silverlight