Category Archives: Balder

Balder out

I promised a release last month, but I had to do surgery and got a bit sidetracked with feeling sorry for myself being in pain. Anyhow, all is good and finally got the release out the door.

Its been almost 6 months since the last release. So this better be good. 🙂

The following are as complete a list I could compile of whats new and improved, btw. you’ll find the new release here. A new version of the SampleBrowser can be found here.

Performance improvements

  • Scanline renderers has improved quite a bit
  • Lighting calculations
  • NodesControl
  • Startup improvements
  • Content caching – loading the same content twice will only clone existing in cache
  • Color class – conversion plus operations are rewritten, introduced ColorAsFloats
  • Dependency properties now represented as Property with caching in it


  • World matrix + general matrix fixups
  • NodesControl fixed, one can now nest these, plus a massive performance improvement during databinding using the ItemsSource.
  • Mouse events actually working – had quite a few bugs with this, they are pixel perfect
  • PivotPoint fixed – working recursively
  • Completely rewritten rendering pipeline for stability, expandability and performance
  • Memory leaks in mouse event handling
  • Fixed Asset handling system – had a few bugs in it. Still has to revisit this.
  • Parsing of ASE files now use invariant culture all over the place. Had a couple of places it didn’t.

New features

  • Manipulation events on objects, implemented using mouse events.
  • They contain more detailed information about the object being manipulated, such as material information. Also, the events are not like the mouse events, they actually contain delta information about the manipulation occuring.
  • Tooltips, there is a property on all objects called Tooltip, you can create tooltips as you please, as you’d do with the TooltipService in Silverlight for other objects. The TooltipService will not work, hence the specialized property for it.
  • DirectionalLight – basic directional lighting
  • ViewLight – lighting that is “attached” to the camera/view
  • ArbitraryHeightMap – heightmap that can have its corners placed arbitrarily
  • SmoothingGroups implemented
  • New ASE parser – supporting multiple objects, world matrix. Also a lot faster.
  • Ring – geometry type
  • Started implementation of a ChamferBox – very basic at this point
  • Passive Rendering, will draw in wireframe during interaction and flip to full rendering when interaction has stopped. When no interaction, it will not render, Balder goes idle.
  • Pausing – for pausing everything.
  • Grabbing a frame from the Display can now be done
  • Container for renderable nodes – has its own world coordinate system that can be manipulated, lights can’t be placed in this container.
  • BubbledEvent system for events that needs to bubble up in the hierarchy
  • Messenger system for decoupling and stability
  • IGeometryDetailLevel – basically only used for Passive rendering at this point
  • Geometry artifacts such as Face, Vertex and so forth are now classes and has been generalized. Its now up to the implementing platform to create specialized versions of them.
  • Removed MEF and introduced a specialized TypeDiscoverer instead.

Development environment

  • Changed to Visual Studio 2010
  • Build server up and running with a more complete file for continuous integration

Breaking changes

  • IGeometryContext does no longer hold the geometry data directly, introduced something called IGeometryDetailLevel. One can get the full detail level, which is the default (and only for now), by calling the method GetDetailLevel() on the IGeometryContext. In addition, any Geometry has a property called FullDetailLevel for convenience.
  • Mouse events has been specialized – they are named the same as one is used to from Silverlight, but the MouseEventArgs has been “duplicated” in Balder.Core.Input. The reason for this is that the Silverlight class for this is sealed and does not have a public constructor, and the mouse event handling needs to handled in a special manner in Balder. Also, the events are now bubbled as well through the geometry hierarchy.

Balder – Upcoming release

Its been some 4 months since the last official binary drop of Balder and its just about time to get a new version out. The reason for the "hold up" is that I've been quite busy with working 2 jobs; my daytime job and Balder related freelance work at night. Combining that with having a family of 2 kids and a wife, there simply hasn't been any time left get binaries out there. 

But, as part of the work that I've been doing freelance, Balder has gotten a lot of improvements. Among these are the following : 

– Further optimizations in the rendering pipeline

– Rewritten NodesControl, speed up and more capable

– General cleanups

– More Xml comments for documentation purposes

– Retrofitted some unittests

– Mouse events working properly

– Tooltip for Nodes

– Arbitrary Heightmap – corners of heightmap can be placed anywhere

– New AseLoader with more support than before (Smoothings groups, more objects, more material details, colors++)

