Building the macOS Project

Create a new Unity Project, if you haven’t already, and call it Chapter5 to begin with. Then, load the project. Now follow these steps:

  1. The Words_Pictures file that we downloaded now needs to be located and imported into the project.
  2. Before we dive in and create the project, let’s have a look at the folders that were created upon import. Our main Assets folder will now have an Editor folder, a StreamingAssets Folder, and a Scenes folder:
  1. Inside the Editor folder, it will have another folder called Vuforia:

  1. Inside the Vuforia folder will be another folder called ImageTargetTextures:
  1. Inside the ImageTargetTextures folder, there will be a folder called Word_Pictures:
  1. Inside the Word_Pictures folder, we will have our tree image sprite:
  1. Go back to the main Assets folder and let’s take a look, starting with StreamingAssets:
  1. Inside the StreamingAssets folder will be a Vuforia folder:
  1. Inside the Vuforia folder will be two files: Words_Pictures.xml and Words_Pictures.dat:
  1. Let’s take a look at the XML file in depth to see what exactly is in it:
<?xml version="1.0" encoding="UTF-8"?>
<QCARConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="qcar_config.xsd">
<Tracking>
<ImageTarget name="Tree" size="680.000000 480. 000000" />
</Tracking>
</QCARConfig>

The XML file has the default schema for it set up, with the main tag being QCarconfig.
The next tag, which houses our image, is ImageTarget. It has the name, which we set to Tree, and the size written in floating-point values.

The XML file is very short and to the point. This file is specifically for housing the data that Vuforia needs to know, the size of the images we are using, and to be able to reference the proper file if we were to have multiple images. Let's continue with the steps:

  1. Go to the TurboSquid website and download the free Tree model that we will be using:
  1. You will need the Tree_FBX and the Tree_textures files for this next section:
  1. Navigate back to the main Assets folder and create a new folder called Models:
  1. Extract both the tree model and the textures. Copy and paste the model and textures into the Models folder inside of Unity:
  1. Delete the standard camera from the hierarchy pane.
  2. Right-click in the hierarchy pane and navigate to Vuforia; click to add an AR Camera:
  1. Click on the AR Camera in the hierarchy pane. Look over to the Inspector pane and click on Open Vuforia Configuration:
  1. Unity should ask for you to import and download more items for Vuforia and accept the Vuforia license:
  1. Copy and paste your app license key into the App License Key section:
  1. Right-click on the hierarchy pane and create an empty game object called ImageTarget.
  2. Right-click on the ImageTarget object and highlight Vuforia, and click on Image:
  1. Click on the Image object and look at the Inspector pane. Image Target Behavior should have the Type as Predefined. Database should be Words_Pictures and Image Target should be Tree:

Now we need to add our model. I am assuming you know how to set up materials for the model, so I will not go over it here. Let's continue with the steps:

  1. Drag and drop the model on to the scene. Set the x, y, and z positions to be 0,0,0, with the scale being 0.09 for the x, y, and z coordinates. The last thing to do is make it a child of the image inside the ImageTarget object:
  1. Print out the Tree text and cut the paper into four strips.
  2. Build the project for iOS by clicking on File | Build Settings. Make sure to select the Development Build check mark:
..................Content has been hidden....................

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