Example #1
0
        //!
        //! Handle submited config widget
        //! This triggers the server adapter to request a scene
        //! @param widget     source widget
        //!
        public void configWidgetSubmit(ConfigWidget widget)
        {
            ui.hideConfigWidget();

            ui.switchLayoutMainMenu(layouts.DEFAULT);

            ui.resetMainMenu();

            TouchInput input = inputAdapter.GetComponent <TouchInput>();

            if (input)
            {
                input.enabled = true;
            }

            hideARWidgets();

            // request progress bar from UI and connect listener to server adapter
            RoundProgressBar progressWidget = ui.drawProgressWidget();

            // Connect set value to progress event
            serverAdapter.OnProgressEvent.AddListener(progressWidget.SetValue);
            // Connect scene load complete to progress finish event
            progressWidget.OnFinishEvent.AddListener(this.sceneLoadCompleted);

            // init server adapter
            serverAdapter.initServerAdapterTransfer();
        }
Example #2
0
File: UI.cs Project: iVerb/VPET
        public void acceptARConfig()
        {
            GameObject arConfigWidget = GameObject.Find("GUI/Canvas/ARConfigWidget");

            arConfigWidget.SetActive(false);
            //reset kinematic properties to previous values
            mainController.lockScene = false;

            InputAdapter inputAdapter = GameObject.Find("InputAdapter").GetComponent <InputAdapter>();

            TouchInput input = inputAdapter.GetComponent <TouchInput>();

            if (input)
            {
                input.enabled = true;
            }

            mainController.hideARWidgets();
        }
Example #3
0
        void Awake()
        {
            mainController = GameObject.Find("MainController").GetComponent <MainController>();


            // declare touch input
            // #if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN) && !UNITY_EDITOR
#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN) && !UNITY_EDITOR
            touchInput = gameObject.AddComponent <TouchInput>();
            mainController.TouchInputActive = true;
#endif


            // declare mouse input
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            mouseInput = gameObject.AddComponent <MouseInput>();
            mainController.MouseInputActive = true;
#endif
        }
Example #4
0
        void Awake()
        {
            mainController = GameObject.Find("MainController").GetComponent <MainController>();
#if USE_AR
            arFoundation = GameObject.Find("Cameras").GetComponent <ARFoundationController>();
#endif
            scene    = GameObject.Find("Scene");
            helpMenu = GameObject.Find("GUI/Canvas/HelpScreen").GetComponent <HelpScreen>();

            // declare touch input
            // #if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN) && !UNITY_EDITOR
#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN) && !UNITY_EDITOR
            touchInput = gameObject.AddComponent <TouchInput>();
            mainController.TouchInputActive = true;
#endif


            // declare mouse input
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            mouseInput = gameObject.AddComponent <MouseInput>();
            mainController.MouseInputActive = true;
#endif
        }
