Monthly Archives: October 2009

GitHub I salute you

I've been using CodePlex with both the TFS integration and SVN for quite a while and recently started using GitHub, especially for the Balder project, and must say that I'm very impressed with what they have over at GitHub. Not only is Git something I'm really falling in love with and the way GitHub handles this, but simple things as the Issue tracking is so nice. GitHub is ultrafast, anything one does, its instant. Adding and modifiying issues is like working locally, kudos for this. 

One of the things I discovered the other day was the ability to host your pages there as well. Plain HTML hosting, something I've been missing at CodePlex, the best part, the HTML being hosted is versioned by Git – of course.

 

Balder gets declarative

We're getting closer to the BETA mark for Balder, and we're starting to get most of the features we want in for version 1 ready. The latest feature is the ability to declaratively through Xaml get Balder up and running. Current release is versioned 0.8.7 and can be found over at the Balder page at Codeplex.

By adding the following namespace declaration in your Xaml file:

[code:c#]xmlns:Core="clr-namespace:Balder.Core;assembly=Balder.Core.Silverlight"[/code]

You now get a set of extra controls that can be used.

First off is the RenderingContainer:

[code:c#]
<balder:RenderingContainer x:Name="_renderingContainer" Width="800" Height="600" BackgroundColor="Black"/> 
[/code]

You need to specify the Width and Height, as that is used to setup the display properly. The BackgroundColor property can be any color, including transparent – which is great if you want to mix with existing Silverlight controls on your page. 

The next control we've added is the Mesh control, it enables you to add any Mesh from a file/resource to the RenderingContainer. You do this by accessing the Nodes property on the Container and putting up a RenderedNodeCollection and put your Mesh(es) within that.

[code:c#]
<balder:RenderingContainer.Nodes>
       <balder:RenderedNodeCollection>
             <balder:Mesh x:Name="_audi" AssetName="audi.ASE"/>
        </balder:RenderedNodeCollection>
</balder:RenderingContainer.Nodes>
[/code]

For now, there is a limited amount of DependencyProperties exposed, so manipulation via Storyboards aren't possible today, but will be very soon. The only way to access this is by hooking up the Updated event on the RenderingContainer and implement codebehind logic for it, something like this:

[code:c#]
private float _angle = 0f;

private void Updated(RenderingContainer renderingContainer)
{
    _audi.Node.World = Matrix.CreateRotationY(_angle);
    _angle += 0.5f;
    _renderingContainer.Camera.Position = new Vector(0,-5,-20);
}
[/code]

Last but not least, to get it all working, you need to initialize Balder. In your App.xaml.cs file, during the Application_Startup event, you need to add one line of code. It is very important for now that you add that line before your page (RootVisual) is created and set.

[code:c#]
  private void Application_Startup(object sender, StartupEventArgs e)
  {
   TargetDevice.Initialize();
   RootVisual = new Page();
  }
[/code]

I you want to use it the "conventional" way – non Xaml based, you need to add a similar line of code, but that line of code needs to be added after the page has been created. This is something that makes absolutely no sense and is something we're trying to fix and make it a lot more sense. Our goal is to get rid of that line of code all together.

A little note, we're not trying to mimick the WPF 3D namespaces at all, we're going our own direction. We don't feel the urge to replicate those, as the purpose of Balder is very different. 

Bing / Virtual Earth WPF MapControl – Localization issues

I just got an email from a guy that watched my WPF talk on the MSDN Live tour in Trondheim, he had downloaded one of my samples from that talk and gave it a go. But he constantly got this "Script Error" thing. The demo was using the WPF MapControl for Virtual Earth maps. It worked OK in all browsers he had tried. Kinda odd I thought. 

The error message was "String was not recognized as a valid boolean". I googled the error message without any concrete results.

Then it struck me; "could it be… Naahh.. It couldn't,  lets try switching regional format settings.." – I always set mine to English – U.S., without really having any good reason for doing so, seeing that I live in Norway. Anywho, I switched it to Norwegian, and there the same error was. 

The simple solution, codewize, is to set the CurrentCulture to be Invariant:

[code:c#]

System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; 

[/code]

I haven't had time to investigate why this happens, but it sure is kinda odd, since running the map in a browser works and the WPF Control is in fact just a WebBrowser control, using the same browser. 

Balder switching to GITHub for SourceControl

The last week or so, we've been hard at work on Balder to reorganize the source repository and move it to GITHub. The reason we want to do this are many, but one of the most important reasons is to enable anyone to be able to contribute to the project and give the core developers greater control for picking changes/patches done to the source and push it into the master/trunk branch.

For now we will be pushing all changes back to the Balder project on CodePlex as well, so anyone that just downloads the source will still find it over there.

During this transition we had really big trouble getting the synchronization between the repositories, even when we want the CodePlex one to be "slave" and no changes will be committed directly to CodePlex. We got errors that was not possible to get any response from Google on (must admit, never tried to Bing them), so we ended up having to totally purge all the source at CodePlex and push it back manually.

We've created a tutorial for getting started here and if you need details on GIT and how we do branching with it, you can read here

Speaking at NNUG Trondheim, 29th of October 2009

I will be speaking at NNUG Trondheim next week about how one can go about creating games using managed code with focus on Xna and Silverlight. The user group meeting is a cooperation with Javabin. 

If you happen to be in Trondheim on the 29th of October, stop by for a great evening with Anders Nordås talk about patterns and myself for the gaming section.

You can sign up and read more over at NNUG