Adding a cube

Now we'll add an object to the Scene, just a simple cube:

  1. In the Hierarchy, select the GibraltarTarget, right-click 3D Object | Cube (or, from the Main Menu, choose GameObject | 3D Object | Cube and make it the child of the target object).

This will create a unit-sized cube, one meter on all sides. Obviously, that's much too big for our target, which is closer to 0.2 units sized. So, over in the Inspector, in the Transform component, modify the Scale to something more manageable right now, such as (0.05, 0.05, 0.05).

You may need to adjust your view in the Scene view panel, but when you do, you can see that our target object appears along with the cube, as shown here:

As described earlier in this chapter, in the topic, Changing the Scene view, to change the Scene view, use the right mouse and/or middle mouse buttons on Windows, and other controls. Also see the Unity Manual at http://docs.unity3d.com/Manual/SceneViewNavigation.html.

It's somewhat awkward to have the target standing vertically, when, in real life you might expect it to be lying horizontally (that is, flat):

  1. Select Root in the Hierarchy and, in Inspector, change its Rotation-X to 90 degrees.
  2. We can also move the cube so that it's positioned in the center of the target, more or less.

After adjusting the position of the cube in my scene to Position (0.12, 0.076, -0.037), it looks like this:

One last thing: double check that the objects under ARRoot are all on the AR background 2 layer.

  1. If you select ARRoot and, in Inspector, set its layer again, Unity will prompt you to change all of its children's layers as well. Do it.

Now we're ready to see it work. Press Play again in the Unity toolbar. Point your webcam at the printed Gibraltar image. Our cube should appear. Woot again!!!

If the app seems slow when you press Play from the Editor, this could be due to a lot of messages being printed to the console window. That can be adjusted in the AR Controller by setting the Log Level to Debug or just Error.

The following image shows me pointing my webcam at the target Gibraltar image, with Unity running the scene on the monitor in the background. In the Game panel, you can see the video feed from the webcam, with the cube added to it, in all its augmented reality awesomeness!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.36.30