Can't compile Balder Silverlight samples

Dec 28, 2010 at 8:49 PM

I'm playing with SLAR and trying to use Balder as the rendering engine, starting from the example in the SLAR toolkit. I'm having a lot of trouble with the Balder part though. I can see a good mix of Balder samples at http://www.ingebrigtsen.info/Balder/SampleBrowser/TestPage.html but when I try to replicate that code in my own application, it won't compile.

I'm using Balder 0.8.8.9, Silverlight 4, Microsoft Visual Web Developer 2010 Express, SLARToolkit 1.0.2.0.

There have been numerous minor issues, which lead me to suspect that the Balder samples are built against a different version of Balder to the one I'm using.

For example, the Programatic/teapot sample shows how to programatically load a mesh from an ASE file. It includes statements like this:

    ContentManager.AssetsRoot = "Assets";

and

    _teapot = ContentManager.Load<Mesh>("teapot.ase");

Neither of these statements compile in my environment. The class reference to ContentManager won't compile unless I add a "using Balder.Content" declaration (the sample doesn't have one). Having referenced the class correctly the samples still won't compile because the class doesn't defined a static property "AssetsRoot" or a static method "Load<Mesh>"; they're instance methods. I'd need to obtain an instance of ContentManager to access them, and so far I haven't worked out how to do that - the only constructor takes several arguments that I don't recognise and can't provide.

These are only examples of the sort of snags I've run into. I don't see how the samples could compile against Balder 0.8.8.9. Are they coded against a different API version?

As an aside - I haven't found any API documentation at all - I'm working from the samples, and the metadata from the DLL. Does any API documentation exist? It would make this learning experience much easier if so.

Dec 29, 2010 at 12:55 AM

Mystery partly solved. In the sample application, ContentManager refers to an instance variable of the base class Game, and not to the class Balder.Content.ContentManager. Since my own application subclasses UserControl, it doesn't inherit this instance variable and I need to reference it as Game.ContentManager.

There were a few other minor compilation errors (can't assign a value to Camera.ProjectionMatrix etc) which probably have a similar cause.

Coordinator
Dec 29, 2010 at 6:09 AM

Hi,

seems like the author of SLARToolkit hasn't updated for the latest version of Balder. 

Documentation is under way, for now the tutorials on the frontpage the sample browser and forum is the best we can offer.

 

As for your last problem, the ProjectionMatrix - you can't set that. But, if you want to control the projection matrix of the camera you can create your own camera class inheriting from the Balder Camera and override the ProjectionMatrix property, or override the SetupProjection() method of the Camera and create your own.

Dec 29, 2010 at 1:34 PM

To be honest I don't understand why the SLAR Toolkit demo is trying to set the ProjectionMatrix but it's doing it like this:

      private void InitializeDetector(int width, int height)
      {
         // Load App resources and init AR
         arDetector = new BitmapMarkerDetector();
         var marker = Marker.LoadFromResource("data/Marker_SLAR_16x16segments_80width.pat", 16, 16, 80.0);
         arDetector.Initialize(width, height, Game.Camera.Near, Game.Camera.Far, marker);
         Game.Camera.ProjectionMatrix = arDetector.Projection.ToBalderMatrix();
      }

That doesn't compile; I can 'get' the ProjectionMatrix property but not 'set' it.

The ProjectionMatrix isn't described anywhere; what does it do - why would the SLAR demo need to set it during detector initialisation? I would guess it's derived from the position, rotation and orientation of the camera, but I don't understand the purpose of setting these before the marker has been detected.

With the assignment to Camera.ProjectionMatrix removed the SLAR demo seems to almost work - the Balder scene is rotated correctly but the translation is not scaled correctly and doesn't follow the marker accurately. I'm still struggling to figure out how the SLAR demo is intended to work - the code doing geometry manipulation seems to be riddled with arbitrary-seeming offsets, reflections and rotations which I wasn't expecting to find. Perhaps it's a cunning solution to the problem that just needs a few comments to explain what's going on, but I'm not convinced that the logic is fundamentally sound. Trying to figure out how it's intended to work is an uphill struggle though, because I don't understand how 3D geometry works in Balder either, and it doesn't seem to be explained anywhere.

Have you seen the source for SLAR Balder demo? Is it handling Balder geometry correctly in your opinion?

 

Coordinator
Dec 30, 2010 at 10:01 PM
Hi, There has been quite a few requests lately about issues with the SLARtoolkit Balder demo. I have not yet had a chance to look at the demo code myself, but I'll try and squeeze in some time for it soon.
Jan 13, 2011 at 1:15 PM
Edited Jan 13, 2011 at 1:43 PM

Hi,

I haven't looked into the latest Balder build 0.8.8.9. I guess Balder changed some interfaces. Maybe the Matrix class uses fixed properties now and not an indexer anymore.  
I don't update to every Balder build. I just don't have the time and I won't have the time during the next weeks. What's wrong with Balder 0.8.8.8? It's working fine for me.

FYI: The projection matrix describes your camera, therefore the AR camera must be set once at startup. You can think of it as a calibration to align the real world as seen through your webcam with Balder's artificial world. For better performance this is only done in the initialization step. The detection provides the world matrix (trans, rot, scale, ...).

 

- Rene Schulte/SLARToolkit