– Rewritten AssetLoader system

– Fixed bugs with primitives

– More samples in SampleBrowser

– Visual Studio 2010 solution + project files

– Optimized lighting

– Added ViewLight – lighting relative to view, basically directional lighting

– Passive Rendering, making the rendering halt unless properties are changed on any object in the scene

– Content caching for faster startups

– A lot of code cleanups for decoupling the platform even more

– Material detection for mouse events 


And a whole bunch of other improvements.

The only thing left before a release can be done is to tie together some lose ends and fix a couple of bugs – then its ready for deployment. I'll be sure to post about all the new features and how they can be used in a post when the release is ready.

The next iteration will focus more on increasing code quality, more cleanups, get more documentation up and running, continuous integration server up and running and things that will improve further development on the project. 

Still alive and kicking

Its been the most hectic couple of months I've ever had since February. 

I've had a few Silverlight courses, been out in the field at all kinda customers, traveling across Norway, doing talks at user groups and at the same time doing some moonlighting for a U.S. based company – and during this time, working hard on Balder and getting more and more features in it, optimizing it and fixing bugs. It has come at a price though, me not being able to post any blogposts and pretty much be passive on Twitter, Facebook and Messenger. My family will be surprised to see me soon, I guess. 🙂 

Balder is coming a long nicely and I'll be posting a bit about the new features and changes when I get some more time. Soon there will be a new official release, and I'm working on getting together a continuous integration server that will also do nightly builds and push them automatically to Codeplex. Just have to decide which platform I want to run it on – Mac or Windows. 

So until then, have patience with my blog – I'll return and put out quite a few articles I have running around in my brain. 

4 hours optimizing later…

After just 4 hours of dedicated optimizations with the aid of the EQATEC profiler for Silverlight – I managed to speed up the rendering pipeline of Balder quite dramatically. The profiler has a great comparison feature – simple and straight to the point. It shows that the rendering pipeline for Balder got optimized at an average og 2.28 times. (RenderingManagerRender) :


EQATEC donates profiler license to the Balder project

One of the things that has been missing in the Silverlight development story is a proper profiler that is simple to use and does not require you to hack the registry or do complex command line hacks to get it working. The Danish company called EQATEC has been making profilers for a while for the compact framework, but now they have implemented a Silverlight version that I must say I'm really impressed with. EQATEC has donated a professional license to the Balder project and I have already started using it, and my findings are very interesting. I've found more bottlenecks the last 24 hours than I have during the entire course of the project without a profiler. So I'm expecting Balder to get even more speedier in the near future.

If you want to have a look at how the profiler works, Channel 9 has a great video on it here.


Sapient using Balder for client project

Balder is rapidly moving from being a proof of concept for rotating a box in 3D as it was in early 2007 to becoming a quality library that can be used for gaming and line of business applications. Thanks to all that has shown interest in the project by using it, writing books about it, creating your own demos and posting it, and last but not least companies like Sapient – that took a leap of faith and went with Balder for visualization on a Silverlight project they are doing for a client they have.

A little more than a month ago, I came to an agreement with Sapient on helping them out using Balder on a non-disclosed client project. The Balder project itself is not affected by it, licensing or ownership wise. But it is affected in a rather positive way, it gives me the extra motivation to keep adding features and at a much faster rate than before. Although it might seem "quiet" on the outside, seeing thats there been more than 4 weeks since a release – its very hectic from where I'm sitting. I'm at high speed and turning out code as fast as I can. I will try to get a release out now and then, and hopefully we'll see one out in a short time span. More on the upcoming release in another post. Stay tuned.

INotifyPropertyChanged – Automagically implemented


Update, 19th of November 2011:

Eduardo Elias Mardini Bitar did an article for the CodeProject with some updates and improvements.


Recently I've been working on a small Silverlight project at a client and at the same time I've been working on implementing a SampleBrowser for Balder on my spare time, both these applications are using the MVVM paradigm and all that comes with it. One of the things that has really been bugging me is the INotifyPropertyChanged interface, a key interface for making the View observe changes on objects. Not only do you have to implement the same thing over and over again (the notification bit), but also the PropertyChanged event takes an argument that holds the property being changed as a literal. Although, the literal bit can be solved quite easily with some Lambda Expression magic, like I've blogged about in the past. But your still left with writing the same boring notification code over and over again.

