Endquote is Josh Santangelo, an interface developer and former man-about-town in Seattle. Lately, he talks a lot about Silverlight, Surface, and Stimulant.

email: josh[a]endquote[.]com
work: stimulant.io


Text

Jun 17, 2010
@ 8:20 pm
Permalink

PlaneProjection in WPF

Silverlight has an excellent feature called PlaneProjection which enables basic perspective transforms on any display object. That’s great for Silverlight, but when I’m working with Surface, I’m still using WPF 3.5. If I want to do any kind of 3D transform there I need to use the WPF 3D library, which is very powerful and very scary, especially if all I want to do is rotate a postcard in space. What to do?

There have been a couple of attempts to create a reusable perspective transform in WPF, but I found them both lacking. The main problem I had with existing solutions is that I needed my psuedo-3D element to play perfectly well with the WPF layout system, and I also needed my text to look perfect when the object was not rotated at some strange angle. So I started with those examples, and along with some help from David Teitlebaum and my co-worker Joel Pryde, created a class simply called “Plane”.

In addition to the features illustrated in the test application, Plane lets you specify differently-sized content for the front and back sides, renders content in regular 2D when rotated to an angle parallel to the display, and has no trouble existing in the same layout with regular 2D objects.

Click the image above to download a Visual Studio 2010 project with the full source. I’ll be posting an example of it in a real application soon.