3D Cloth Source Code Posted: Technique for WPF 3D Morph Mesh

There is a great 3D cloth demo that has been floating around interally for awhile and shown at conferences, talks, channel 9 interviews, etc. However, we haven’t ever posted the source code . . . until now.  You can run it from here and download the source code here.

I didn’t write this code; David Teitlebaum, from the WPF team, did. He was hesitant to release it as the code isn’t factored to his liking, but I convinced him otherwise.  His code is interesting to read: Thing3D is my personal favorite class. It is also worth calling out that he uses no XAML and he also uses a MatrixCamera instead of the more easy-to-grok PerspectiveCamera and OrthographicCamera.  And the technique he uses for morphing the mesh is to swap out vertices on the fly using a timer, again not for the feint of heart. But, if you already know 3D paradigms and are wondering how to create stunning effects like this in WPF, this source code will be illuminating for you. 

If you can’t run the application because you either aren’t on Vista or haven’t installed .NET 3.0 on XP, here are some pics to give you a sense of the effect as the cloth, which is really just a 20 x 20 vertice plane, drops onto a sphere, bounces and slides onto a cube:

You can run it from here and download the source code here.

Comments (11)

  1. Thanks Karsten for your effort to get David to release his code. It’s appreciated.

  2. Jason L says:

    For some reason, I can’t run any "clickonce" applications on my computer.   When I clicked on the link for this application, it opened a separate browser window that closed in a couple of seconds, but nothing ever runs.  Any ideas?  I am running Windows XP Pro Service Pack 2 with IE 6.  I have .NET 3.0 installed.


  3. karstenj says:

    Hmm — no error message?  Anything in the event log?

  4. Jason L says:


    What event log are you referring to?  And no, there is not an error.

  5. Jason L says:

    I looked in the local settings/apps/2.0 directory and there were items loaded, but nothing for this application.  I deleted the 2.0 directory, and tried to launch the application again.  Still nothing happens, and the 2.0 directory wasn’t even recreated.  I also checked the event logs on my laptop, and I saw nothing out of the ordinary.

  6. Mike Goatly says:

    Fantastic stuff – very impressive!

  7. Ales Sturala says:

    Wow … I supposed WPF 3D is only for some easy 3D effects … but this is really impressive … what will be next, Halo IV completely coded in WPF? ;]

  8. this is impressive, indeed! it opens up a new age in developing online solutions…

    ..i’m not so familiar with this WPF-Stuff right now; all that i know is that we are not going to learn xaml:-)

    is there a rad available right now?

    greetings from germany!

  9. By RAD, I assume you mean tooling.  Check out Expression Blend (http://www.microsoft.com/expression).  For importing 3D assets, check out Mike Swanson’s tooling page: http://blogs.msdn.com/mswanson/articles/WPFToolsAndControls.aspx

  10. Știați că în XAML/WPF: există styling asemeni celui din CSS pt HTML? un co