Esempio n. 1
0
    void OnGUI()
    {
        if (m_tangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.white;

            GUI.color = Color.black;
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoPoseController.m_tangoServiceVersionName) + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_FPS_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + m_FPSText + "</size>");
            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME,
                                                                              "Device",
                                                                              "Start") + "</size>");

            Vector3    pos            = m_tangoPoseController.transform.position;
            Quaternion quat           = m_tangoPoseController.transform.rotation;
            string     positionString = pos.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.z.ToString(UI_FLOAT_FORMAT);
            string rotationString = quat.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.z.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.w.ToString(UI_FLOAT_FORMAT);
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_STATUS,
                                                                              _GetLoggingStringFromPoseStatus(m_tangoPoseController.m_status),
                                                                              _GetLoggingStringFromFrameCount(m_tangoPoseController.m_frameCount),
                                                                              positionString, rotationString) + "</size>");
            GUI.color = oldColor;
        }
    }
    void OnGUI()
    {
        if (m_tangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.white;

            if (GUI.Button(new Rect(UI_BUTTON_GAP_X,
                                    Screen.height - (UI_BUTTON_SIZE_Y + UI_LABEL_GAP_Y),
                                    UI_BUTTON_SIZE_X + 100,
                                    UI_BUTTON_SIZE_Y), "<size=20>Reset motion tracking</size>"))
            {
                PoseProvider.ResetMotionTracking();
            }

            GUI.color = Color.black;
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoPoseController.m_tangoServiceVersionName) + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_FPS_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + m_FPSText + "</size>");
            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME,
                                                                              "Device",
                                                                              "Start") + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_STATUS,
                                                                              _GetLoggingStringFromPoseStatus(m_tangoPoseController.m_status),
                                                                              _GetLoggingStringFromFrameCount(m_tangoPoseController.m_frameCount),
                                                                              _GetLoggingStringFromVec3(m_tangoPoseController.transform.position),
                                                                              _GetLoggingStringFromQuaternion(m_tangoPoseController.transform.rotation)) + "</size>");
            GUI.color = oldColor;
        }
    }
