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
Feedback
  • # RE: New swf -> xaml/xna converter
    Bertrand Le Roy
    Posted @ 4/19/2007 3:17 AM
    Always playing with the fun stuff, eh? That's pretty cool!

  • # RE: New swf -> xaml/xna converter
    Robin Debreuil
    Posted @ 4/19/2007 11:50 AM
    Well actually doing a lot of Flash games these days, but one must keep at least one toe in the fun stuff : ).

    Awesome you are in OpenAjax btw...

  • # RE: New swf -> xaml/xna converter
    Michael Swanson
    Posted @ 4/23/2007 12:43 PM
    Very nice stuff! Related to this, I've also written a SWF2XAML conversion tool: http://blogs.msdn.com/mswanson/archive/2007/03/14/swf2xaml-0-2-a-slightly-better-flash-to-xaml-conversion.aspx. I'd be curious to hear your feedback.

  • # RE: New swf -> xaml/xna converter
    Robin Debreuil
    Posted @ 4/23/2007 6:21 PM
    Hi Michael,

    I did try out your tool, I really like the interface in there (nice site for it too btw). It is what convinced me I'm not ready to release the one I'm doing yet ; ).

    One thing I noticed is a number of my test cases didn't render properly on it. These were tests from when I did the swf>svg converter a few years ago. Generally they were the hard cases I saved so it isn't really typical files, but if you want a copy them to try just let me know (for example the shape3.swf one above doesn't render correctly for me - could be me doing something wrong too of course, like that has never happened before :).

    Looks like a great tool happening there in any case. Are you planning on doing animation or code conversion too? I guess a person only has so much spare time, but it would be really cool to see : ). Love to know about any updates when they happen...

    Cheers,
    Robin

  • # RE: New swf -> xaml/xna converter
    Michael Swanson
    Posted @ 4/24/2007 11:57 AM
    Glad you had a chance to try it out, Robin. Yes, I also have a collection of troublesome files that represent tags that I haven't implemented or geometry conversion problems that I haven't yet tackled. Unfortunately, as you've noticed, it's a side project, and I haven't had much time to work on it recently. As such, I don't currently have any major updates in the works.

    Please don't let my tool delay the release of yours! :) It sounds like you have a lot of expertise here, and that is a huge benefit.

    If you would like to contact me, please use the Email link on the aforementioned blog site.

    Thanks!

Blog Stats

  • Posts - 121
  • Stories - 1
  • Comments - 1441
  • Trackbacks - 47

.Net Blogs

01101 Blogs

Flash Blogs

Graphics

People