I got really inspired by Jonas Follesoes post about how he solved the ever lasting challenge of INotifyPropertyChanged using Castles DynamicProxy to generate a proxy and automatically handle most of it. I read it and automatically started thinking about how I could remove the last bits and make the objects needed notification totally ignorant of the fact they should notify any changes. The Castle approach described by Jonas is very clean and I love working with Aspects like that, but it is pretty much impossible to get it to 100% automatically generate everything. The reason for this is that in the Silverlight runtime, you are not allowed for security reasons to invoke delegates on another type other than your own through reflection. Another issue I had that I could never figure out, was how to tie it in with an IoC container. I couldn't find a way in Castles solution to actually get the proxy type and not the instance, this of course is quite possibly possible, but I couldn't find it at all.

I started earlier today with the idea I could generate the proxy from scratch myself. The idea is to create a new proxy type that derives from the type you want to automatically notify its changes by overriding your properties. The properties you want to automatically notify must be virtual and implement a setter. The weaved version will override these properties and actually forward both the get and the set method of the properties to your type, so you can still do more complex stuff in your property methods. The result is a specialized object weaver for handling INotifyPropertyChanged. The code is too much to include in this post, but you'll find the implementation here and the unit tests here, also it support a couple of attributes – much like Jonas' solution for ignoring and adding other properties it should notify as well. Take a look at the entire namespace for all files needed. Also worth mentioning is that if you define your constructor to have arguments, it will implement a constructor on the proxy that is exactly the same and forward any arguments when instantiated. That way in a typical ViewModel scenario were you have dependencies to typically services, these will be injected when creating an instance of the proxy through an IoC Container.

Using it is very simple, create a class:

public class ViewModel
    public virtual string SomeString { get; set; }  


Getting the proxy type:

var proxyType = NotifyingObjectWeaver.GetProxyType<ViewModel>();

Once you have the type you can bind it in your IoC container or simply use the Activator type and create an instance of it. 

UPDATED 12th of January 2010: Discovered a small bug when I moved it into production, had forgotten to mark the type created with public. Silverlight can't instantiate private types via dynamically from other types. Its all been updated in the repository. 

EDIT 18th of January 2010: Made it dispatcher friendly – read my post about it.  


2009 coming to an end – Welcome 2010

2010 is just a couple of days away, I thought I'd do a recap of 2009 and what has happened in my little world. 🙂 

Back in August 2008 Balder was at a proof of concept stage and I had close to abandoned the project, I had so many things I wanted to do which resulted in not doing anything. Along came a couple of emails from Clinton Rocksmith who found the project interesting and wanted to know how he could contribute. I was really surprised, I never imagined anyone actually looking at the project. Timing was a bit off, I had just signed a contract with a new company and never got around to prioritize Balder, other projects always came in the way. Again, a couple of months later the project was at a stand still and I was getting again to a point of almost abandoning it completely. In the beginning of 2009 though, I got contacted by Gastón Hillar who also found the project interesting and wanted to include a couple of samples in his upcoming book. This spun me completely of my axis. I worked closely with Gastón in providing him the best possible solution and bring Balder to a new level. For me this was a true turning point for Balder and I quickly decided to put all other projects on a complete halt and focus my energy on Balder. The result was that we managed to get Balder to an API level that felt a lot better, performance was increased with several hundred percent and the codebase quality was increased dramatically with retrofitting unit tests for critical parts. 

The project was all of a sudden going somewhere, it was time to look for other developers to join in. A good friend of mine; Petri Wilhelmsen joined the project and has contributed a bit and will commit more time next year to the project. Another friend of mine; Raymond Holmboe has been contributing some on and off since I started the project back in the days and will be committing more time next year as well to the project. 

The ultimate result from all of this is that there has been quite a few commercial interests in the project, everything from companies wanting to buy the project as a whole to companies wanting to utilize it professionally. This is something I can disclose more information on later next year. One thing is certain though, Balder will stay open source and free to use.

Also this year, I was suggested as a Silverlight MVP and was eventually moved from Xna to Silverlight. Thanks to Justin Angel for recognizing me and suggesting the move, its a true honor. 

Although I had a very nice job at Objectware, the distance of 125 KM to work one way was to big. Even though I didn't commute everyday, it got to be a strain on my family when I had to go early in the morning and wasn't back till late and most nights after the kids had gone to bed. So I started sniffing the market to see if there was opportunities closer to home. I ended up at a company called Bouvet, and don't regret my decision. Bouvet has in my opinion the right focus for consultants, and it just feels right. Happy to be onboard.