Esempio n. 3
0
    /// <summary>
    /// GUI for switch getting data API and status.
    /// </summary>
    private void OnGUI()
    {
        if (TangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.gray;

            if (!TangoApplication.HasGrantedPermissions())
            {
                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_LABEL_START_Y,
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), "<size=15>" + Common.TANGO_NO_PERMISSIONS_ERROR + "</size>");
                return;
            }

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_TANGO_SERVICE_VERSION, TangoApplication.GetTangoServiceVersion()) + "</size>");


            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>Point Count: " + pointcloud.m_pointsCount.ToString() + "</size>");

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 2.0f,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>Average Depth (m): " + pointcloud.m_overallZ.ToString() + "</size>");


            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 3.0f,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>Frame Delta Time (ms): " + pointcloud.GetTimeSinceLastFrame().ToString("0.") + "</size>");

            GUI.color = oldColor;
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Unity GUI callback.
    /// </summary>
    public void OnGUI()
    {
        if (m_tangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.black;

            GUI.Label(new Rect(UI_LABEL_START_X, UI_LABEL_START_Y, UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoPoseController.m_tangoServiceVersionName) + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X, UI_FPS_LABEL_START_Y, UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + m_fpsText + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X, UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET, UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME, "Device", "Start") + "</size>");

            string logString = String.Format(UX_STATUS,
                                             _GetLoggingStringFromPoseStatus(m_tangoPoseController.m_status),
                                             _GetLoggingStringFromFrameCount(m_tangoPoseController.m_frameCount),
                                             _GetLoggingStringFromVec3(m_tangoPoseController.transform.position),
                                             _GetLoggingStringFromQuaternion(m_tangoPoseController.transform.rotation));
            GUI.Label(new Rect(UI_LABEL_START_X, UI_POSE_LABEL_START_Y, UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + logString + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X, UI_DEPTH_LABLE_START_Y, UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + "Average depth (m): " + m_pointcloud.m_overallZ.ToString() + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X, UI_DEPTH_LABLE_START_Y + (UI_LABEL_OFFSET * 1.0f), UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + "Point count: " + m_pointcloud.m_pointsCount.ToString() + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X, UI_DEPTH_LABLE_START_Y + (UI_LABEL_OFFSET * 2.0f), UI_LABEL_SIZE_X, UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + "Frame delta time (ms): " + m_pointcloud.m_depthDeltaTime.ToString(UI_FLOAT_FORMAT) + "</size>");

            GUI.color = oldColor;
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Display simple GUI.
    /// </summary>
    public void OnGUI()
    {
        Rect distortionButtonRec = new Rect(UI_BUTTON_GAP_X,
                                            Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                            UI_BUTTON_SIZE_X,
                                            UI_BUTTON_SIZE_Y);
        string isOn = m_arCameraPostProcess.enabled ? "Off" : "On";

        if (GUI.Button(distortionButtonRec,
                       UI_FONT_SIZE + "Turn Distortion " + isOn + "</size>"))
        {
            m_arCameraPostProcess.enabled = !m_arCameraPostProcess.enabled;
        }

        if (m_showDebug && m_tangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.white;

            GUI.color = Color.black;
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoServiceVersion) + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_FPS_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + m_fpsText + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME, "Device", "Start") + "</size>");

            Vector3    pos            = m_tangoPose.transform.position;
            Quaternion quat           = m_tangoPose.transform.rotation;
            string     positionString = pos.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.z.ToString(UI_FLOAT_FORMAT);
            string rotationString = quat.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.z.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.w.ToString(UI_FLOAT_FORMAT);
            string statusString = String.Format(UX_STATUS,
                                                _GetLoggingStringFromPoseStatus(m_tangoPose.m_poseStatus),
                                                _GetLoggingStringFromFrameCount(m_tangoPose.m_poseCount),
                                                positionString, rotationString);
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + statusString + "</size>");
            GUI.color = oldColor;
        }

        if (m_selectedMarker != null)
        {
            Renderer selectedRenderer = m_selectedMarker.GetComponent <Renderer>();

            // GUI's Y is flipped from the mouse's Y
            Rect  screenRect = WorldBoundsToScreen(Camera.main, selectedRenderer.bounds);
            float yMin       = Screen.height - screenRect.yMin;
            float yMax       = Screen.height - screenRect.yMax;
            screenRect.yMin = Mathf.Min(yMin, yMax);
            screenRect.yMax = Mathf.Max(yMin, yMax);

            if (GUI.Button(screenRect, "<size=30>Hide</size>"))
            {
                m_selectedMarker.SendMessage("Hide");
                m_selectedMarker = null;
                m_selectedRect   = new Rect();
            }
            else
            {
                m_selectedRect = screenRect;
            }
        }
        else
        {
            m_selectedRect = new Rect();
        }

        if (GameObject.FindObjectOfType <ARMarker>() != null)
        {
            m_hideAllRect = new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
                                     Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                     UI_BUTTON_SIZE_X,
                                     UI_BUTTON_SIZE_Y);
            if (GUI.Button(m_hideAllRect, "<size=30>Hide All</size>"))
            {
                foreach (ARMarker marker in GameObject.FindObjectsOfType <ARMarker>())
                {
                    marker.SendMessage("Hide");
                }
            }
        }
        else
        {
            m_hideAllRect = new Rect(0, 0, 0, 0);
        }
    }
    /// <summary>
    /// Data logging GUI.
    /// </summary>
    private void OnGUI()
    {
        Color oldColor = GUI.color;

        GUI.color = Color.black;

        if (TangoApplication.HasRequestedPermissions())
        {
            if (!TangoApplication.HasGrantedPermissions())
            {
                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_LABEL_START_Y,
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + Common.TANGO_NO_PERMISSIONS_ERROR + "</size>");
                return;
            }

            int guiIndex = 1;
            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_TANGO_SERVICE_VERSION, m_tangoServiceVersionName) + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_POSE_LABEL_START_Y,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_TARGET_TO_BASE_FRAME,
                                                                                            "Device",
                                                                                            "Start") + "</size>");

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_POSE_LABEL_START_Y + Common.UI_LABEL_OFFSET * guiIndex,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_STATUS,
                                                                                            _GetLoggingStringFromPoseStatus(m_status[DEVICE_TO_START]),
                                                                                            _GetLoggingStringFromFrameCount(m_frameCount[DEVICE_TO_START]),
                                                                                            _GetLogginStringFromFrameDeltaTime(m_frameDeltaTime[DEVICE_TO_START]),
                                                                                            _GetLoggingStringFromVec3(m_tangoPosition[DEVICE_TO_START]),
                                                                                            _GetLoggingStringFromQuaternion(m_tangoRotation[DEVICE_TO_START])) + "</size>");

            if (m_useADF || m_tangoApplication.m_enableAreaLearning)
            {
                // ADF
                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_POSE_LABEL_START_Y + Common.UI_LABEL_OFFSET * (++guiIndex),
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_TARGET_TO_BASE_FRAME,
                                                                                                "Device",
                                                                                                "ADF") + "</size>");

                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_POSE_LABEL_START_Y + Common.UI_LABEL_OFFSET * (++guiIndex),
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_STATUS,
                                                                                                _GetLoggingStringFromPoseStatus(m_status[DEVICE_TO_ADF]),
                                                                                                _GetLoggingStringFromFrameCount(m_frameCount[DEVICE_TO_ADF]),
                                                                                                _GetLogginStringFromFrameDeltaTime(m_frameDeltaTime[DEVICE_TO_ADF]),
                                                                                                _GetLoggingStringFromVec3(m_tangoPosition[DEVICE_TO_ADF]),
                                                                                                _GetLoggingStringFromQuaternion(m_tangoRotation[DEVICE_TO_ADF])) + "</size>");

                // RELOCALIZATION
                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_POSE_LABEL_START_Y + Common.UI_LABEL_OFFSET * (++guiIndex),
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_TARGET_TO_BASE_FRAME,
                                                                                                "Start",
                                                                                                "ADF") + "</size>");

                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_POSE_LABEL_START_Y + Common.UI_LABEL_OFFSET * (++guiIndex),
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), Common.UI_FONT_SIZE + String.Format(Common.UX_STATUS,
                                                                                                _GetLoggingStringFromPoseStatus(m_status[START_TO_ADF]),
                                                                                                _GetLoggingStringFromFrameCount(m_frameCount[START_TO_ADF]),
                                                                                                _GetLogginStringFromFrameDeltaTime(m_frameDeltaTime[START_TO_ADF]),
                                                                                                _GetLoggingStringFromVec3(m_tangoPosition[START_TO_ADF]),
                                                                                                _GetLoggingStringFromQuaternion(m_tangoRotation[START_TO_ADF])) + "</size>");
            }
        }
        GUI.color = oldColor;
    }
    /// <summary>
    /// Data logging GUI.
    /// </summary>
    private void OnGUI()
    {
        Color oldColor = GUI.color;

        GUI.color = Color.black;

        if (m_tangoApplication.HasRequestedPermissions())
        {
            int guiIndex = 0;
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoPoseController.m_tangoServiceVersionName) + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME,
                                                                              "Device",
                                                                              "Start") + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y + UI_LABEL_OFFSET * guiIndex,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_STATUS,
                                                                              _GetLoggingStringFromPoseStatus(m_tangoPoseController.m_status[AreaLearningPoseController.DEVICE_TO_START]),
                                                                              _GetLoggingStringFromFrameCount(m_tangoPoseController.m_frameCount[AreaLearningPoseController.DEVICE_TO_START]),
                                                                              _GetLoggingStringFromVec3(m_tangoPoseController.m_tangoPosition[AreaLearningPoseController.DEVICE_TO_START]),
                                                                              _GetLoggingStringFromQuaternion(m_tangoPoseController.m_tangoRotation[AreaLearningPoseController.DEVICE_TO_START])) + "</size>");

            if (m_tangoPoseController.m_useADF || m_tangoApplication.m_enableAreaLearning)
            {
                // ADF
                GUI.Label(new Rect(UI_LABEL_START_X,
                                   UI_POSE_LABEL_START_Y + UI_LABEL_OFFSET * (++guiIndex),
                                   UI_LABEL_SIZE_X,
                                   UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME,
                                                                                  "Device",
                                                                                  "ADF") + "</size>");

                GUI.Label(new Rect(UI_LABEL_START_X,
                                   UI_POSE_LABEL_START_Y + UI_LABEL_OFFSET * (++guiIndex),
                                   UI_LABEL_SIZE_X,
                                   UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_STATUS,
                                                                                  _GetLoggingStringFromPoseStatus(m_tangoPoseController.m_status[AreaLearningPoseController.DEVICE_TO_ADF]),
                                                                                  _GetLoggingStringFromFrameCount(m_tangoPoseController.m_frameCount[AreaLearningPoseController.DEVICE_TO_ADF]),
                                                                                  _GetLoggingStringFromVec3(m_tangoPoseController.m_tangoPosition[AreaLearningPoseController.DEVICE_TO_ADF]),
                                                                                  _GetLoggingStringFromQuaternion(m_tangoPoseController.m_tangoRotation[AreaLearningPoseController.DEVICE_TO_ADF])) + "</size>");

                // RELOCALIZATION
                GUI.Label(new Rect(UI_LABEL_START_X,
                                   UI_POSE_LABEL_START_Y + UI_LABEL_OFFSET * (++guiIndex),
                                   UI_LABEL_SIZE_X,
                                   UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME,
                                                                                  "Start",
                                                                                  "ADF") + "</size>");

                GUI.Label(new Rect(UI_LABEL_START_X,
                                   UI_POSE_LABEL_START_Y + UI_LABEL_OFFSET * (++guiIndex),
                                   UI_LABEL_SIZE_X,
                                   UI_LABEL_SIZE_Y), UI_FONT_SIZE + String.Format(UX_STATUS,
                                                                                  _GetLoggingStringFromPoseStatus(m_tangoPoseController.m_status[AreaLearningPoseController.START_TO_ADF]),
                                                                                  _GetLoggingStringFromFrameCount(m_tangoPoseController.m_frameCount[AreaLearningPoseController.START_TO_ADF]),
                                                                                  _GetLoggingStringFromVec3(m_tangoPoseController.m_tangoPosition[AreaLearningPoseController.START_TO_ADF]),
                                                                                  _GetLoggingStringFromQuaternion(m_tangoPoseController.m_tangoRotation[AreaLearningPoseController.START_TO_ADF])) + "</size>");
            }
        }
        GUI.color = oldColor;
    }
