A long long time ago, I made a swf converter that went to svg among other things, that eventually became part of the now defunct Xamlon product. Over the past few months I've been occasionally picking away at a new one - you can only live so long without your own graphic tools.
This is a bit different as it is written in C# 2.0 instead of 1.0 (nice!) and accepts Flash 8 files instead of just Flash 6. The previous version used an interim format that has as many .Net objects as I could manage (Colors were .Net Color objects, matrices were .Net Matrix's, even Brushes, Pens and Bitmaps were stored as the .Net equivalents). I've come to think this was a very stupid idea, so the new interim format has 0% to do with .Net framework graphic types. I'm calling the format Vex, but whatever, it is just crap in the middle. Rewriting is always a pain, but I must say the third or fourth time through this stuff it at least gets easier : ).
So the point of all this is to be able to take Flash animation and put it into the XNA games we are making (XNA is for making XBox/Windows games). That part is close to done, but after hearing about the Silverlight player I thought I would try exporting to xaml. The graphic part of Vex>Xaml only took about 3 hours, though it did remind me again how I really don't enjoy xml and 'squishy' formats like xaml. I guess I'm just not the type, I know it works for others. The older I get the less I like anything dynamic, and text as a format strikes me as really bloated, error prone, and strangely limiting. How fun would xaml be if you didn't speak English for example. Anyway, it is just a serialization format, so I won't get too excited. Besides I speak English, and since the good old days at Xamlon I speak Xaml too : ).
Here is a sample of the (not very pretty) xaml code I'm generating at the moment (you will need the Silverlight player to view it, and it seems to have a problem viewing straight *.xaml files in firefox, so, ugh, IE probably). Click for the original:
SWF:
XAML:
Now one thing that always seems to alarm people about the swf format is instead of defining a bunch of shapes with fills inside, it defines a bunch of edges with fills on each side. There are a lot of reasons this is a great idea (speed, size and cool implications for drawing to mention three), but maybe the reason it is pure genius is the anti-aliased gap problem. When you have two curved shapes that meet each other, and the edges are anti-aliased, you will see through the tiny gap. See this image for an example:
The thing is, this happens every time you intersect two shapes, and can be a huge pain. It happens a lot in a typical illustration or animation, and just once is enough to make it look like crap. You can see it on the horses neck in the above images too. Kind of like the choking and trapping issues that the print industry had to contend with in years gone by. With the edge being the definition of both sides, the rendering has the information it needs to blend the two colors together, rather than just butt them against each other. To get around this problem I'm currently adding a thin line of a solid fill color to edges, but this creates it's own problems, apart from being a total hack. Also, once you hit gradients, it is even more painful as you can't be sure what color to choose. I will try gradient outlines later, that might do it. Possibly the first practical use of a gradient brush stroke in history!
Anyway, long ramble about nothing here. I will post some animation samples when I get them (very busy finishing a game series atm, so maybe next week). I'm very interested how Silverlight will play animation. SVG totally choked on character style animations in the last converter, but Xaml is gpu (afaik Silverlight is too?) and has features like gradient freezing which should help a lot. Then again my laptop turns into a space heater running some of their simple demos. Then again it might not be optimized code, and xna plays them like butter. Well, time will soon tell!
Why do I keep thinking Silverchair? Hope they didn't name their Flash killer after a medium sucked band. Oh, I will post the app once it is presentable -- some stuff is kind of hacked in atm.
posted on Wednesday, April 18, 2007 9:59 PM