Week 3: Markerless Introduction
AR Markerless Portals
On thursdays’ Mix1 session we got introduced to the next assignment, a markerless AR application with educational purpose so we started by thinking of some ideas. We decided to work on AR ports that will transport you to another city, in this case Paris and London, so when a plane is detected it will appear two doors that will act as portals to the respective cities.
For our application we chose to work with ARCore SDK so we downloaded and imported the package. At the beginning, Unity showed a lot of errors when we first added the ARCore SDK, so we had to install additional packages from the Package Manager which are: Multiplayer HLAPI, and XR Legacy Input Helper. The next step was to create a Scene that we named HelloAR, and later we switched platform to Android under Build settings. To do this steps we followed the steps from ARCore official webpage: https://developers.google.com/ar/develop/unity/quickstart-android.
Now that the set up was done, it was time to start the project. First we added an empty gameObject named ARCoreDevice with a camera attached to it. We also added a ARCore Session Config, which is responsible for managing the AR core session, and we added it to the ArCoreDevice. We also added a Tracked Pose driver and AR Core background render, which is responsible for rendering the camera image to the screen, to the camera that we set up and we add the ARCoreBackground, which is provided by the sdk, as the BackgroundMaterial like the following:
Creating ARController to detect planes and show the grid on new planes
To detect a plane we started by adding an ARcontroller Script that uses GoogleARCore, this script keeps track of the detected planes. We made a new Game Object that contained this new script and we also created a cube prefab called ‘Grid’ and we attached a Script to it called GridVisualizer by copy paste the code from one of the examples tha ARCore facilitates, we found it under :
Assets\GoogleARCore\Examples\Common\Scripts\DetectedPlaneVisualizer.cs
This grid prefab is the mesh/grid material that shows up when a new plane is detected.
We opened again the ARController to add the code that will instantiate the grid.
Next we did was to add the Grid to the ARController
Adding the portal and positioning it
Now that planes could be detected, a portal should appear, so the next step was to import the door model into unity. Once we had that, we opened once again ARController and added the code to make the portal appear, and it’s explained in the code snippet:
The Portal was also added to the ARControler preferences Menu
At this point we had a portal appearing when detecting a plane and decided to continue next week making the connection to the virtual world.
Comments
Post a Comment