Esempio n. 8
0
    /// <summary>
    /// Display simple GUI.
    /// </summary>
    public void OnGUI()
    {
        Rect distortionButtonRec = new Rect(UI_BUTTON_GAP_X,
                                            Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                            UI_BUTTON_SIZE_X,
                                            UI_BUTTON_SIZE_Y);
        string isOn = m_arCameraPostProcess.enabled ? "Off" : "On";

        if (GUI.Button(distortionButtonRec,
                       UI_FONT_SIZE + "Turn Distortion " + isOn + "</size>"))
        {
            m_arCameraPostProcess.enabled = !m_arCameraPostProcess.enabled;
        }

        if (m_showDebug && m_tangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.white;

            GUI.color = Color.black;
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoServiceVersion) + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_FPS_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + m_fpsText + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME, "Device", "Start") + "</size>");

            Vector3    pos            = m_tangoPose.transform.position;
            Quaternion quat           = m_tangoPose.transform.rotation;
            string     positionString = pos.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.z.ToString(UI_FLOAT_FORMAT);
            string rotationString = quat.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.z.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.w.ToString(UI_FLOAT_FORMAT);
            string statusString = String.Format(UX_STATUS,
                                                _GetLoggingStringFromPoseStatus(m_tangoPose.m_poseStatus),
                                                _GetLoggingStringFromFrameCount(m_tangoPose.m_poseCount),
                                                positionString, rotationString);
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + statusString + "</size>");
            GUI.color = oldColor;
        }

        if (m_selectedMarker != null)
        {
            Renderer selectedRenderer = m_selectedMarker.GetComponent <Renderer>();

            // GUI's Y is flipped from the mouse's Y
            Rect  screenRect = WorldBoundsToScreen(Camera.main, selectedRenderer.bounds);
            float yMin       = Screen.height - screenRect.yMin;
            float yMax       = Screen.height - screenRect.yMax;
            screenRect.yMin = Mathf.Min(yMin, yMax);
            screenRect.yMax = Mathf.Max(yMin, yMax);

            if (_fileBrowser == null && GUI.Button(screenRect, "<size=20>Delete</size>"))
            {
                m_selectedMarker.SendMessage("Hide");
                m_selectedMarker = null;
                m_selectedRect   = new Rect();
            }
            else
            {
                m_selectedRect = screenRect;
            }
        }
        else
        {
            m_selectedRect = new Rect();
        }

        if (GameObject.FindObjectOfType <ARMarker>() != null)
        {
            m_hideAllRect = new Rect(Screen.width - UI_BUTTON_SIZE_X * 0.75f - UI_BUTTON_GAP_X,
                                     Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                     UI_BUTTON_SIZE_X * 0.75f,
                                     UI_BUTTON_SIZE_Y);
            if (_fileBrowser == null && GUI.Button(m_hideAllRect, "<size=20>Reset</size>"))
            {
                foreach (ARMarker marker in GameObject.FindObjectsOfType <ARMarker>())
                {
                    marker.SendMessage("Hide");
                }
                #region Cfd
                _uiElementTriggered = true;
                _markerPositions.Clear();
                _errorCalcXform = false;
                _xformCalced    = false;
                showMarker      = true;
                return;

                #endregion
            }
            #region Cfd

            if (_markerPositions.Count >= 4)
            {
                var rect = new Rect(Screen.width - UI_BUTTON_SIZE_X * 1.5f - UI_BUTTON_GAP_X,
                                    Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                    UI_BUTTON_SIZE_X * 0.75f,
                                    UI_BUTTON_SIZE_Y);
                var txt = showMarker ? "Hide Marker" : "Show Marker";
                if (GUI.Button(rect, "<size=20>" + txt + "</size>"))
                {
                    _uiElementTriggered = true;
                    showMarker          = !showMarker;
                    foreach (ARMarker marker in GameObject.FindObjectsOfType <ARMarker>())
                    {
                        marker.GetComponent <Renderer>().enabled = showMarker;
                    }
                    return;
                }
            }

            #endregion
        }
        else
        {
            m_hideAllRect = new Rect(0, 0, 0, 0);
        }

        #region Cfd
        var oColor = GUI.color;

        GUI.color = Color.black;
        var msg = "Add 4 markers before loading and positioning CFD data.";
        if ((_markerPositions.Count >= 4 || !Application.isMobilePlatform) && _errorCalcXform)
        {
            msg = "Error encountered, please clear all markers and try again.";
        }
        GUI.Label(new Rect(UI_LABEL_GAP_X,
                           UI_LABEL_GAP_Y,
                           UI_LABEL_SIZE_X,
                           UI_LABEL_SIZE_Y),
                  UI_FONT_SIZE + msg + "</size>");
        GUI.color = oColor;

        if (_fileBrowser == null && (_markerPositions.Count >= 4 || !Application.isMobilePlatform))
        {
            Rect toggleRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                       UI_BUTTON_GAP_Y,
                                       UI_TOGGLE_SIZE_X,
                                       UI_TOGGLE_SIZE_Y);
            float vmove = UI_TOGGLE_SIZE_Y + UI_BUTTON_GAP_Y;
            //data source toggle
            _dataFromServer = GUI.Toggle(toggleRect, _dataFromServer, "<size=20>Load Server Data</size>");
            if (_dataFromServer)
            {
                toggleRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                      vmove + UI_BUTTON_GAP_Y,
                                      UI_TOGGLE_SIZE_X,
                                      UI_TOGGLE_SIZE_Y);
                _loadSliceByTouch = GUI.Toggle(toggleRect, _loadSliceByTouch, "<size=20>Load slice by touch</size>");
                vmove            += UI_TOGGLE_SIZE_Y + UI_BUTTON_GAP_Y;
            }
            int  it         = 0;
            Rect buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                       vmove + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                       UI_BUTTON_SIZE_X,
                                       UI_BUTTON_SIZE_Y);
            //load file button
            if (GUI.Button(buttonRect, "<size=20>Load BIM/Scan</size>"))
            {
                _uiElementTriggered = true;
                _loadMode           = FileLoadMode.Scan;
                OnLoadFile();
                return;
            }
            if (_cfdManager.BaseFileLoaded)
            {
                it++;
                buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                      vmove + UI_BUTTON_GAP_Y + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                      UI_BUTTON_SIZE_X,
                                      UI_BUTTON_SIZE_Y);
                string show = _cfdManager.ScannedActive ? "Hide" : "Show";
                if (GUI.Button(buttonRect, "<size=20>" + show + " BIM/Scan</size>"))
                {
                    _uiElementTriggered = true;
                    _cfdManager.SetScannedActive(!_cfdManager.ScannedActive);
                    return;
                }

                it++;
                buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                      vmove + UI_BUTTON_GAP_Y + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                      UI_BUTTON_SIZE_X,
                                      UI_BUTTON_SIZE_Y);
                //load file button
                if (GUI.Button(buttonRect, "<size=20>Load CFD Slice</size>"))
                {
                    _uiElementTriggered = true;
                    _loadMode           = FileLoadMode.CFD;
                    if (_loadSliceByTouch)
                    {
                        _posingSlice = true;
                    }
                    else
                    {
                        OnLoadFile();
                    }
                    return;
                }

                it++;
                buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                      vmove + UI_BUTTON_GAP_Y + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                      UI_BUTTON_SIZE_X,
                                      UI_BUTTON_SIZE_Y);
                //load file button
                if (GUI.Button(buttonRect, "<size=20>Load Tube</size>"))
                {
                    _uiElementTriggered = true;
                    _loadMode           = FileLoadMode.Tube;
                    OnLoadFile();
                    return;
                }
            }

            if (_cfdManager.TimeStepCount > 1)
            {
                it++;
                buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                      vmove + UI_BUTTON_GAP_Y + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                      UI_BUTTON_SIZE_X,
                                      UI_BUTTON_SIZE_Y);
                //step switch button
                if (GUI.Button(buttonRect, "<size=20>Clear Slices/Tubes</size>"))
                {
                    _uiElementTriggered = true;
                    OnClearSliceTube();
                    return;
                }

                it++;
                buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                      vmove + UI_BUTTON_GAP_Y + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                      UI_BUTTON_SIZE_X,
                                      UI_BUTTON_SIZE_Y);
                //step switch button
                if (GUI.Button(buttonRect, "<size=20>Next Step</size>"))
                {
                    _uiElementTriggered = true;
                    OnNextStep();
                    return;
                }

                foreach (var cfdAttribute in _cfdManager.CfdAttributes)
                {
                    it++;
                    buttonRect = new Rect(Screen.width - UI_BUTTON_GAP_X - UI_BUTTON_SIZE_X,
                                          vmove + UI_BUTTON_GAP_Y + ((UI_BUTTON_GAP_Y + UI_BUTTON_SIZE_Y) * it),
                                          UI_BUTTON_SIZE_X,
                                          UI_BUTTON_SIZE_Y);
                    //step switch button
                    if (GUI.Button(buttonRect, "<size=20>" + cfdAttribute + "</size>"))
                    {
                        _uiElementTriggered = true;
                        OnSwitchToAttrib(cfdAttribute);
                        return;
                    }
                }
            }
        }

        //draw and display output
        if (_fileBrowser != null && _fileBrowser.draw()) //true is returned when a file has been selected
                                                         //the output file is a member if the FileInfo class, if cancel was selected the value is null
        {
            if (_fileBrowser.outputFile != null)
            {
                _uiElementTriggered = true;

                var output = _fileBrowser.outputFile;
                _fileBrowser = null;
                bool fromSvr = false;
                if (_svrFileList.Count > 0)
                {
                    _svrFileList.Clear();
                    fromSvr = true;
                }
                switch (_loadMode)
                {
                case FileLoadMode.Scan:
                    if (fromSvr)
                    {
                        _cfdManager.LoadDataFromServer("scan/" + output.Name, output.Name, p => _cfdManager.LoadScanned(p));
                    }
                    else
                    {
                        _cfdManager.LoadScanned(output.FullName);
                    }
                    break;

                case FileLoadMode.CFD:
                    if (fromSvr)
                    {
                        _cfdManager.LoadDataFromServer("slices/" + output.Name, output.Name,
                                                       p => _cfdManager.LoadCfd(p));
                    }
                    else
                    {
                        _cfdManager.LoadCfd(output.FullName);
                    }
                    _cfdManager.ResetTimeStep();
                    break;

                case FileLoadMode.Tube:
                    if (fromSvr)
                    {
                        _cfdManager.LoadDataFromServer("tubes/" + output.Name, output.Name,
                                                       p => _cfdManager.LoadTube(p));
                    }
                    else
                    {
                        _cfdManager.LoadTube(output.FullName);
                    }
                    _cfdManager.ResetTimeStep();
                    break;
                }
            }
            _fileBrowser = null;
            return;
        }

        _uiElementTriggered = false;
        #endregion
    }
