AndroidQuit() public static méthode

Calls quit on the Unity Activity.
public static AndroidQuit ( ) : void
Résultat void
Exemple #1
0
    /// <summary>
    /// Apply any needed changes to the pose.
    /// </summary>
    private void Update()
    {
        popManager.TriggerUpdateFPS();
        #if UNITY_ANDROID && !UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
        #else
        popManager.tangoInitialized = true;
        Vector3    tempPosition = transform.position;
        Quaternion tempRotation = transform.rotation;
        PoseProvider.GetMouseEmulation(ref tempPosition, ref tempRotation);
        transform.rotation = tempRotation;
        transform.position = transform.position + ((tempPosition - transform.position) * m_metersToWorldUnitsScaler);
        #endif

        popManager.debugText = "Interpolation: " + enableInterpolation;
    }
    /// <summary>
    /// Update this instance.
    /// </summary>
    public void Update()
    {
        if (Input.touchCount == 1)
        {
            // Trigger place kitten function when single touch ended.
            Touch t = Input.GetTouch(0);
            if (t.phase == TouchPhase.Began)
            {
                if (!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId) && menuScript.isSpawning)
                {
                    Debug.Log("Not on UI");
                    menuScript.currentItem.GetComponent <SetAllScripts>().ToggleAll();
                    PlaceItem(t.position);
                    menuScript.isSpawning = false;
                }
            }
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }
    }
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        if (m_saveThread != null && m_saveThread.ThreadState != ThreadState.Running)
        {
            // After saving an Area Description, we reload the scene to restart the game.
            #pragma warning disable 618
            Application.LoadLevel(Application.loadedLevel);
            #pragma warning restore 618
        }

        // Pressing the back button should popup the management window if you are not in the management screen,
        // otherwise it can quit.
        if (Input.GetKey(KeyCode.Escape))
        {
            if (m_managementRoot.activeSelf)
            {
                // This is a fix for a lifecycle issue where calling
                // Application.Quit() here, and restarting the application
                // immediately results in a deadlocked app.
                AndroidHelper.AndroidQuit();
            }
            else
            {
                #pragma warning disable 618
                Application.LoadLevel(Application.loadedLevel);
                #pragma warning restore 618
            }
        }
    }
Exemple #4
0
 /// <summary>
 /// Unity Update function.
 ///
 /// Application will be closed when click the back button.
 /// </summary>
 public void Update()
 {
     if (Input.GetKey(KeyCode.Escape))
     {
         // This is a fix for a lifecycle issue where calling
         // Application.Quit() here, and restarting the application
         // immediately results in a deadlocked app.
         AndroidHelper.AndroidQuit();
     }
 }
 private void Update()
 {
     // "back" button of phone equals "Escape". quit app if that's pressed
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         // This is a fix for a lifecycle issue where calling
         // Application.Quit() here, and restarting the application
         // immediately results in a deadlocked app.
         AndroidHelper.AndroidQuit();
     }
 }
Exemple #6
0
    /// <summary>
    /// Update this instance.
    /// </summary>
    public void Update()
    {
        m_poseController.m_clutchEnabled = Input.GetMouseButton(0);

        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }
    }
Exemple #7
0
    /// <summary>
    /// Apply any needed changes to the pose.
    /// </summary>
    private void Update()
    {
        if (m_shouldInitTango)
        {
            m_tangoApplication.InitApplication();
            m_tangoApplication.InitProviders(string.Empty);
            m_tangoApplication.ConnectToService();
            m_shouldInitTango = false;

            double timestamp = 0.0;
            TangoCoordinateFramePair pair;
            TangoPoseData            poseData = new TangoPoseData();

            pair.baseFrame   = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
            pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
            PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
            Vector3    position = new Vector3((float)poseData.translation[0], (float)poseData.translation[1], (float)poseData.translation[2]);
            Quaternion quat     = new Quaternion((float)poseData.orientation[0], (float)poseData.orientation[1], (float)poseData.orientation[2], (float)poseData.orientation[3]);
            m_imuTd = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));

            pair.baseFrame   = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
            pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_CAMERA_COLOR;
            PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
            position = new Vector3((float)poseData.translation[0], (float)poseData.translation[1], (float)poseData.translation[2]);
            quat     = new Quaternion((float)poseData.orientation[0], (float)poseData.orientation[1], (float)poseData.orientation[2], (float)poseData.orientation[3]);
            m_imuTc  = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));
        }
        if (m_isDirty)
        {
            Matrix4x4 ssTd  = Matrix4x4.TRS(m_tangoPosition, m_tangoRotation, Vector3.one);
            Matrix4x4 uwTuc = m_uwTss * ssTd * Matrix4x4.Inverse(m_imuTd) * m_imuTc * m_cTuc;

            // Extract new local position
            transform.position = uwTuc.GetColumn(3);

            // Extract new local rotation
            transform.rotation = Quaternion.LookRotation(uwTuc.GetColumn(2), uwTuc.GetColumn(1));
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
    }
