Exemple #1
0
        private void Awake()
        {
            tracker         = Session.GetComponentInChildren <ImageTrackerFrameFilter>();
            cloudRecognizer = Session.GetComponentInChildren <CloudRecognizerFrameFilter>();

            if (UseOfflineCache)
            {
                if (string.IsNullOrEmpty(OfflineCachePath))
                {
                    OfflineCachePath = Application.persistentDataPath + "/CloudRecognizerSample";
                }
                if (!Directory.Exists(OfflineCachePath))
                {
                    Directory.CreateDirectory(OfflineCachePath);
                }
                if (Directory.Exists(OfflineCachePath))
                {
                    var targetFiles = Directory.GetFiles(OfflineCachePath);
                    foreach (var file in targetFiles)
                    {
                        if (Path.GetExtension(file) == ".etd")
                        {
                            LoadOfflineTarget(file);
                        }
                    }
                }
            }
        }
Exemple #2
0
 private void Awake()
 {
     vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
     sparse    = Session.GetComponentInChildren <SparseSpatialMapWorkerFrameFilter>();
     dense     = Session.GetComponentInChildren <DenseSpatialMapBuilderFrameFilter>();
     TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, false, false, true, false);
 }
Exemple #3
0
        private void Awake()
        {
            videoCamera               = arSession.GetComponentInChildren <VideoCameraDevice>();
            cameraRenderer            = arSession.GetComponentInChildren <CameraImageRenderer>();
            cubeTexture               = CubeRenderer.material.mainTexture;
            targetTextureEventHandler = (camera, texture) =>
            {
                if (texture)
                {
                    CubeRenderer.material.mainTexture = texture;
                }
                else
                {
                    CubeRenderer.material.mainTexture = cubeTexture;
                    if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal)
                    {
                        CubeRenderer.transform.localScale = new Vector3(-1, -1, 1);
                    }
                    else
                    {
                        CubeRenderer.transform.localScale = new Vector3(1, 1, 1);
                    }
                }
            };

            videoCamera.DeviceOpened += () =>
            {
                if (videoCamera.Device == null)
                {
                    return;
                }
                var flip = videoCamera.Device.type() == CameraDeviceType.Front ? arSession.HorizontalFlipFront : arSession.HorizontalFlipNormal;
                FlipSwitch.isOn = flip == ARSession.ARHorizontalFlipMode.World;
            };
        }
 private void Awake()
 {
     vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
     sparse    = Session.GetComponentInChildren <SparseSpatialMapWorkerFrameFilter>();
     TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, false, false, true, false);
     ImageTarget.TargetFound += () => { found = true; };
     ImageTarget.TargetLost  += () => { found = false; };
 }
Exemple #5
0
        private void Awake()
        {
            objectTracker = Session.GetComponentInChildren <ObjectTrackerFrameFilter>();
            cameraDevice  = Session.GetComponentInChildren <VideoCameraDevice>();

            objectTarget = GameObject.Find("ObjectTarget").GetComponent <ObjectTargetController>();
            AddTargetControllerEvents(objectTarget);
        }
Exemple #6
0
        private void Start()
        {
            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }

            sparse    = Session.GetComponentInChildren <SparseSpatialMapWorkerFrameFilter>();
            vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
            TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, false, false, true, false);

            if (string.IsNullOrEmpty(MapController.MapManagerSource.ID) || string.IsNullOrEmpty(MapController.MapManagerSource.Name))
            {
                throw new UIPopupException("Map ID or Name NOT set, please set MapManagerSource on: " + MapController + Environment.NewLine +
                                           "To create SpatialMap, use <SpatialMap_SparseSpatialMap> sample." + Environment.NewLine +
                                           "To get Map ID and Name, use EasyAR Develop Center (www.easyar.com) -> SpatialMap -> Database Details." + Environment.NewLine +
                                           "Map ID is used when loading, it can be used to share maps among devices.", 100);
            }

            MapController.MapLoad += (map, status, error) =>
            {
                GUIPopup.EnqueueMessage("Load map {name = " + map.Name + ", id = " + map.ID + "} into " + sparse.name + Environment.NewLine +
                                        " => " + status + (string.IsNullOrEmpty(error) ? "" : " <" + error + ">"), status ? 3 : 5);

                if (!status)
                {
                    return;
                }

                GUIPopup.EnqueueMessage("Notice: load map (only the first time each map) will trigger a download in this sample." + Environment.NewLine +
                                        "Statistical request count will be increased (more details on EasyAR website)." + Environment.NewLine +
                                        "Map cache is used after a successful download." + Environment.NewLine +
                                        "Map cache will be cleared if SparseSpatialMapManager.clear is called or app uninstalled.", 5);
            };

            MapController.MapLocalized += () =>
            {
                GUIPopup.EnqueueMessage("Localized map {name = " + MapController.MapInfo.Name + "}", 3);
            };

            MapController.MapStopLocalize += () =>
            {
                GUIPopup.EnqueueMessage("Stopped localize map {name = " + MapController.MapInfo.Name + "}", 3);
            };

            sparse.Localizer.startLocalization();
        }