Esempio n. 9
0
    /// <summary>
    /// Display simple GUI.
    /// </summary>
    public void OnGUI()
    {
        if (GameObject.FindObjectOfType <ARMarker> () == null)
        {
            Texture2D placeTableTexture = (Texture2D)Resources.Load("PlaceTable");
            Rect      playRect          = new Rect((Screen.width - 1206) / 2, 20, 1206, 109);
            GUI.Button(playRect, placeTableTexture);
        }

        if (GameObject.FindObjectOfType <ARMarker> () != null && beerPongComponent != null && !beerPongComponent.isActive)
        {
            Rect distortionButtonRec = new Rect(Screen.width - UI_BUTTON_SIZE_X - UI_BUTTON_GAP_X,
                                                Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                                UI_BUTTON_SIZE_X,
                                                UI_BUTTON_SIZE_Y);
            if (GUI.Button(distortionButtonRec,
                           UI_FONT_SIZE + "Continue" + "</size>"))
            {
                GameObject.DestroyImmediate(m_canvas.gameObject);

                if (beerPongComponent != null)
                {
                    beerPongComponent.ActivateGame();
                }
                Debug.Log("Activated game elements");
                //Logic for Continue button goes here
            }
        }

        if (m_showDebug && m_tangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.white;

            GUI.color = Color.black;
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TANGO_SERVICE_VERSION, m_tangoServiceVersion) + "</size>");

            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_FPS_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + m_fpsText + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y - UI_LABEL_OFFSET,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + String.Format(UX_TARGET_TO_BASE_FRAME, "Device", "Start") + "</size>");

            Vector3    pos            = m_tangoPose.transform.position;
            Quaternion quat           = m_tangoPose.transform.rotation;
            string     positionString = pos.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                        pos.z.ToString(UI_FLOAT_FORMAT);
            string rotationString = quat.x.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.y.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.z.ToString(UI_FLOAT_FORMAT) + ", " +
                                    quat.w.ToString(UI_FLOAT_FORMAT);
            string statusString = String.Format(UX_STATUS,
                                                _GetLoggingStringFromPoseStatus(m_tangoPose.m_poseStatus),
                                                _GetLoggingStringFromFrameCount(m_tangoPose.m_poseCount),
                                                positionString, rotationString);
            GUI.Label(new Rect(UI_LABEL_START_X,
                               UI_POSE_LABEL_START_Y,
                               UI_LABEL_SIZE_X,
                               UI_LABEL_SIZE_Y),
                      UI_FONT_SIZE + statusString + "</size>");
            GUI.color = oldColor;
        }

        if (m_selectedMarker != null)
        {
            Renderer selectedRenderer = m_selectedMarker.GetComponent <Renderer>();

            // GUI's Y is flipped from the mouse's Y
            Rect  screenRect = WorldBoundsToScreen(Camera.main, selectedRenderer.bounds);
            float yMin       = Screen.height - screenRect.yMin;
            float yMax       = Screen.height - screenRect.yMax;
            screenRect.yMin = Mathf.Min(yMin, yMax);
            screenRect.yMax = Mathf.Max(yMin, yMax);

            if (GUI.Button(screenRect, "<size=30>Hide</size>"))
            {
                m_selectedMarker.SendMessage("Hide");
                m_selectedMarker = null;
                m_selectedRect   = new Rect();
            }
            else
            {
                m_selectedRect = screenRect;
            }
        }
        else
        {
            m_selectedRect = new Rect();
        }

        if (GameObject.FindObjectOfType <ARMarker>() != null && beerPongComponent != null && !beerPongComponent.isActive)
        {
            Texture2D placeTableTexture = (Texture2D)Resources.Load("DragTable");
            Rect      playRect          = new Rect((Screen.width - 790) / 2, 20, 790, 109);
            GUI.Button(playRect, placeTableTexture);



            m_hideAllRect = new Rect(UI_BUTTON_GAP_X,
                                     Screen.height - UI_BUTTON_SIZE_Y - UI_BUTTON_GAP_X,
                                     UI_BUTTON_SIZE_X,
                                     UI_BUTTON_SIZE_Y);
            if (GUI.Button(m_hideAllRect, "<size=30>Place Again</size>"))
            {
                foreach (ARMarker marker in GameObject.FindObjectsOfType <ARMarker>())
                {
                    marker.SendMessage("Hide");
                }
            }
        }
        else
        {
            m_hideAllRect = new Rect(0, 0, 0, 0);
        }
    }
