(2) Light Estimation which can estimate light strength and color. (3) Environmental Understanding to recognize floor and wall. (4) Augmented Image to recognize predefined image marker. (5) Cloud Anchor for sharing AR experience among multiple users.
realize marker less AR. (2) Light Estimation which can estimate light strength and color. (3) Environmental Understanding to recognize floor and wall. (4) Augmented Image to recognize predefined image marker. (5) Cloud Anchor for sharing AR experience among multiple users.
class PutScript : MonoBehaviour { public GameObject andy; //Variable to handle CG(Andy) void Start () { } void Update () { //(1) Detect tap. //(2) Transform 2D position to 3D position of real world. //(3) Put Andy there. } }
pointed trackable is plane if (hit.Trackable is DetectedPlane ) { //Set the position and the angle of Andy andy.transform.position = hit.Pose.position; andy.transform.rotation = hit.Pose.rotation; andy.transform.Rotate(0, 180, 0, Space.Self); //Set the anchor to fix Andy object to real space. var anchor = hit.Trackable.CreateAnchor(hit.Pose); andy.transform.parent = anchor.transform; } }
GameObject andy;//Variable to handle Andy public GameObject astronaut;// Variable to handle astronaut //Dictionary to hold pairs of marker id and virtual object Dictionary<int,GameObject> markerDic = new Dictionary<int,GameObject>(); //List of detected marker in each frame. List<AugmentedImage> markers = new List<AugmentedImage>(); void Start() { } void Update() { //Couple marker and object } }
Session.GetTrackables<AugmentedImage> (markers,TrackableQueryFilter.Updated); //Couple or remove marker and virtual object foreach (var image in markers) { int index = image.DatabaseIndex; //marker id GameObject obj = null; markerDic.TryGetValue(index, out obj);// get virtual object with id if (image.TrackingState == TrackingState.Tracking && obj == null) { //Couple marker and virtual object. } else if (image.TrackingState == TrackingState.Stopped && obj != null) { //Remove information of marker and virtual object. } } }
Session.GetTrackables<AugmentedImage> (markers,TrackableQueryFilter.Updated); //Couple or remove marker and virtual object foreach (var image in markers) { int index = image.DatabaseIndex; //marker id GameObject obj = null; markerDic.TryGetValue(index, out obj); // get virtual object with id if (image.TrackingState == TrackingState.Tracking && obj == null) { //Couple marker and virtual object. } else if (image.TrackingState == TrackingState.Stopped && obj != null) { //Remove information of marker and virtual object. } } }
Session.GetTrackables<AugmentedImage> (markers,TrackableQueryFilter.Updated); //Couple or remove marker and virtual object foreach (var image in markers){ int index = image.DatabaseIndex; //marker id GameObject obj = null; markerDic.TryGetValue(index, out obj); // get virtual object with id if (image.TrackingState == TrackingState.Tracking && obj == null) { //Coupling marker and virtual object. } else if (image.TrackingState == TrackingState.Stopped && obj != null) { markerDic.Remove(image.DatabaseIndex); Destroy(obj); } } }
AnchorScript : MonoBehaviour { public GameObject andy; // Use this for initialization void Start() { } // Update is called once per frame void Update () { Touch touch; if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } Rename class name toAnchorScript
for initialization void Start() { } public void HostAnchor() { } public void ResolveAnchor() { } void Update () { //Detect Button tapping or screen tapping //Put Andy on a plane if user taps screen. (Not button) //save current position of Andy } } Upload Environment Information Matching the space with Cloud Anchor
GoogleARCore.CrossPlatform; using UnityEngine.UI; public class AnchorScript : MonoBehaviour { public GameObject andy; Anchor currentAnchor = null; public Text txt; //Used for display the state of saving cloud anchor bool connecting = false; //state of connecting or disconnecting to CCP void Start() { } public void HostAnchor() { } Save the environmental information and cloud anchor (See next page..)
on a plane ③ Tap the Host button. ④ Bottom text will be hosting... ⑤ ID will shown if upload is success 【Next Step】 ① Shut down and reboot this app. ② Call Cloud Anchor API with ID ③ Match space with now and before ④ Andy will appear the same position. Enable saving ID in the next step
this for initialization void Start() { } public void HostAnchor() { } public void ResolveAnchor() { } void Update () { //Detect Button tapping or screen tapping //Put Andy on a plane if user taps screen. (Not button) //save current position of Andy } } Upload Environment Information Matching the space with Cloud Anchor
(connecting) { return; } connecting = true; // Read ID from text file FileInfo file = new FileInfo(filePath); StreamReader sr = new StreamReader(file.OpenRead()); string cloudAnchorId = sr.ReadLine(); sr.Close(); txt.text=cloudAnchorId; }
Host button ③ Shut down the application. ④ Reboot this application. ⑤ Tap Resolve button. ⑥ ID will appear on the bottom of screen. 【Next Step】 ① Call Cloud Anchor API with ID ③ Match space with CloudAnchor. ④ Position of Andy will reproduced. ここにIDが表示される