Exemple #8
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            AndroidHelper.AndroidQuit();
        }

        m_time += Time.deltaTime;
        if (m_time > m_timeInterval)
        {
            m_time -= m_timeInterval;
            StartCoroutine(WaitForDepthAndDetectPlanes());
        }
    }
 /// <summary>
 /// Internal callback when a permissions event happens.
 /// </summary>
 /// <param name="permissionsGranted">If set to <c>true</c> permissions granted.</param>
 public void OnTangoPermissions(bool permissionsGranted)
 {
     if (permissionsGranted)
     {
         _PopulateList();
     }
     else
     {
         // This is a fix for a lifecycle issue where calling
         // Application.Quit() here, and restarting the application
         // immediately results in a deadlocked app.
         AndroidHelper.AndroidQuit();
     }
 }
    /// <summary>
    /// Apply any needed changes to the pose.
    /// </summary>
    private void Update()
    {
        #if UNITY_ANDROID && !UNITY_EDITOR
        if (m_isDirty)
        {
            // This rotation needs to be put into Unity coordinate space.
            Quaternion rotationFix = Quaternion.Euler(90.0f, 0.0f, 0.0f);

            if (!m_isRelocalized)
            {
                Quaternion axisFix = Quaternion.Euler(-m_tangoRotation[0].eulerAngles.x,
                                                      -m_tangoRotation[0].eulerAngles.z,
                                                      m_tangoRotation[0].eulerAngles.y);

                transform.rotation = m_startingRotation * (rotationFix * axisFix);
                transform.position = (m_startingRotation * (m_tangoPosition[0] * m_movementScale)) + m_startingOffset;
            }
            else
            {
                Quaternion axisFix = Quaternion.Euler(-m_tangoRotation[1].eulerAngles.x,
                                                      -m_tangoRotation[1].eulerAngles.z,
                                                      m_tangoRotation[1].eulerAngles.y);

                transform.rotation = m_startingRotation * (rotationFix * axisFix);
                transform.position = (m_startingRotation * (m_tangoPosition[1] * m_movementScale)) + m_startingOffset;
            }
            m_isDirty = false;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
        #else
        Vector3    tempPosition = transform.position;
        Quaternion tempRotation = transform.rotation;
        PoseProvider.GetMouseEmulation(ref tempPosition, ref tempRotation);
        transform.rotation = tempRotation;
        transform.position = tempPosition;
        #endif
    }
    /// <summary>
    /// Unity update callback.
    /// </summary>
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
    }
