Beispiel #1
0
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        // get the reference of mesh
        MeshFilter mf = gameObject.GetComponent <MeshFilter>();

        if (mf == null)
        {
            MeshFilter meshFilter = (MeshFilter)gameObject.AddComponent(typeof(MeshFilter));
            meshFilter.mesh = m_mesh = new Mesh();
            MeshRenderer renderer = gameObject.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
            renderer.material.shader = Shader.Find("Mobile/Unlit (Supports Lightmap)");
        }
        else
        {
            m_mesh = mf.mesh;
        }
        m_isDirty = false;
        _CreateMesh();
        transform.localScale = new Vector3(transform.localScale.x,
                                           transform.localScale.y * -1.0f,
                                           transform.localScale.z);

        m_tangoApplication = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            // Request Tango permissions
            m_tangoApplication.RequestNecessaryPermissions();

            if (TangoApplication.HasGrantedPermissions())
            {
                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);
                }

                m_tangoApplication.ConnectToService();
            }
            else
            {
                UnityEngine.Debug.Log("Tango can't be initialized because of invalid permissions");
            }
        }
        else
        {
            UnityEngine.Debug.Log("No Tango Manager found in scene.");
        }
    }
Beispiel #2
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;
        }
    }
Beispiel #3
0
    private void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            // Request Tango permissions
            m_tangoApplication.RequestNecessaryPermissions();

            if (TangoApplication.HasGrantedPermissions())
            {
                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);
                }

                m_tangoApplication.ConnectToService();
            }
            else
            {
                Debug.Log("Tango can't be initialized because of invalid permissions");
            }
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }

        m_tangoServiceVersionName = TangoApplication.GetTangoServiceVersion();
    }
    /// <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;
    }
Beispiel #5
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;
        }
    }