示例#1
0
    /// <summary>
    ///  Set more variables once scene has loaded and all scripts are ready
    /// </summary>
    void Start()
    {
        Application.targetFrameRate = 60;

        // Initialize some variables
        m_tangoRotation    = Quaternion.identity;
        m_tangoPosition    = Vector3.zero;
        m_startPosition    = transform.position;
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        if (m_tangoApplication != null)
        {
            // Request Tango permissions
            m_tangoApplication.RegisterPermissionsCallback(PermissionsCallback);
            m_tangoApplication.RequestNecessaryPermissionsAndConnect();
            m_tangoApplication.Register(this);
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
    }
示例#2
0
    /// <summary>
    /// Unity Start() callback, we set up some initial values here.
    /// </summary>
    public void Start()
    {
        m_currentFPS          = 0;
        m_framesSinceUpdate   = 0;
        m_currentTime         = 0.0f;
        m_fpsText             = "FPS = Calculating";
        m_tangoApplication    = FindObjectOfType <TangoApplication>();
        m_tangoPose           = FindObjectOfType <TangoARPoseController>();
        m_arCameraPostProcess = FindObjectOfType <ARCameraPostProcess>();
        m_tangoServiceVersion = TangoApplication.GetTangoServiceVersion();

        m_tangoApplication.Register(this);

        #region Cfd
        _cfdManager = new CfdSceneManagerV2();
        _cfdManager.DefaultMaterial     = defaultMaterial;
        _cfdManager.VertexColorMaterial = vertexColorMaterial;
        _cfdManager.CfdShader           = shader;
        _cfdManager.Start();
        #endregion
    }
    /// <summary>
    /// Start is called on the frame when a script is enabled.
    /// </summary>
    public void Start()
    {
        m_tangoARScreen = GetComponent <TangoARScreen>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
    }
示例#4
0
    /// <summary>
    /// Unity Start function.
    /// </summary>
    public void Start()
    {
        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        if (tangoApplication != null)
        {
            tangoApplication.Register(this);
            if (AndroidHelper.IsTangoCorePresent())
            {
                tangoApplication.RequestPermissions();
            }
        }
        else
        {
            Debug.LogError("No Tango Manager found in scene." + Environment.StackTrace);
            return;
        }
#if UNITY_EDITOR
        PhotonNetwork.ConnectUsingSettings("0.1");
#endif
    }
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_occupancyManager = m_occupancyManagerObject.GetComponent <DynamicMeshManager> ();

        m_depthPoints = new float[m_maxPoints * 3];
        m_isDirty     = false;

        m_initCameraPosition = m_mainCamera.transform.position;

        m_coordinatePair.baseFrame   = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
        m_coordinatePair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;//FIX should be depth sensor

        m_quads = new GameObject[m_insertionCount];
        float size = 0.02f;

        for (int i = 0; i < m_insertionCount; i++)
        {
            m_quads[i] = (GameObject)GameObject.CreatePrimitive(PrimitiveType.Cube);
            m_quads[i].transform.localScale = new Vector3(size, size, size);
            m_quads[i].transform.parent     = transform;
        }


#if UNITY_ANDROID && !UNITY_EDITOR
        if (m_recordData)
        {
            PrepareRecording();
        }
#endif
        if (m_playbackData)
        {
            m_recordData = false;
            string filename = m_loadSessionID + ".dat";
            m_fileReader = new BinaryReader(File.Open(Application.persistentDataPath + "/" + filename, FileMode.Open));
            m_debugText  = "Loading from: " + filename + " " + m_fileReader.ToString();
        }

        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_tangoApplication.Register(this);
    }
示例#6
0
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_camera = GetComponent <Camera>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        tangoApplication.OnDisplayChanged += _OnDisplayChanged;
        m_arCameraPostProcess              = gameObject.GetComponent <ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }

            CommandBuffer buf = VideoOverlayProvider.CreateARScreenCommandBuffer();
            m_camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, buf);
            m_camera.AddCommandBuffer(CameraEvent.BeforeGBuffer, buf);
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled              = true;
                renderer.material.shader      = m_occlusionShader;
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
示例#7
0
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_tangoApplication.Register(this);

        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_cTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_cTuc.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_cTuc.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_cTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_triangles = new int[VERT_COUNT];
        m_colors    = new Color[VERT_COUNT];
        // Assign triangles, note: this is just for visualizing point in the mesh data.
        for (int i = 0; i < VERT_COUNT; i++)
        {
            m_triangles[i] = i;
            m_colors[i]    = Color.white;
        }

        //m_pointCloud = new List<GameObject>();
        m_subCloud = new GameObject("PointCloud");
        m_subCloud.AddComponent <MeshFilter>();
        m_subCloud.AddComponent <MeshRenderer>();
        Material newMat = Resources.Load("pointcloud", typeof(Material)) as Material;

        m_subCloud.GetComponent <MeshRenderer>().material = newMat;

        m_mesh = m_subCloud.GetComponent <MeshFilter>().mesh;
        m_mesh.Clear();
        m_mesh.triangles = m_triangles;
        m_mesh.colors    = m_colors;
        m_mesh.RecalculateBounds();
        m_mesh.RecalculateNormals();
    }