Exemple #12
0
    /// <summary>
    /// Internal callback when a permissions event happens.
    /// </summary>
    /// <param name="permissionsGranted">If set to <c>true</c> permissions granted.</param>
    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            _PopulateList();
        }
        else
        {
            AndroidHelper.ShowAndroidToastMessage("Motion Tracking and Area Learning Permissions Needed");

            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }
    }
    /// <summary>
    /// Apply any needed changes to the pose.
    /// </summary>
    private void Update()
    {
        #if UNITY_ANDROID && !UNITY_EDITOR
        if (m_shouldInitTango)
        {
            m_tangoApplication.InitApplication();
            m_tangoApplication.InitProviders(string.Empty);
            m_tangoApplication.ConnectToService();
            m_shouldInitTango = false;
        }
        if (m_isDirty)
        {
            // Construct the start of service with respect to device matrix from the pose.
            Matrix4x4 ssTd = Matrix4x4.TRS(m_tangoPosition, m_tangoRotation, Vector3.one);

            // Converting from Tango coordinate frame to Unity coodinate frame.
            Matrix4x4 uwTuc = m_uwTss * ssTd * m_dTuc;

            // Extract new local position
            transform.position = uwTuc.GetColumn(3);

            // Extract new local rotation
            transform.rotation = Quaternion.LookRotation(uwTuc.GetColumn(2), uwTuc.GetColumn(1));
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
        #else
        Vector3    tempPosition = transform.position;
        Quaternion tempRotation = transform.rotation;
        PoseProvider.GetMouseEmulation(ref tempPosition, ref tempRotation);
        transform.rotation = tempRotation;
        transform.position = tempPosition;
        #endif
    }
Exemple #14
0
 /// <summary>
 /// Update is called once per frame.
 /// Return to menu or quit current application when back button is triggered.
 /// </summary>
 public void Update()
 {
     if (Input.GetKey(KeyCode.Escape))
     {
         if (m_menuOpen)
         {
             // This is a fix for a lifecycle issue where calling
             // Application.Quit() here, and restarting the application
             // immediately results in a deadlocked app.
             AndroidHelper.AndroidQuit();
         }
         else
         {
             #pragma warning disable 618
             Application.LoadLevel(Application.loadedLevel);
             #pragma warning restore 618
         }
     }
 }
    /// <summary>
    /// Unity update function, we update our texture from here.
    /// </summary>
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
        double timestamp = VideoOverlayProvider.RenderLatestFrame(TangoEnums.TangoCameraId.TANGO_CAMERA_COLOR);

        _UpdateTransformation(timestamp);
        GL.InvalidateState();
    }
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }

        if (!m_findingFloor)
        {
            return;
        }

        // If the point cloud floor has found a new floor, place the marker at the found y position.
        if (m_pointCloudFloor.m_floorFound)
        {
            m_findingFloor = false;

            // Place the marker at the center of the screen at the found floor height.
            m_marker.SetActive(true);
            Vector3    target;
            RaycastHit hitInfo;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f)), out hitInfo))
            {
                // Limit distance of the marker position from the camera to the camera's far clip plane. This makes sure that the marker
                // is visible on screen when the floor is found.
                Vector3 cameraBase = new Vector3(Camera.main.transform.position.x, hitInfo.point.y, Camera.main.transform.position.z);
                target = cameraBase + Vector3.ClampMagnitude(hitInfo.point - cameraBase, Camera.main.farClipPlane * 0.9f);
            }
            else
            {
                // If no raycast hit, place marker in the camera's forward direction.
                Vector3 dir = new Vector3(Camera.main.transform.forward.x, 0.0f, Camera.main.transform.forward.z);
                target   = dir.normalized * (Camera.main.farClipPlane * 0.9f);
                target.y = m_pointCloudFloor.transform.position.y;
            }

            m_marker.transform.position = target;
            AndroidHelper.ShowAndroidToastMessage(string.Format("Floor found. Unity world height = {0}", m_pointCloudFloor.transform.position.y.ToString()));
        }
    }
Exemple #17
0
    /// <summary>
    /// Update is called every frame.
    /// </summary>
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }

        if (m_tangoARScreen.m_screenUpdateTime != m_poseTimestamp)
        {
            _UpdateTransformation(m_tangoARScreen.m_screenUpdateTime);
        }
    }
Exemple #18
0
    /// <summary>
    /// Update this instance.
    /// </summary>
    public void Update()
    {
        // Distance was found.
        m_distanceText = "Distance is " + m_distance + " meters.";

        _RenderLine();

        if (Input.GetMouseButtonDown(0))
        {
            StartCoroutine(_WaitForDepth(Input.mousePosition));
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }
    }
Exemple #19
0
    /// <summary>
    /// Update this instance.
    /// </summary>
    public void Update()
    {
        // Distance was found.

        if (screenTaps == 2)
        {
            m_distanceText01 = "Length is:" + m_distance01;  //"01 Distance is " + m_distance01 + " meters.";
            m_distanceText12 = "";
            m_distanceText23 = "";
        }
        else if (screenTaps == 3)
        {
            m_distanceText01 = "Length is:" + m_distance01;  //"01 Distance is " + m_distance01 + " meters.";
            m_distanceText12 = "Width is:" + m_distance12;   //"12 Distance is " + m_distance12 + " meters.";
            m_distanceText23 = "";
        }
        else if (screenTaps > 3)
        {
            m_distanceText01 = "Length is:" + m_distance01;  //"01 Distance is " + m_distance01 + " meters.";
            m_distanceText12 = "Width is:" + m_distance12;
            m_distanceText23 = "Height is:" + m_distance23;
        }



        // _RenderLine();

        if (Input.GetMouseButtonDown(0))
        {
            StartCoroutine(_WaitForDepth(Input.mousePosition));
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }
    }
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        m_currentTime += Time.deltaTime;
        ++m_framesSinceUpdate;
        m_accumulation += Time.timeScale / Time.deltaTime;
        if (m_currentTime >= UPDATE_FREQUENCY)
        {
            m_currentFPS        = (int)(m_accumulation / m_framesSinceUpdate);
            m_currentTime       = 0.0f;
            m_framesSinceUpdate = 0;
            m_accumulation      = 0.0f;
            m_fpsText           = "FPS: " + m_currentFPS;
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }
    }
