ARMobile (Experimental)
ARMobile is an extension to work with augmented reality experiences, so you will need compatible devices to run this kind of applications. By now, only supported platform is Android (ARCore) but we also plan to support iOS (ARKit) in the future. AR Mobile is based on XR Platform.
Note
Please, note that Evergine.ARMobile extension is in experimental state, so it has some limitations and known issues described at Known issues.
Create a project using ARMobile
To make it easier to create ARMobile projects, we have created a new project template for Android ARCore. It works with OpenGL as graphics backend, due to limitations related with ARCore, that does not support Vulkan.
You also have to open Evergine Studio add-ons manager and add Evergine.ARMobile add-on.
Once Evergine Studio loads default scene, you need to do some changes to make it work properly for ARMobile.
- For scene 3D camera, set background color to #00000000 color and remove FreeCameraBehavior component.
- Disable SkyAtmosphere entity.
- Go to Scene Managers tab and add ARMobileManager scene manager.
Built-in AR.Mobile add-on prefabs
AR.Mobile add-on provides a set of prefabs that you can use for common AR scenarios. Expand Dependencies > Evergine.ARMobile > Prefabs. You can find following prefabs here: Cursor, Face, FeaturePoints, Image and Planes.
Cursor prefab
This prefab draws a cursor which orientation changes depending on surface detection. Drag and drop Cursor prefab to your scene and set its position to (0, 0, 0).
If you select prefab entity, will realize that apart from plane mesh components, there is a ARMobileHitTestBehavior that lets you choose about how plane collision is detected: every frame or just when user taps on the screen.
Face prefab
Face prefab allows you to use face tracking capabilities from AR platform. Drag and drop Face prefab to your scene and set its position to (0, 0, 0). Then, go to Scene Managers and mark FaceTrackingEnabled as checked.
When you use face tracking detection, rear camera is no longer used and front camera is used instead. Because of this, any other AR mode like image tracking or plane detection will not work.
If you select prefab entity, you can use attached MaterialComponent to change face material. You also can realize that there is a component called XRFaceTrackingMesh that creates face mesh from native buffers.
Feature Points prefab
This prefab uses LineBatch3D to render feature points in green, orange or red color, from more confident to less confident results. Confidence is saved in W field of Points property in XRFeaturePoints. Drag and drop FeaturePoints prefab to your scene and set its position to (0, 0, 0) and enable feature points detection in ARMobileManager scene manager.
Image prefab
With image prefab you can easily track images, and place 3D objects when those images are detected and their real world position changes. It includes a MaterialComponent that you can change to use a custom material for plane that appears once target image has been detected. Drag and drop Image prefab to your scene and set its position to (0, 0, 0) and enable image detection in ARMobileManager scene manager.
Under Dependencies > Evergine.ARMobile > AR you will find default images dataset. It includes a single image, named arimage.jpg. Dataset file is in CSV format:
- Each line represents a single image from dataset.
- First column is the relative path to the image file. Second column is expected image size in real world, measured in meters. So, for default image, we expect it to be 20 centimeters wide.
- For each one of the images, we use file name (without extension) as image name, that we internally register in dataset database. This is why default ImageName value for XRImageTracking component in Image prefab is arimage, as this is the file name for default image in Evergine.ARMobile add-on.
If you want a custom set of images, just create your own dataset within your project folders. Then, you have to change ImageDataSetPath value in ARMobileManager scene manager to meet your dataset path. To ensure your images are optimal for tracking, please follow platform recommendations:
- Android: use arcoreimg tool to evaluate your images quality.
Planes prefab
We provide this prefab to visualize detected planes. For this, drag and drop Planes prefab to your scene and set its position to (0, 0, 0). Then, go to Scene Managers and select a plane detection mode.
Prefab counts with a XRPlaneRenderer that lets you change the material used to draw the planes.
Known issues
As ARMobile extension is in experimental state, you could find some issues while running applications. This is a list of known issues:
- Application crashes when returning back from background.
- You will find, in Debug configuration, some Google.AR.Core.Exceptions.DeadlineExceededException exceptions that are written to output console, depending on ARMobileManager configuration.
- When dragging AR prefabs to the scene, you need to ensure that their Transform3D location is set to (0, 0, 0) position. Any other position could provoke an OpenGL rendering issue that results in a full screen green texture.