RoadToTheMetaverse / R2mv12SpatialAnchorsProject

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

R2MV

Episode 12 - Build geolocated and social experiences in AR

About this project

Part of the Road to Metaverse, Creator Series, this demo was used in Episode 12 to learn how to build a geolocated AR exeprience, using Azure Spatial Anchors!

Synopsis

Place persistent content in the realworld, that can be found/located later. Using AR Foundation and Azure Spatial Anchors, this demo will show how to place and retrieve anchors!




Demo

THe main scene to explore is under R2mv12Assets/Scenes/

R2mvSpatialAnchorsDemo

Editor screenshot


Setup Azure Credetials

Before using this demo application, the SpatialAnchorConfig details must be added:

  • Account ID
  • Account Key
  • Account Domain

To setup your credentials on the Azure Portal, check out these instructions.


Demo Walkthrough

All code is contained in the SpatialAnchorsDemo component. Using the Azure SDK SpatialAnchorManager to manage authentication and interface with Azure backend services.


Spatial Anchors Demo

  • Defined 4 app states
    • Start
    • Placing Anchor
    • Creating Spatial Anchor
    • Locating Anchor
  • Created 4 UI views for the app’s UX
  • References
    • The prefab to use as visual anchor
    • SpatialAnchorManager
    • ARRaycastManager
  • Public API -> handle user requests for
    • Restart
    • PlaceAnchor
    • SaveAnchor
    • LocateAnchor
    • ClearHistory
  • Demo Lifecycle -> Manages the state of the application
    • Initialization
    • Update elements based on Demo State
    • Update UI
  • Spatial Anchor Event Handlers -> Interface with the SpatialAnchorManager
    • Mostly event handler (Delegates)
    • CloudManagerOnAnchorLocated -> Called when a cloud anchor is located! Use LocateAnchorStatus.Located to place an AR Anchor.
    • Show AddFoundCloudSpatialAnchor CloudNativeAnchor -> Azure SDK component CloudToNative(anchor) handles placing the anchor in the correct position and rotation!
  • History and Anchor creation management
    • CreateSpatialAnchor
      • Complex method
      • Responsible creating the Azure Anchor using the local AR Foundation anchor
      • Handles communication with backend service for visually positioning anchors and saving the data on Azure
      • Waits for IsReadyForCreate
      • Uses CreateAnchorAsync
    • LoadSpatialAnchorHistory
    • SaveSpatialAnchorHistory
    • System uses the same data structure as the Google Cloud Anchor demo!
      • SpatialAnchorHistory
      • SpatialAnchorHistoryCollection
      • PlayerPrefs and JSON serialization / de-serialization



Resources

Need more info, or have some questions? Head over to our forums.

About


Languages

Language:C# 62.1%Language:ShaderLab 32.4%Language:HLSL 5.5%