Exemple #21
0
    /// <summary>
    /// Apply any needed changes to the pose.
    /// </summary>
    private void Update()
    {
        #if UNITY_ANDROID && !UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
        #else
        Vector3    tempPosition = transform.position;
        Quaternion tempRotation = transform.rotation;
        PoseProvider.GetMouseEmulation(ref tempPosition, ref tempRotation);
        transform.rotation = tempRotation;
        transform.position = tempPosition;
        #endif
    }
Exemple #22
0
    /// <summary>
    /// Apply any needed changes to the pose.
    /// </summary>
    private void Update()
    {
        #if UNITY_ANDROID && !UNITY_EDITOR
        if (m_shouldInitTango)
        {
            m_tangoApplication.InitApplication();

            if (m_useADF)
            {
                // Query the full adf list.
                PoseProvider.RefreshADFList();
                // loading last recorded ADF
                string uuid = PoseProvider.GetLatestADFUUID().GetStringDataUUID();
                m_tangoApplication.InitProviders(uuid);
            }
            else
            {
                m_tangoApplication.InitProviders(string.Empty);
            }

            // Query extrinsics constant tranformations.
            TangoPoseData            poseData  = new TangoPoseData();
            double                   timestamp = 0.0;
            TangoCoordinateFramePair pair;

            pair.baseFrame   = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
            pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
            PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
            Vector3    position = new Vector3((float)poseData.translation[0], (float)poseData.translation[1], (float)poseData.translation[2]);
            Quaternion quat     = new Quaternion((float)poseData.orientation[0], (float)poseData.orientation[1], (float)poseData.orientation[2], (float)poseData.orientation[3]);
            m_deviceToIMUMatrix = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));

            pair.baseFrame   = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
            pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_CAMERA_COLOR;
            PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
            position            = new Vector3((float)poseData.translation[0], (float)poseData.translation[1], (float)poseData.translation[2]);
            quat                = new Quaternion((float)poseData.orientation[0], (float)poseData.orientation[1], (float)poseData.orientation[2], (float)poseData.orientation[3]);
            m_cameraToIMUMatrix = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));

            m_alreadyInitialized = true;
            m_shouldInitTango    = false;

            m_tangoApplication.ConnectToService();
        }

        if (m_isDirty)
        {
            // This rotation needs to be put into Unity coordinate space.
            Quaternion rotationFix = Quaternion.Euler(90.0f, 0.0f, 0.0f);

            if (!m_isRelocalized)
            {
                Quaternion axisFix = Quaternion.Euler(-m_tangoRotation[0].eulerAngles.x,
                                                      -m_tangoRotation[0].eulerAngles.z,
                                                      m_tangoRotation[0].eulerAngles.y);

                transform.rotation = m_startingRotation * (rotationFix * axisFix);
                transform.position = (m_startingRotation * (m_tangoPosition[0] * m_movementScale)) + m_startingOffset;
            }
            else
            {
                Quaternion axisFix = Quaternion.Euler(-m_tangoRotation[1].eulerAngles.x,
                                                      -m_tangoRotation[1].eulerAngles.z,
                                                      m_tangoRotation[1].eulerAngles.y);

                transform.rotation = m_startingRotation * (rotationFix * axisFix);
                transform.position = (m_startingRotation * (m_tangoPosition[1] * m_movementScale)) + m_startingOffset;
            }
            m_isDirty = false;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (m_tangoApplication != null)
            {
                m_tangoApplication.Shutdown();
            }

            // This is a temporary fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application immediately,
            // results in a hard crash.
            AndroidHelper.AndroidQuit();
        }
        #else
        Vector3    tempPosition = transform.position;
        Quaternion tempRotation = transform.rotation;
        PoseProvider.GetMouseEmulation(ref tempPosition, ref tempRotation);
        transform.rotation = tempRotation;
        transform.position = tempPosition;
        #endif
    }
