Building the project for AR Toolkit

Let's begin building the project with AR Toolkit. We will assume you have a SolarSystem prefab as described previously. If not, you must have exported it into a Unity package; use Assets | Import Package | Custom Package to import SolarSystem.unitypackage now. Also, import the AR Toolkit package:

  1. Import the ARToolkit asset package (for example, ARUnity5.unitypackage).
  2. Create an AR Controller. In Hierarchy, create an empty object named ARController.
  3. Go to Add Component | ARController and verify the AR Background layer is set in Video Options.

When we created our bar code markers (in the previous section), we made them AR_MATRIX_CODE_3x3 types. So, in Square Tracking Options of ARController, perform the following:

  1. Set Pattern Detection Mode to AR_MATRIX_CODE_DETECTION.
  2. Set Matrix Code Type to AR_MATRIX_CODE_3x3.

The current Square Tracking Options now look like this:

  1. Create a root object in Hierarchy:
    1. In Hierarchy, create an empty object named Root.
    2. Add Component | AROrigin.
    3. Set the Layer object to AR Background 2.
    4. Set its Transform Rotation X axis to 90 so the marker lays flat rather than upright.
  2. Create an AR Camera by following these steps:
    1. Move Main Camera to the child of Root and reset its Transform.
    2. Add Component | ARCamera.
    3. Set Culling Mask to AR Background 2.
  3. Add an AR Marker. We will tag our markers with a name and ID so it's easy to remember. The first one will be tagged solarsystem0, corresponding to the bar code ID 0 as shown ahead:
    1. On ARController, do this: Add Component | AR Marker.
    2. Set Marker Tag to solarsystem0, Type to Square Barcode, and Barcode ID to 0.
  4. Now add the solar-system-tracked object:
    1. As a child of Root, create an empty object named SolarSystem0.
    2. Add Component | AR Tracked Object and set Marker tag to solarsystem0.
    3. Drag the Assets/SolarSystem/Prefabs/SolarSystem prefab as a child of SolarSystem0.
    4. Set the SolarSystem Transform as follows: Position: 0, 0, 0, Rotation: -90, 0, 0, and Scale: 0.04, 0.04, 0.04.
    5. Select Root and (again) set Layer AR background 2. Then say OK to Yes, change children, which now includes SolarSystem.

As we saw in the previous chapter, scaling in ARToolkit is a bit different than Vuforia. Our square marker is in real-life units, about one inch or 0.04 meters. Thus, if we want our earth to be about the width of the marker, we can scale to 0.04.

The following screenshot shows the current Layer and Transform settings for the SolarSystem object:

  1. Now we need to complete the scene with a GameController, with MasterControls for the animation:
    1. In Hierarchy, create an empty object named GameController.
    2. Add Component | Master Controls.

Let's not forget to set the environmental lighting like we did earlier in the chapter

  1. Go to the Lighting panel (Window | Lighting | Lighting Settings).
  2. Set Environment Lighting Source to Color and Ambient Color to black.
  3. Also, in the Environmental Reflections group, set Intensity Multiplier to 0.

OK! Save the scene and the project. Then click on Play!

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

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