示例#8
0
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        m_arCameraPostProcess = gameObject.GetComponent <ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // Pass YUV textures to shader for process.
            YUVTexture textures = tangoApplication.GetVideoOverlayTextureYUV();
            m_screenMaterial.SetTexture("_YTex", textures.m_videoOverlayTextureY);
            m_screenMaterial.SetTexture("_UTex", textures.m_videoOverlayTextureCb);
            m_screenMaterial.SetTexture("_VTex", textures.m_videoOverlayTextureCr);
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled = true;

                // Set the renderpass as background renderqueue's number minus one. YUV2RGB shader executes in
                // Background queue which is 1000.
                // But since we want to write depth data to Z buffer before YUV2RGB shader executes so that YUV2RGB
                // data ignores Ztest from the depth data we set renderqueue of PointCloud as 999.
                renderer.material.renderQueue = BACKGROUND_RENDER_QUEUE - 1;
                renderer.material.SetFloat("point_size", POINTCLOUD_SPLATTER_UPSAMPLE_SIZE);
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
    /// <summary>
    /// Start is called on the frame when a script is enabled.
    /// </summary>
    public void Start()
    {
        if (rotationTarget == null)
        {
            rotationTarget = transform;
        }

        m_characterController = GetComponent <CharacterController>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        if (tangoApplication != null)
        {
            tangoApplication.Register(this);
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }

        SetPose(transform.position, transform.rotation);
        initPos = transform.position;
    }
示例#10
0
    /// <summary>
    /// Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
    /// </summary>
    public void Start()
    {
        m_adfMeshSavePath = Application.persistentDataPath + "/ADFMeshes";

        m_arPoseController = FindObjectOfType <TangoARPoseController>();
        m_tangoDynamicMesh = FindObjectOfType <TangoDynamicMesh>();

        m_areaDescriptionLoaderPanel.SetActive(true);
        m_meshBuildPanel.SetActive(false);
        m_meshInteractionPanel.SetActive(false);
        m_relocalizeImage.gameObject.SetActive(false);

        // Initialize tango application.
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
            if (AndroidHelper.IsTangoCorePresent())
            {
                m_tangoApplication.RequestPermissions();
            }
        }
    }
    /// <summary>
    /// Unity Start function.
    ///
    /// We find and assign pose controller and tango applicaiton, and register this class to callback events.
    /// </summary>
    public void Start()
    {
        // Constant matrix converting start of service frame to Unity world frame.
        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_dTuc = new Matrix4x4();
        m_dTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_dTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_deltaPoseController = FindObjectOfType <TangoDeltaPoseController>();
        m_tangoApplication    = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
        }
    }
示例#12
0
    /// @cond
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_tangoApplication.Register(this);
        m_tangoDeltaPoseController = FindObjectOfType <TangoDeltaPoseController>();
        m_unityWorldTStartService.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_colorCameraTUnityCamera.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Assign triangles, note: this is just for visualizing point in the mesh data.
        m_points = new Vector3[MAX_POINT_COUNT];

        m_mesh = GetComponent <MeshFilter>().mesh;
        m_mesh.Clear();

        m_renderer = GetComponent <Renderer>();
    }
示例#13
0
    /// <summary>
    /// Start is called on the frame when a script is enabled.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            if (AndroidHelper.IsTangoCorePresent())
            {
                // Request Tango permissions
                m_tangoApplication.RegisterPermissionsCallback(_OnTangoApplicationPermissionsEvent);
                m_tangoApplication.RequestNecessaryPermissionsAndConnect();
                m_tangoApplication.Register(this);
            }
            else
            {
                // If no Tango Core is present let's tell the user to install it!
                StartCoroutine(_InformUserNoTangoCore());
            }
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
    }
示例#14
0
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
#if UNITY_EDITOR
        // We must initialize this on the main Unity thread, since the value
        // is sometimes used within a separate saving thread.
        AreaDescription.GenerateEmulatedSavePath();
#endif

        m_tangoApplication = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);

            if (AndroidHelper.IsTangoCorePresent())
            {
                m_tangoApplication.RequestPermissions();
            }
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
    }
示例#15
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
            if (AndroidHelper.IsTangoCorePresent())
            {
                // Request Tango permissions
                m_tangoApplication.RequestPermissions();
                m_tangoServiceVersionName = TangoApplication.GetTangoServiceVersion();
            }
            else
            {
                // If no Tango Core is present let's tell the user to install it!
                StartCoroutine(_InformUserNoTangoCore());
            }
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
    }
示例#16
0
    // Use this for initialization
    void Start()
    {
        JLog("ITango Video Overlay Frame Forwarder  start()");

        // Open file for reading
        _FileStream =
            new System.IO.FileStream(Application.persistentDataPath + "data.yv12", System.IO.FileMode.Create,
                                     System.IO.FileAccess.Write);
        // Writes a block of bytes to this stream using data from
        // a byte array.

        // close file stream


        m_tangoApplication = FindObjectOfType <TangoApplication>();
//		m_tangoApplication.m_enableVideoOverlay = true;
//		m_tangoApplication.m_videoOverlayUseByteBufferMethod = true;

        cls_UnityPlayer = new AndroidJavaClass(m_activityTangoARClass);

        m_tangoApplication.Register(this);

        //        TangoEnvironmentalLighting t;
    }
