Scene Creation
- Overview
- This tutorial covers the creation and testing of an augmented reality scene using the Unity Engine with the Vuforia Computer Vision Platform.
- Dependencies
- Unity Engine 5 (32 Bit).
- Vuforia 5 plugin for Unity.
- Image to utilize as an Image Target.
- Scene Creation
- Open Unity Engine.
- Select New Project.
- Enter a name for the new project and select storage location.
- Click the Create Project button.
- Import Vuforia
- Select ASSETS from the main menu bar.
- Select ‘Import Package’.
- Select ‘Custom Package’.
- Navigate to and select the previously downloaded Vuforia plugin package, then click on the ‘Open’ button.
- Click on the ‘Import’ button.
- Under the Assets heading in the Project View there should be a visible Vuforia directory.
- Import Vuforia License and Image Tracker.
- https://developer.vuforia.com/.
- Log into a developer account.
- Create New License Key.
- Select ‘Develop’ from main menu.
- Select the License Manager Tab.
- Click on the ‘Add License Key’ button.
- Enter a name, click ‘Next’, and accept the Developer Agreement.
- Select the newly created key to view license information.
- Leave license key details page open as this information will be required for the Vuforia Augmented Reality camera.
- Create new Image Tracker.
- Select the Target Manager Tab.
- Click on the ‘Add Database’ button.
- Name the new database.
- Select ‘Device’ storage (Cloud storage requires subscription).
- Click on ‘Create’ button.
- Select the newly created database.
- Click on the ‘Add Target’ button.
- Select the Image Target.
- Reselect the Target Manager Tab (page does not refresh after image upload).
- Reselect the appropriate database.
- Click on the ‘Download Dataset’ button.
- Select ‘Unity Editor’ version and click ‘Download’
- Import Tracker
- Select ASSETS from the main menu bar.
- Select ‘Import Package’.
- Select ‘Custom Package’.
- Navigate to and select the previously downloaded image tracker unity package, then click the ‘Open’ button.
- Click on the ‘Import’ button.
- Import 3D Model from Unity Asset Store
- Select WINDOW from Unity’s main menu bar.
- Select ASSET STORE.
- Expand the window pane until the right-side navigation column is visible (Optionally, closing the Inspector is equivalent).
- Select a 3d Model.
- Browse and select any arbitrary and suitable model
- Click on the ‘Download’ button, then click on the ‘Import’ button
- The package should now be visible in the Project’s Assets View.
- Component Configuration
- Remove all default components from the scene.
- Delete the Main Camera and Directional Light default components.
- ARCamera
- From the Assets View, select the Vuforia directory. Next select the PreFab directory.
- Click-and-drag the ARCamera component into the scene.
- Retrieve the License Key information from the Vuforia developer console.
- Copy-and-Paste the License Key details from the vuforia site into the ARCamera’s App License Key field.
- Locate the ‘Database Load Behaviour’ field in the Inspector.
- Select the custom imported tracker database.
- Select ‘Activate’ to initialize the database for ARCamera use.
- ImageTarget
- From the Assets View, select the Vuforia directory. Next select the PreFab directory.
- Click-and-drag the ImageTarget component into the scene.
- Locate the ‘Image Target Behaviour’ field in the Inspector.
- Select the appropriate dataset.
- Select the appropriate image target.
- Model
- From the Assets View, select the model that was previously downloaded from the Asset Store.
- Locate the model’s prefab object or *.fbx file and drag it into the Hierarchy tab in order to drop it onto the ImageTarget component.
- Dragging and Dropping the model object onto the ImageTarget registers the model as a child object of the parent (ImageTarget) object. In other words, this act associates the model with the target.
- Locate the model’s prefab object or *.fbx file and drag it into the Hierarchy tab in order to drop it onto the ImageTarget component.
- From the Assets View, select the model that was previously downloaded from the Asset Store.
- Remove all default components from the scene.
- Testing - Requires a webcam and Unity 32-Bit
- Physically print the image tracker for real-world use, if necessary.
- Enable a local webcam that must be connected to the PC running Unity.
- Direct the camera’s imaging sensor towards the image target.
- Press CTRL+P or click the small ‘Play’ button just above the scene in order to begin testing.
- Conclusion
- This tutorial has demonstrated the use of Vuforia Computer Vision within the Unity Engine to create a simple Augmented Reality experience.