ARMobile brings a cross-platform API that allows a single application to run on ARCore and ARKit supported devices without platform specific code.
This article describes the necessary steps to create a basic AR application using this new extension.
- Android 7.0 (API 24) or later
- ARCore APK
- iOS 11 or later (some features will require higher versions)
You need to perform additional configuration to run your application in Android. The AndroidManifest.xml has to include the following line.
<uses-feature android:name="android.hardware.camera.ar" android:required="true" />
Create an AR Camera
In order to render the entities of the virtual scene in a real-world environment, the ARCameraRig component should be used. This component is generic for all AR implementations available in Wave Engine and is responsible to adjust the camera entity properties to the device’s physical camera.
ARCameraRig needs the ARMobileProvider component that provides specific functionality from ARCore and ARKit. It has the following configuration:
- AutoStart: Indicates whether the tracking will start automatically
- WorldAlignment: Indicates how a scene coordinate system is constructed based on real-world device motion. On ARCore only Gravity mode is supported
- TrackPosition: Indicates whether the position tracking is enabled. On ARCore position tracking cannot be disabled
- Plane Detection: Indicates how flat surfaces are detected in captured images
- Point Cloud Enabled: Indicates whether the point cloud is available
- Light Estimation Enabled: Indicates whether the light estimation is available
The light estimation feature can be easily included in the scene with the ARLightEstimation component. This component must be added to a light entity and it will modify the light properties according to the information provided by ARCore and ARKit.
The HitTest method available in the ARMobileProvider component performs a ray cast from the user’s device in the direction of the given location in the camera view. Intersections with the detected scene surface are returned, sorted by distance from the device; the nearest intersection is returned first.
The ARMobilePlaneVisualizer component can be used to visualize detected surfaces. Using the property PrefabPath, a prefab entity can be chosen to represent each plane.