Example #5
0
        public void ToggleArMode(bool active)
        {
            arMode = active;
            ui.setupSecondaryMenu();
#if USE_ARKIT
            GameObject root           = GameObject.Find("Scene");
            GameObject arPlanes       = GameObject.Find("ARPlanes");
            GameObject arKit          = GameObject.Find("ARKit");
            TouchInput input          = inputAdapter.GetComponent <TouchInput>();
            GameObject arConfigWidget = GameObject.Find("GUI/Canvas/ARConfigWidget");
            GameObject rootScene      = SceneLoader.scnRoot;

            if (m_anchorPrefab == null)
            {
                m_anchorPrefab = Resources.Load("VPET/Prefabs/AnchorModifier", typeof(GameObject)) as GameObject;
            }

            if (input)
            {
                input.enabled = !active;
            }
#endif
            if (active)
            {
#if USE_TANGO
                sceneAdapter.HideGeometry();
                tangoApplication.m_enableVideoOverlay           = true;
                tangoApplication.m_videoOverlayUseTextureMethod = true;
                TangoARScreen tangoArScreen = Camera.main.gameObject.GetComponent <TangoARScreen>();
                if (tangoArScreen == null)
                {
                    tangoArScreen = Camera.main.gameObject.AddComponent <TangoARScreen>();
                }
                tangoArScreen.enabled = true;
#elif USE_ARKIT
                //avoids object updates while placing, scaling, rotating scene in AR setup
                lockScene = true;
                // reset camera
                cameraAdapter.globalCameraReset();
                //resetCameraOffset();
                Camera.main.transform.position = Vector3.zero;
                Camera.main.transform.rotation = Quaternion.identity;
                //Camera.main.fieldOfView = 60;
                //Camera.main.nearClipPlane = 0.1f;
                //Camera.main.farClipPlane = 100000;
                // enable video background

                ARScreen arkitScreen = Camera.main.gameObject.GetComponent <ARScreen>();
                if (arkitScreen == null)
                {
                    arkitScreen = Camera.main.gameObject.AddComponent <ARScreen>();
                }

                if (arKit)
                {
                    ARKitController arController = arKit.GetComponent <ARKitController>();
                    if (arController)
                    {
                        arController.setARMode(true);
                    }
                }

                // enable plane alignment
                if (root)
                {
                    ARPlaneAlignment hitTest = root.GetComponent <ARPlaneAlignment>();
                    if (hitTest == null)
                    {
                        hitTest = root.AddComponent <ARPlaneAlignment>();
                        hitTest.m_HitTransform = root.transform;
                    }
                }
                // enable plane visualisation
                if (arPlanes)
                {
                    ARPlane arPlaneComponent = arPlanes.GetComponent <ARPlane>();
                    if (arPlaneComponent == null)
                    {
                        arPlaneComponent = arPlanes.AddComponent <ARPlane>();
                    }
                }
                // create anchor modifier
                if (m_anchorModifier == null)
                {
                    m_anchorModifier = GameObject.Instantiate(m_anchorPrefab);
                    m_anchorModifier.transform.position = Vector3.zero;
                    m_anchorModifier.layer = LayerMask.NameToLayer("RenderInFront");
                    foreach (Transform child in m_anchorModifier.transform)
                    {
                        child.gameObject.layer = 8;
                    }
                    m_anchorModifier.transform.localScale = Vector3.zero;
                    m_anchorModifier.name = "ARModifier";
                    if (root)
                    {
                        m_anchorModifier.transform.SetParent(root.transform, false);
                    }
                }
                ui.hideConfigWidget();
                //hide scene while placing AR anchor
                //rootScene.SetActive(false);
                arConfigWidget.SetActive(true);
                SetSceneScale(VPETSettings.Instance.sceneScale);
                //arConfigWidget.transform.Find("scale_value").GetComponent<Text>().text;

                //initalize ar lock buttons
                ui.changeARLockRotationButtonImage(lockARRotation);
                ui.changeARLockScaleButtonImage(lockARScale);
#endif
            }
            else
            {
#if USE_TANGO
                Camera.main.gameObject.GetComponent <TangoARScreen>().enabled = false;
                GameObject.Destroy(Camera.main.GetComponent <TangoARScreen>());
                tangoApplication.m_enableVideoOverlay = false;
#elif USE_ARKIT
                if (arKit)
                {
                    ARKitController arController = arKit.GetComponent <ARKitController>();
                    if (arController)
                    {
                        arController.setARMode(false);
                    }
                }
                // destroy video background
                GameObject.Destroy(Camera.main.GetComponent <ARScreen>());
                if (root)
                {
                    GameObject.Destroy(root.GetComponent <ARPlaneAlignment>());
                }
                // destroy plane visualisation
                if (arPlanes)
                {
                    GameObject.Destroy(arPlanes.GetComponent <ARPlane>());
                }
                // disable anchor visualisation
                if (m_anchorModifier)
                {
                    m_anchorModifier.SetActive(false);
                    GameObject.Destroy(m_anchorModifier);
                    m_anchorModifier = null;
                }
#endif
                // reset cameras to defaults
                Camera.main.ResetProjectionMatrix();
                SetSceneScale(1f);
                repositionCamera();
                UpdateProjectionMatrixSecondaryCameras();
                sceneAdapter.ShowGeometry();
            }

            hasUpdatedProjectionMatrix = true;
        }