Exemple #7
0
        private void Awake()
        {
            tracker         = Session.GetComponentInChildren <ImageTrackerFrameFilter>();
            cloudRecognizer = Session.GetComponentInChildren <CloudRecognizerFrameFilter>();

            if (UseOfflineCache)
            {
                if (string.IsNullOrEmpty(OfflineCachePath))
                {
                    OfflineCachePath = Application.persistentDataPath + "/CloudRecognizerSample";
                }
                if (!Directory.Exists(OfflineCachePath))
                {
                    Directory.CreateDirectory(OfflineCachePath);
                }
                if (Directory.Exists(OfflineCachePath))
                {
                    var targetFiles = Directory.GetFiles(OfflineCachePath);
                    foreach (var file in targetFiles)
                    {
                        if (Path.GetExtension(file) == ".etd")
                        {
                            LoadOfflineTarget(file);
                        }
                    }
                }
            }

            cloudRecognizer.CloudUpdate += (status, targets) =>
            {
                if (cloudStatus != status)
                {
                    Debug.LogFormat("Cloud status changed: {0} with {1} targets", status, targets.Count);
                    cloudStatus = status;
                }

                foreach (var target in targets)
                {
                    var uid = target.uid();
                    if (loadedCloudTargetUids.Contains(uid))
                    {
                        continue;
                    }

                    LoadCloudTarget(target.Clone() as ImageTarget);
                }
            };
        }
Exemple #8
0
    private void Awake()
    {
        session     = FindObjectOfType <ARSession>();
        mapWorker   = FindObjectOfType <SparseSpatialMapWorkerFrameFilter>();
        videoCamera = session.GetComponentInChildren <VideoCameraDevice>();

#if UNITY_EDITOR
        GameObject.Find("EasyAR_SparseSpatialMapWorker").SetActive(false);
#endif

        PropDragger.CreateObject += (gameObj) =>
        {
            if (gameObj)
            {
                gameObj.transform.parent = mapData.Controller.transform;
                mapData.Props.Add(gameObj);
            }
        };
        PropDragger.DeleteObject += (gameObj) =>
        {
            if (gameObj)
            {
                mapData.Props.Remove(gameObj);
            }
        };
    }
Exemple #9
0
        private void Awake()
        {
            vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
            vioCamera.DeviceCreated += () =>
            {
                if (vioCamera.Device.Type() == typeof(MotionTrackerCameraDevice))
                {
                    TouchControl.TurnOn(TouchControl.gameObject.transform, Session.Assembly.Camera, false, false, true, true);
                }
                else
                {
                    TouchControl.TurnOn(TouchControl.gameObject.transform, Session.Assembly.Camera, true, true, true, true);
                    UnlockPlaneButton.gameObject.SetActive(false);
                }
            };

            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }
        }
Exemple #10
0
        private void Awake()
        {
            vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
            dense     = Session.GetComponentInChildren <DenseSpatialMapBuilderFrameFilter>();

            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }
        }
        private void Awake()
        {
            vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
            sparse    = Session.GetComponentInChildren <SparseSpatialMapWorkerFrameFilter>();
            TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, false, false, true, false);

            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }
        }
    private void Awake()
    {
#if UNITY_EDITOR
        GameObject.FindObjectOfType <VIOCameraDeviceUnion>().enabled = false;
#endif
        session     = FindObjectOfType <ARSession>();
        mapWorker   = FindObjectOfType <SparseSpatialMapWorkerFrameFilter>();
        videoCamera = session.GetComponentInChildren <VideoCameraDevice>();
    }
        private void Awake()
        {
            objectTracker = Session.GetComponentInChildren <ObjectTrackerFrameFilter>();
            cameraDevice  = Session.GetComponentInChildren <VideoCameraDevice>();

            objectTarget = GameObject.Find("ObjectTarget").GetComponent <ObjectTargetController>();
            AddTargetControllerEvents(objectTarget);

            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }
        }