Exemple #23
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    public void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }

        if (isEnabled)
        {
            pollTimer += Time.deltaTime;

            //poll floor every 2 seconds
            if (pollTimer > 2)
            {
                pollTimer = 0;

                if (m_pointCloud == null)
                {
                    Debug.LogError("TangoPointCloud required to find floor.");
                    return;
                }

                m_findingFloor = true;
                //m_marker.SetActive(false);
                m_tangoApplication.SetDepthCameraRate(TangoEnums.TangoDepthCameraRate.MAXIMUM);
                m_pointCloud.FindFloor();
            }

            //check if already found
            if (!m_findingFloor)
            {
                return;
            }

            // If the point cloud floor has found a new floor, place the marker at the found y position.
            if (m_pointCloudFloor.m_floorFound && m_pointCloud.m_floorFound)
            {
                m_findingFloor = false;

                // Place the marker at the center of the screen at the found floor height.
                Vector3    target;
                RaycastHit hitInfo;
                if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f)), out hitInfo))
                {
                    //create marker
                    var marker = GameObject.Instantiate(m_marker);
                    marker.transform.parent = gameObject.transform;

                    // Limit distance of the marker position from the camera to the camera's far clip plane. This makes sure that the marker
                    // is visible on screen when the floor is found.
                    Vector3 cameraBase = new Vector3(Camera.main.transform.position.x, hitInfo.point.y, Camera.main.transform.position.z);
                    //target = cameraBase + Vector3.ClampMagnitude(hitInfo.point - cameraBase, Camera.main.farClipPlane * 0.9f);
                    marker.transform.position = cameraBase;
                }
                //else
                //{
                // If no raycast hit, place marker in the camera's forward direction.
                //Vector3 dir = new Vector3(Camera.main.transform.forward.x, 0.0f, Camera.main.transform.forward.z);
                //target = dir.normalized * (Camera.main.farClipPlane * 0.9f);
                //target.y = m_pointCloudFloor.transform.position.y;
                //}

                //marker.transform.position = target;
                //AndroidHelper.ShowAndroidToastMessage(string.Format("Floor found. Unity world height = {0}", m_pointCloudFloor.transform.position.y.ToString()));
            }
        }
    }
Exemple #24
0
    // Update is called once per frame
    void Update()
    {
        //TangoSupport.TangoSupportEdge[] edges;
        //int num_edges;
        //Vector2 guiPosition = new Vector2(Input.GetTouch(0).position.x, Screen.height - Input.GetTouch(0).position.y);
        // RaycastHit hit = new RaycastHit();
        //for (int i = 0; i < Input.touchCount; ++i)

        if (Input.GetMouseButtonDown(0))
        {
            StartCoroutine(_WaitForDepth(Input.mousePosition));
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            // This is a fix for a lifecycle issue where calling
            // Application.Quit() here, and restarting the application
            // immediately results in a deadlocked app.
            AndroidHelper.AndroidQuit();
        }

        /*
         * if (Input.touchCount > 0)
         * {
         *  Touch t = Input.GetTouch(0);
         *  Vector2 guiPosition = Vector2.zero;
         *  if (t.phase == TouchPhase.Began)
         *  {
         *      guiPosition = new Vector2(t.position.x, Screen.height - t.position.y);
         *
         *      m_camera = Camera.main;
         *
         *      if (!FindObjectOfType<TangoPointCloud>())
         *      {
         *          Debug.Log("<<<<<<<<<<<<<<<< need point cloud to find the edges");
         *      }
         *      else
         *      {
         *          m_pointCloud = FindObjectOfType<TangoPointCloud>();
         *      }
         *
         *      if (m_pointCloud != null)
         *      {
         *          Vector3 touch_world = m_camera.ScreenToWorldPoint(t.position);
         *          Vector2 n_touch = new Vector2(touch_world.x, touch_world.y);
         *          bool edgeResult = m_pointCloud.FindEdges(m_imagebuffer, m_camera, t.position,
         *              out edges, out num_edges);
         *          if (edgeResult == true)
         *          {
         *
         *              Debug.Log("Touch Points : x  " + touch_world.x + " y  " + touch_world.y);
         *              m_edgeCount = num_edges;
         *              m_startPoint = new Vector3[num_edges];
         *              m_endPoint = new Vector3[num_edges];
         *              m_nearestPoint = new Vector3[num_edges];
         *              for(int i = 0; i < num_edges; i++)
         *              {
         *                  m_startPoint[i] = new Vector3(edges[i].end_points_x1,
         *                                                edges[i].end_points_y1,
         *                                                edges[i].end_points_z1);
         *                  Debug.Log(m_startPoint[i]);
         *                  m_endPoint[i] = new Vector3(edges[i].end_points_x2,
         *                                              edges[i].end_points_y2,
         *                                              edges[i].end_points_z2);
         *                  Debug.Log(m_endPoint[i]);
         *                  m_nearestPoint[i] = new Vector3(edges[i].closest_point_on_edge_x,
         *                                                  edges[i].closest_point_on_edge_y,
         *                                                  edges[i].closest_point_on_edge_z);
         *                  Debug.Log(m_nearestPoint[i]);
         *              }
         *              _RenderLine();
         *          }
         *      }
         *  }
         * }
         */
    }