omnidirectional light

Sep 4, 2010 at 10:51 PM

i'm following your tutorial . it's really good even for a newbie like me but i cant get the light rendering. the color of the box is always the same even if i change the light color to black for istance. 

i'm using sl4 , vs2010 and balder

my xaml:

(i copyed a little from comments :D )

<UserControl x:Class="baldertest2.MainPage"
    d:DesignHeight="484" d:DesignWidth="644">

    <Grid x:Name="LayoutRoot" Background="White">
        <Execution:Game Width="640" Height="480">
                <View:Camera Position="-10,0,-20"></View:Camera>
            <Lighting:OmniLight Position="0,2,-10" Strength="0.6" Diffuse="Green" />
            <Custom:MyBox Color="Blue"/>


my c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Balder.Objects.Geometries;
using Balder.Display;
using Balder.Math;
using Balder.Materials;

namespace baldertest2
    public partial class MainPage : UserControl
        public MainPage()


    public class MyBox : Balder.Objects.Geometries.Geometry
        public override void Prepare(Viewport viewport)
        public void PrepareFR()
            //Face f = null; 
            //for (int i = 0; i < FullDetailLevel.FaceCount; i++)
            //    f = FullDetailLevel.GetFace(i);
            //    f.Material = new Material();
            //    f.Material.Ambient = Colors.Orange;
            //    f.Material.Diffuse = Colors.Orange;
            //    f.Material.Opacity = 1;

        private void GenerateVertices()
            var dimensionAsVector = new Vector(5f, 5f, 5f);
            var halfDimension = dimensionAsVector / 2f;
            var frontUpperLeft = new Vertex(-halfDimension.X, halfDimension.Y, -halfDimension.Z);
            var frontUpperRight = new Vertex(halfDimension.X, halfDimension.Y, -halfDimension.Z);
            var frontLowerLeft = new Vertex(-halfDimension.X, -halfDimension.Y, -halfDimension.Z);
            var frontLowerRight = new Vertex(halfDimension.X, -halfDimension.Y, -halfDimension.Z);
            var backUpperLeft = new Vertex(-halfDimension.X, halfDimension.Y, halfDimension.Z);
            var backUpperRight = new Vertex(halfDimension.X, halfDimension.Y, halfDimension.Z);
            var backLowerLeft = new Vertex(-halfDimension.X, -halfDimension.Y, halfDimension.Z);
            var backLowerRight = new Vertex(halfDimension.X, -halfDimension.Y, halfDimension.Z);
            FullDetailLevel.SetVertex(0, frontUpperLeft);
            FullDetailLevel.SetVertex(1, frontUpperRight);
            FullDetailLevel.SetVertex(2, frontLowerLeft);
            FullDetailLevel.SetVertex(3, frontLowerRight);
            FullDetailLevel.SetVertex(4, backUpperLeft);
            FullDetailLevel.SetVertex(5, backUpperRight);
            FullDetailLevel.SetVertex(6, backLowerLeft);
            FullDetailLevel.SetVertex(7, backLowerRight);
        private void GenerateLines()
            FullDetailLevel.SetLine(0, new Balder.Objects.Geometries.Line(0, 1));
            FullDetailLevel.SetLine(1, new Balder.Objects.Geometries.Line(2, 3));
            FullDetailLevel.SetLine(2, new Balder.Objects.Geometries.Line(0, 2));
            FullDetailLevel.SetLine(3, new Balder.Objects.Geometries.Line(1, 3));
            FullDetailLevel.SetLine(4, new Balder.Objects.Geometries.Line(4, 5));
            FullDetailLevel.SetLine(5, new Balder.Objects.Geometries.Line(6, 7));
            FullDetailLevel.SetLine(6, new Balder.Objects.Geometries.Line(4, 6));
            FullDetailLevel.SetLine(7, new Balder.Objects.Geometries.Line(5, 7));
            FullDetailLevel.SetLine(8, new Balder.Objects.Geometries.Line(0, 4));
            FullDetailLevel.SetLine(9, new Balder.Objects.Geometries.Line(1, 5));
            FullDetailLevel.SetLine(10, new Balder.Objects.Geometries.Line(2, 6));
            FullDetailLevel.SetLine(11, new Balder.Objects.Geometries.Line(3, 7));
        private void GenerateFaces()
            FullDetailLevel.SetFace(0, new Face(2, 1, 0));
            FullDetailLevel.SetFace(1, new Face(1, 2, 3));
            FullDetailLevel.SetFace(2, new Face(4, 5, 6));
            FullDetailLevel.SetFace(3, new Face(7, 6, 5));
            FullDetailLevel.SetFace(4, new Face(0, 4, 2));
            FullDetailLevel.SetFace(5, new Face(6, 2, 4));
            FullDetailLevel.SetFace(6, new Face(3, 5, 1));
            FullDetailLevel.SetFace(7, new Face(5, 3, 7));
            FullDetailLevel.SetFace(8, new Face(0, 1, 4));
            FullDetailLevel.SetFace(9, new Face(5, 4, 1));
            FullDetailLevel.SetFace(10, new Face(6, 3, 2));
            FullDetailLevel.SetFace(11, new Face(3, 6, 7));





Sep 6, 2010 at 9:22 PM


sorry about the relay slow answer on this one. 

There is a couple of bugs in the version that was introduced in that version, one is the coloring and Materials, it defaults to a material that doesn't reflect anything from lighting.

You can fix it by specifying a Material that has the Shade property set to Flat or Gouraud, so in your Xaml you could do something like this : 

					<Materials:Material Diffuse="Green" Specular="White" Shade="Gouraud"/>

This is fixed in the source under the Source Code tab, if you download the latest from there - and you open up a Visual Studio CMD and change folder to the Balder source folder. Then you enter the following in the CMD : 

build All

There should now be a Drops folder with the binaries you need, update with those.


Hope this helps