Archive for February, 2010

Friday, February 12th, 2010

Balder was one of the first 3d prototype engines in Silverlight and it has evolved quite nicely. ¬†Balder by Einar Ingebrigtsen is described as a “Managed GameEngine with both 2D and 3D support targetting Silverlight, Xna and OpenGL.”

The sample browser will show you what Balder is capable of and it has come pretty far since the first version showing a wireframe teapot.

You know you’ve made it as a 3D engine when there are Augmented Reality apps for it.

Here’s a glance at what some of the C# source looks like for a feel of the engine code from the Silverlight4 TestApp:

using Balder.Core.Execution;
using Balder.Core.Objects.Geometries;
using System;
using Balder.Core.Lighting;
using Balder.Core;
using Colors=System.Windows.Media.Colors;
 
namespace Balder.Silverlight4.TestApp
{
    public class MyGame : Game
    {
        public override void OnInitialize()
        {
 
            Camera.Position.X = 0;
            Camera.Position.Y = 0;
            Camera.Position.Z = -80;
 
            var light = new OmniLight();
            light.Diffuse = Color.FromSystemColor(Colors.Green);
            light.Ambient = Color.FromSystemColor(Colors.Green);
            light.Specular = Color.FromSystemColor(Colors.White);
            light.Position.X = 0;
            light.Position.Y = 0;
            light.Position.Z = -130;
 
            Scene.AddNode(light);
 
            base.OnInitialize();
        }
 
 
        public override void OnLoadContent()
        {
            var teapot = ContentManager.Load("teapot.ase");
            Scene.AddNode(teapot);
            base.OnLoadContent();
        }
 
 
        private double _sin;
 
        public override void OnUpdate()
        {
 
            Camera.Position.X = (float)(Math.Sin(_sin)*80);
            Camera.Position.Y = 0;
            Camera.Position.Z = (float)(Math.Cos(_sin) * 80);
 
            _sin += 0.05;
            base.OnUpdate();
        }
 
    }
}