示例#17
0
    /// <summary>
    /// Unity Awake callback.
    /// </summary>
    public void Awake()
    {
        m_tangoApplication = GameObject.FindObjectOfType <TangoApplication>();
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
        }

        m_meshes            = new Dictionary <Tango3DReconstruction.GridIndex, TangoSingleDynamicMesh>(100);
        m_gridIndexToUpdate = new List <Tango3DReconstruction.GridIndex>(100);

        // Cache the renderer and collider on this object.
        m_meshRenderer = GetComponent <MeshRenderer>();
        if (m_meshRenderer != null)
        {
            m_meshRenderer.enabled = false;
        }

        m_meshCollider = GetComponent <MeshCollider>();
        if (m_meshCollider != null)
        {
            m_meshCollider.enabled = false;
        }
    }
示例#18
0
 public TangoTouchProjector(TangoApplication tangoApplication, TangoPointCloud pointCloud)
 {
     _tangoApplication = tangoApplication;
     _pointCloud       = pointCloud;
     _tangoApplication.Register(this);
 }
示例#19
0
        IEnumerator Start()
        {
            // Register this event system to the Tango service.
            tango = FindObjectOfType <TangoApplication>();
            tango.Register(this);

            // Seconds past since the motion tracking has been lost.
            // When this reaches lostThreasholdSeconds, lostIndicator should be presented.
            float lostSeconds = 0;

            // Seconds past since the motion tracking has been active.
            // When this reaches hideIndicatorsSeconds, indicators should be hidden.
            float trackingSeconds = 0;

            while (true)
            {
                if (isConnected)
                {
                    if (isTracking)
                    {
                        trackingSeconds += Time.deltaTime;
                        lostSeconds      = 0;
                    }
                    else
                    {
                        lostSeconds    += Time.deltaTime;
                        trackingSeconds = 0;
                    }

                    if (isTracking && trackingSeconds < hideIndicatorsSeconds)
                    {
                        // trackingIndicator should be presented when
                        // the motion tracking is active and not too long time
                        // has passed since the tracking was established.
                        SetUIState(true);
                    }
                    else if (lostSeconds > lostThresholdSeconds)
                    {
                        // lostIndicator should be presented when
                        // the motion tracking is lost and a long enough time
                        // has passed since the tracking was lost.
                        SetUIState(false);
                    }
                    else
                    {
                        // Both indicators should be hidden when
                        // the motion tracking has been active for a long enough time,
                        // or not a long enough time has passed since the tracking was lost.
                        SetUIState(null);
                    }
                }
                else
                {
                    lostSeconds = trackingSeconds = 0;

                    // If the Tango service is not connected,
                    // the UI shouldn't present anything (should pretend being inactive).
                    SetUIState(null);
                }

                yield return(null);
            }
        }
    /// <summary>
    /// Start this instance.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();

        m_tangoApplication.Register(this);
    }
 public void Init(TangoApplication app)
 {
     Debug.Log("BloonController:Init()");
     m_tangoApplication = app;
     m_tangoApplication.Register(this);
 }
示例#22
0
        // Unity function
        void Start()
        {
            tango = FindObjectOfType <TangoApplication>();

            tango.Register(this);

            if (saveAdfButton)
            {
                saveAdfButton.onClick.AddListener(() => {
                    SaveCurrentADF();
                });
            }

            if (connectServiceButton)
            {
                connectServiceButton.onClick.AddListener(() => {
                    ConnectService();
                });
            }

            if (disconnectServiceButton)
            {
                disconnectServiceButton.onClick.AddListener(() => {
                    DisconnectService();
                });
            }

            if (learningAreaToggle)
            {
                learningAreaToggle.isOn = tango.m_enableAreaDescriptions;
                learningAreaToggle.onValueChanged.AddListener(shouldLearn => {
                    // Note that this won't change learning mode of (currently) running service.
                    // This will be applied to service from the next connection.
                    tango.m_areaDescriptionLearningMode = shouldLearn;
                });
            }

            if (requestPermissionsButton)
            {
                requestPermissionsButton.onClick.AddListener(() => {
                    Debug.Log("Requesting permissions...");
                    tango.RequestPermissions();
                    Debug.Log("Requested permissions.");
                });
            }

            if (selectAdfUI)
            {
                selectAdfUI.onAdfSelected += (adf) => {
                    selectedADF = adf;

                    // selectedADF may be null if creating a new ADF.
                    if (adfNameText)
                    {
                        if (selectedADF == null)
                        {
                            // If no ADF is currently selected, blank out the text field.
                            adfNameText.text = "";
                        }
                        else
                        {
                            // If an ADF is selected, reflect the name to the text field.
                            adfNameText.text = selectedADF.GetMetadata().m_name;
                        }
                    }
                };
            }
        }