Professionally I've had the opportunity to work full time on a Enterprise Silverlight project, I've worked on two Microsoft Surface projects, some WPF projects and finally ended up spending the last 3-4 months of the year working on an MVC project with some Silverlight content.  

Its also been a very busy year when it comes to speaking engagements, I've been part of Microsoft Norways MSDN Live tour, been speaking at NNUG a couple of times, Game Camp, did a Silverlight course. 

2009 has truly been an exciting year, busy, but very exciting. With the release of Silverlight 3 this summer and the beta version of Silverlight 4, I'm at a point were I really can't wait to get out of bed in the morning and just find the keyboard and start hacking away. It has never been more fun to be a developer, a lot is happening these days, not only in the Microsoft arena, but in general. I can't wait to see what 2010 brings.


Happy new year everyone, looking forward to participate next year. Thanks to everyone who has made 2009 so much fun and exciting, especially I'd like to thank my wife and kids, who has really been patient with me and supported me along the way. 



Innovasys donates to the Balder project

One really important thing when creating a framework like Balder, is to create proper documentation. The purpose of the documentation is for people to get good explanations for the API and samples on how to use it. 

I've been researching quite a bit for finding a good solution for doing this and didn't want to do all documentation by using XML comments only, but wanted more rich content and must admit that I never found any free solutions that I found satisfying. In the past I've used Innovasys' solution called DocumentX and was very happy with it. It might not be the natural choice for an OpenSource project to chose a commercial product, but the quality in which I want the documentation to be in I really wanted to use a product like DocumentX.

DocumentX provides a combination of documentation generated from XML comments in the code and rich text edited content, all mixed in nicely in the development environment; Visual Studio. This makes it easy to use and maintainable.  

Long story short, we've been so lucky to get Innovasys to sponsor  donate a license to actually do this. So a big thanks goes to them for providing the necessary license for this.


We will be working on updating the documentation and get it in future releases and part of the regular development. 

Balder Release is out

UPDATE 8th of July 2010 : is out – read more here.

UPDATE, 16th of December 2009 : Release was pulled due to issues with rendering. New release will be pushed soon.

Its that time again, yet another release of Balder. You’re probably thinking – whats going on? Pushing releases close to every week.

Well, this release had to be pushed out fast, the reason being that a couple of days after the previous release I realized that the Xaml support introduced felt good while using it, but clearly had its limitations and also maintainability issues when working with the library.

In the previous release I introduced the Xaml support as Controls in the Balder.Silverlight assembly, which seemed like a fair place to have it, seeing that Xaml/Controls are a very specific platform option that Silverlight supports and should not be present in Core. Problem with that was that we now had two object hierarchies to maintain, one just reflecting most of the properties already found in Core and doing some crazy magic to maintain these hierarchies. Needless to say, this approach is very error prone and hard to maintain.

Dependency Properties

The main reasons for not pushing the Control support into Core was the fact that I didn’t want DependencyProperties leaking into it all over the place and not wanting types to derive from DependencyObject or any other Silverlight specific type. So what I came up with is to make the types in question partial and implement the Silverlight specifics in a .Silverlight.cs file – which then could be skipped for other platforms. Then for DependencyProperties, I wrapped everything up in a generic Property type that has a Specific Silverlight implementation that again can change for other platforms.

The result is a more maintainable codebase, and a better experience when using it.


Another reason for pushing for another release was the fact that I did some heavy optimizations. Earlier when doing optimizations, I worked mostly with Silverlight 2 and Silverlight 3 Beta. For SL2 I created a RawPngBufferStream, since no WriteableBitmap was available there, and for SL3 beta, the WriteableBitmap was quite different than what the final RTW version had going for it. Long story short, I ended up with a multithreading scenario that gave quite a performance boost.

After looking at this for quite some time, I found that it would be better to have multiple WriteableBitmaps and do triplebuffering with these and use different threads for different purposes (Clearing, Rendering, Showing). Turns out that this was quite efficient, only problem was that synchronization turned out to be a bit of a problem. So I did a test with doing all the operations synchronously in the CompositionTargets event, and it gave a serious performance boost. That combined with some optimized ways of clearing surely seemed to do wonders.

The new release is available fromhere.