Esempio n. 10
0
    private void OnGUI()
    {
        if (TangoApplication.HasRequestedPermissions())
        {
            Color oldColor = GUI.color;
            GUI.color = Color.black;

            if (!TangoApplication.HasGrantedPermissions())
            {
                GUI.Label(new Rect(Common.UI_LABEL_START_X,
                                   Common.UI_LABEL_START_Y,
                                   Common.UI_LABEL_SIZE_X,
                                   Common.UI_LABEL_SIZE_Y), "<size=15>" + Common.TANGO_NO_PERMISSIONS_ERROR + "</size>");
                return;
            }

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_TANGO_SERVICE_VERSION, m_tangoServiceVersionName) + "</size>");

            // MOTION TRACKING
            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_TARGET_TO_BASE_FRAME,
                                                                                    TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE,
                                                                                    TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE) + "</size>");

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 2,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_STATUS,
                                                                                    m_status[0],
                                                                                    m_frameCount[0],
                                                                                    m_frameDeltaTime[0],
                                                                                    m_tangoPosition[0],
                                                                                    m_tangoRotation[0]) + "</size>");

            // ADF
            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 3,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_TARGET_TO_BASE_FRAME,
                                                                                    TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE,
                                                                                    TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION) + "</size>");

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 4,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_STATUS,
                                                                                    m_status[1],
                                                                                    m_frameCount[1],
                                                                                    m_frameDeltaTime[1],
                                                                                    m_tangoPosition[1],
                                                                                    m_tangoRotation[1]) + "</size>");

            // RELOCALIZATION
            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 5,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_TARGET_TO_BASE_FRAME,
                                                                                    TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION,
                                                                                    TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE) + "</size>");

            GUI.Label(new Rect(Common.UI_LABEL_START_X,
                               Common.UI_LABEL_START_Y + Common.UI_LABEL_OFFSET * 6,
                               Common.UI_LABEL_SIZE_X,
                               Common.UI_LABEL_SIZE_Y), "<size=15>" + String.Format(Common.UX_STATUS,
                                                                                    m_status[2],
                                                                                    m_frameCount[2],
                                                                                    m_frameDeltaTime[2],
                                                                                    m_tangoPosition[2],
                                                                                    m_tangoRotation[2]) + "</size>");

            GUI.color = oldColor;
        }
    }