Exemple #14
0
        private void Awake()
        {
            videoCamera               = arSession.GetComponentInChildren <VideoCameraDevice>();
            cameraRenderer            = arSession.GetComponentInChildren <CameraImageRenderer>();
            cubeTexture               = CubeRenderer.material.mainTexture;
            targetTextureEventHandler = (camera, texture) =>
            {
                if (texture)
                {
                    CubeRenderer.material.mainTexture = texture;
                }
                else
                {
                    CubeRenderer.material.mainTexture = cubeTexture;
                    CubeRenderer.transform.localScale = new Vector3(1, 1, 1);
                }
            };

            videoCamera.DeviceOpened += () =>
            {
                if (videoCamera.Device == null)
                {
                    return;
                }
                var flip = videoCamera.Device.type() == CameraDeviceType.Front ? arSession.HorizontalFlipFront : arSession.HorizontalFlipNormal;
                FlipSwitch.isOn = flip == ARSession.ARHorizontalFlipMode.World;
            };

            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }
        }
Exemple #15
0
    private void Awake()
    {
        imageTracker = Session.GetComponentInChildren <ImageTrackerFrameFilter>();
        cameraDevice = Session.GetComponentInChildren <VideoCameraDevice>();

        int power = 1;

        // targets from scene
        foreach (ImageTargetController control in Resources.FindObjectsOfTypeAll(typeof(ImageTargetController)))
        {
            imageTargetControllers.Add(control, false);
            AddTargetControllerEvents(control);
            controllerMap.Add(control, (int)Math.Pow(2, power)); // set controller to a bit number (power of 2)
            power++;
        }
        // calculate combination bits for each combo of symbols that trigger an artifact
        foreach (TwoSymbolArtifactLink link in linkMap)
        {
            int bit1 = controllerMap[link.symbol1];
            int bit2 = controllerMap[link.symbol2];
            link.comboBit = bit1 | bit2;
        }
    }
Exemple #16
0
 private void Awake()
 {
     vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
     vioCamera.DeviceCreated += () =>
     {
         if (vioCamera.Device.Type() == typeof(MotionTrackerCameraDevice))
         {
             TouchControl.TurnOn(TouchControl.gameObject.transform, Session.Assembly.Camera, false, false, true, true);
         }
         else
         {
             TouchControl.TurnOn(TouchControl.gameObject.transform, Session.Assembly.Camera, true, true, true, true);
             UnlockPlaneButton.gameObject.SetActive(false);
         }
     };
 }
Exemple #17
0
        private void Awake()
        {
            vioCamera          = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
            controllerNamecard = GameObject.Find("ImageTarget").GetComponent <ImageTargetController>();
            TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, true, true, true, true);

            var launcher = "AllSamplesLauncher";

            if (Application.CanStreamedLevelBeLoaded(launcher))
            {
                var button = BackButton.GetComponent <Button>();
                button.onClick.AddListener(() => { UnityEngine.SceneManagement.SceneManager.LoadScene(launcher); });
            }
            else
            {
                BackButton.gameObject.SetActive(false);
            }
        }
Exemple #18
0
 private void Awake()
 {
     vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
     TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, true, true, true, true);
 }
Exemple #19
0
 private void Awake()
 {
     tracker            = Session.GetComponentInChildren <SurfaceTrackerFrameFilter>();
     controllerNamecard = GameObject.Find("ImageTarget").GetComponent <ImageTargetController>();
     TouchControl.TurnOn(TouchControl.transform, Camera.main, false, false, true, true);
 }
Exemple #20
0
 private void Awake()
 {
     vioCamera          = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
     controllerNamecard = GameObject.Find("ImageTarget").GetComponent <ImageTargetController>();
     TouchControl.TurnOn(TouchControl.gameObject.transform, Camera.main, true, true, true, true);
 }
Exemple #21
0
 private void Awake()
 {
     vioCamera = Session.GetComponentInChildren <VIOCameraDeviceUnion>();
     dense     = Session.GetComponentInChildren <DenseSpatialMapBuilderFrameFilter>();
 }
Exemple #22
0
 private void Awake()
 {
     tracker = Session.GetComponentInChildren <SurfaceTrackerFrameFilter>();
     TouchControl.TurnOn(TouchControl.transform, Camera.main, false, false, true, true);
 }