Beispiel #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>
    /// Quit the room properly.
    /// </summary>
    private void _QuitGame()
    {
        if (PhotonNetwork.inRoom)
        {
            PhotonNetwork.LeaveRoom();
        }

        m_tangoApplication.Shutdown();
        Application.LoadLevel("AreaDescriptionPicker");
    }
Beispiel #3
0
 void DisconnectService()
 {
     if (!tango.IsServiceConnected)
     {
         Debug.LogWarning("Service not connected.");
     }
     else
     {
         tango.Shutdown();
     }
 }
Beispiel #4
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();
        }
    }
Beispiel #5
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
    }
    /// <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();
        }
    }
    /// <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
    }
    /// <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>
 /// Perform updates for the next frame after the
 /// normal update has run. This loads next frame.
 /// </summary>
 private void LateUpdate()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         if (m_isActive)
         {
             m_isActive = false;
         }
         else
         {
             TangoApplication application = FindObjectOfType <TangoApplication>();
             if (application != null)
             {
                 application.Shutdown();
             }
             Application.Quit();
         }
     }
 }
Beispiel #11
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);
        }
    }
Beispiel #12
0
 // Makes sure to restart the service properly.
 // If the service hasn't started, just starts the service normally.
 public static void Restart(this TangoApplication self, AreaDescription adf)
 {
     self.Shutdown();
     self.Startup(adf);
 }
Beispiel #13
0
 public override void OnDispose()
 {
     m_tangoApplication.Shutdown();
 }
 private void OnDestroy()
 {
     tangoApplication.Shutdown();
 }
Beispiel #15
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
    }
Beispiel #16
0
 private void OnDestroy( )
 {
     m_tangoApplication.Shutdown( );
     Debug.Log("Destroying Tango");
 }