Saturday, August 25, 2012

Sometimes I think I should read more but there is no time...isn't it?

I spent many days this week trying to get the XML load/save functionality of scenes and got that working in a very complex way, took me 24 hours this week to make the code to work and still it lacks some functionality around the animation settings and physics, suddenly, something came to my mind and it ticked in my mind thinking why there isn't any solution already build in the XNA framework to handle all this for me instead of me writting thousands of lines of code to format and properly create THE XML file I am looking for.... and in a matter of 2 minutes after thinking I found this:

XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.Indent = true;

using (XmlWriter xmlWriter = XmlWriter.Create("testAniPack.xml", xmlSettings))
                IntermediateSerializer.Serialize(xmlWriter , animationPack , null);


may not seem very big, but this replaces the thousands of lines I wrote this week with just 4 lines. Wasted too much time to replicate something that already exists, at least I am glad I found this because the missing part is too complicated to do it manually and the animations are already running very smoothly, hope to be able to show up something very soon once I finish removing all this week's work and replace it by a few more lines of code. At least this made me very happy this weekend so I can work more on the physics portion.

2 comments:

  1. I know the feeling. As a coder you want to dive in and write it all yourself. But sometimes google is your best friend. You can stop yourself re-inventing the wheel.

    XNA is quite feature-rich, worthwhile learning it all if you have the time

    ReplyDelete
    Replies
    1. true, but lately I think I came up with google solutions after implementing them, though I was able to do some speed comparissons and I found that my loading routine was a lot faster than the native XNA loader, by around 30% to 50% faster, I am not sure why yet, but since the work offload to XNA makes things easier I will keep the XNA solution.

      But my next post will be around my adventures around Inverse Kinematics implementation, this time I made sure to find answers by searching for weeks but I couldn't find a proper solution

      Delete