This project is read-only.

Tutorial 8 - tracking Toolbar

Dec 17, 2010 at 6:07 PM

Hey guys,

I'm just trying to force tutorial 8 to track the Toolbar Marker Array. Unfortunately it doesn't show my 3D model. Does anybody know why? (code is attached)

It seems that it has some troubles with the Array Config file (Toolbox.txt), because I tried the same with a self-created one. BTW: The code compiles well. No errors.




// Loades textured model of an object
            ModelLoader loader2 = new ModelLoader();
            Model toolbarModel = (Model)loader2.Load("", "test2");

            // Create a geometry node for Schafkopf table
            GeometryNode toolbarNode = new GeometryNode("Tool");

            toolbarNode.Model = toolbarModel;

            // Create a marker node to track a toolbar marker array.

            ids = new int[2];
            ids[0] = 29;
            ids[1] = 30;

            toolbarMarkerNode = new MarkerNode(scene.MarkerTracker, "Toolbar.txt", ids);

            // Table transformation
            TransformNode toolbarTransNode = new TransformNode();
            toolbarTransNode.Translation = new Vector3(0, 0, 0.1f);
            toolbarTransNode.Scale = new Vector3(0.1f);
            toolbarTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(270));

            Material toolbarMaterial = new Material();
            toolbarMaterial.Diffuse = new Vector4(1, 1, 1, 1);
            toolbarMaterial.Specular = Color.White.ToVector4();
            toolbarMaterial.SpecularPower = 10;

            toolbarNode.Material = toolbarMaterial;

            // Now add the above nodes to the scene graphe in the appropriate order.
            // Note that only the nodes addes below the marker node are affected by the marker transformation.


Dec 19, 2010 at 11:33 PM

The code looks correct. 

There a few possibilities you're not seeing the model.

First of all, you want to make sure the marker array is being tracked. You can check that by checking toolbarMarkerNode.MarkerFound is true in your Draw(...) call when the array is visible in the video.

Once you know the array is being tracked, the next thing to check is that your model attached on the marker is neither too small or too big. In either case, you will see nothing. Check your model dimension by getting Vector3Helper.GetDimensions(toolbarModel.MinimumBoundingBox). Then compare this with your marker array dimension defined your .txt file. Also, you're applying 0.1f scale to your model, so your if model dimension * scale is too small or too big compared to your marker array dimension, then it's a problem.

One way to automatically make your model match the size of the marker array is, make your Scale to be  

(marker array dimension in X) / Vector3Helper.GetDimensions(toolbarModel.MinimumBoundingBox).X

Note that this will only consider in the X dimension, but you can change it to use the overall size if you like.


Dec 20, 2010 at 12:20 AM

Ohan, thanks for your reply.

In the meantime I found the mistake. It was a Config File issue. The marker was tracked, but it didn't show the model, because the coordinates in the Config file were wrong. The only mistake was, that I'm using German language settings. So the coordinates in the config file were generated with a "," instead of a "." as a seperator. I fixed this and now everything is running well.