示例#1
0
 /// <summary>
 /// Unity Monobehavior function. ARUWPVideo is set here. Target the render frame rate to 60.
 /// Create unaddedMarkers list, preparing the initialization. [internal use]
 /// </summary>
 private void Start()
 {
     videoManager = GetComponent <ARUWPVideo>();
     if (videoManager == null)
     {
         Debug.Log(TAG + ": not able to find ARUWPVideo");
         Application.Quit();
     }
     Application.targetFrameRate = 60;
     unaddedMarkers = GetComponents <ARUWPMarker>();
 }
示例#2
0
    /// <summary>
    /// Unity Monobehavior function. ARUWPVideo is set here. Target the render frame rate to 60.
    /// Create unaddedMarkers list, preparing the initialization. [internal use]
    /// </summary>
    private void Start()
    {
        rosConnector = (RosSharp.RosBridgeClient.RosConnector)GetComponentInParent(typeof(RosSharp.RosBridgeClient.RosConnector));

        videoManager = GetComponent <ARUWPVideo>();
        if (videoManager == null)
        {
            Debug.Log(TAG + ": not able to find ARUWPVideo");
            Application.Quit();
        }
        Application.targetFrameRate = 60;
        unaddedMarkers = GetComponents <ARUWPMarker>();
    }
示例#3
0
        public void Start()
        {
            UltrasoundTracker = GameObject.Find("UltrasoundTracker").GetComponent <ARUWPVideo>();

#if NETFX_CORE
            Conductor.Instance.LocalStreamEnabled = true;
            Debug.Log("setting up spatial coordinate system");
            IntPtr spatialCoordinateSystemPtr = UnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr();
            Conductor.Instance.InitializeSpatialCoordinateSystem(spatialCoordinateSystemPtr);

            Conductor.Instance.IncomingRawMessage += Conductor_IncomingRawMessage;
            Conductor.Instance.OnSelfRawFrame     += Conductor_OnSelfRawFrame;

            Conductor.Instance.Initialized += Conductor_Initialized;
            Conductor.Instance.Initialize(CoreApplication.MainView.CoreWindow.Dispatcher);
            Conductor.Instance.EnableLogging(Conductor.LogLevel.Verbose);
            Debug.Log("done setting up the rest of the conductor");

            // add the button to connect to server
            Configurations.Instance.AddCallback("*_Connect", () =>
            {
                if (WebRTCStatus == WebRTCStatuses.NotConnected)
                {
                    new Task(() =>
                    {
                        Conductor.Instance.StartLogin(ServerAddress, ServerPort, ClientName);
                    }).Start();
                    WebRTCStatus = WebRTCStatuses.Connecting;
                }
                else if (WebRTCStatus == WebRTCStatuses.Connected)
                {
                    new Task(() =>
                    {
                        var task = Conductor.Instance.DisconnectFromServer();
                    }).Start();

                    WebRTCStatus = WebRTCStatuses.Disconnecting;
                }
            });
            // add the button to initiate the call
            Configurations.Instance.AddCallback("*_Call", () =>
            {
                if (WebRTCStatus == WebRTCStatuses.Connected && PeerName != null)
                {
                    new Task(() =>
                    {
                        // given the selectedPeerIndex, find which remote peer that matches.
                        // Note: it's not just that index in Conductor.Instance.GetPeers() because that list contains both remote peers and ourselves.
                        Conductor.Peer selectedConductorPeer = null;

                        var conductorPeers = Conductor.Instance.GetPeers();
                        foreach (var conductorPeer in conductorPeers)
                        {
                            if (conductorPeer.Name == MentorName)
                            {
                                selectedConductorPeer = conductorPeer;
                                break;
                            }
                        }

                        if (selectedConductorPeer != null)
                        {
                            Conductor.Instance.ConnectToPeer(selectedConductorPeer);
                        }
                    }).Start();
                    WebRTCStatus = WebRTCStatuses.Calling;
                }
                else if (WebRTCStatus == WebRTCStatuses.InCall)
                {
                    new Task(() =>
                    {
                        var task = Conductor.Instance.DisconnectFromPeer(MentorName);
                    }).Start();
                    WebRTCStatus = WebRTCStatuses.EndingCall;
                }
            });
#endif
            Configurations.Instance.SetAndAddCallback("ConnectionWebRTC_AROverlay", AROverlay,
                                                      v => { AROverlay = v; UpdatePreferredFrameFormat(); });
            Configurations.Instance.SetAndAddCallback("ConnectionWebRTC_VideoWidth", VideoWidth,
                                                      v => { VideoWidth = v; UpdatePreferredFrameFormat(); });
            Configurations.Instance.SetAndAddCallback("ConnectionWebRTC_VideoHeight", VideoHeight,
                                                      v => { VideoHeight = v; UpdatePreferredFrameFormat(); });
            Configurations.Instance.SetAndAddCallback("ConnectionWebRTC_VideoFrameRate", VideoFrameRate,
                                                      v => { VideoFrameRate = v; UpdatePreferredFrameFormat(); });
            Configurations.Instance.SetAndAddCallback("Stabilization_SavePose", SaveVideo, v =>
            {
                if (SaveVideo = v)
                {
                    VideoFrames       = File.Create(Utilities.FullPath(Utilities.TimeNow() + ".txt"));
                    VideoBinaryWriter = new BinaryWriter(VideoFrames);
                }
                else
                {
                    VideoBinaryWriter.Dispose();
                    VideoFrames.Dispose();
                }
            }, Configurations.RunOnMainThead.YES, Configurations.WaitUntilDone.YES);
        }
示例#4
0
    void Start()
    {
        {
            // look for the ARUWP Video component. If it exists, and "Initialize Video Here" is false, then it's the responsibility of ControlScript to give it frames.
            Debug.Log("Looking for ARUWPVideo...");
            GameObject go = GameObject.Find("ARUWP Controller");
            if (go != null)
            {
                aruwpVideo = go.GetComponent <ARUWPVideo>();
                if (aruwpVideo != null)
                {
                    if (aruwpVideo.initializeVideoHere)
                    {
                        Debug.Log("ARUWPVideo has initializeVideoHere=true, so it is handling its own receiving of frames. (This may mean that WebRTC streaming won't work).");
                        shouldSendFramesToAruwpVideo = false;
                    }
                    else
                    {
                        Debug.Log("ARUWPVideo has initializeVideoHere=false. ControlScript's responsibility to send frames to ARUWPVideo. Tracking will only work when WebRTC connection is established.");
                        shouldSendFramesToAruwpVideo = true;
                    }
                }
                else
                {
                    Debug.Log("Did not find ARUWPVideo component on the ARUWP Controller object");
                }
            }
            else
            {
                Debug.Log("Did not find object with name 'ARUWP Controller'");
            }
        }



        /*
         * Debug.Log("NOTE: creating some mock remote peers to test UI");
         * for (int i = 0; i < 5; i++)
         * {
         *  string mockName = "mock-peer-" + UnityEngine.Random.value;
         *  if (i == 0)
         *  {
         *      mockName = ClientName; // testing to make sure we can't accidentally call ourselves
         *  }
         *  AddRemotePeer(mockName);
         * }
         */



#if !UNITY_EDITOR
        Debug.Log("Setting LocalStreamEnabled to " + LocalStreamEnabled);

        Conductor.Instance.LocalStreamEnabled = LocalStreamEnabled;
#endif

#if !UNITY_EDITOR
        // Set up spatial coordinate system for sending pose metadata
        Debug.Log("setting up spatial coordinate system");
        IntPtr spatialCoordinateSystemPtr = WorldManager.GetNativeISpatialCoordinateSystemPtr();
        if (spatialCoordinateSystemPtr.ToInt32() != 0)
        {
            Debug.Log("spatialCoordinateSystemPtr: " + spatialCoordinateSystemPtr.ToString());
            Conductor.Instance.InitializeSpatialCoordinateSystem(spatialCoordinateSystemPtr);
            Debug.Log("SetSpatialCoordinateSystem done");
        }
        else
        {
            Debug.Log("spatialCoordinateSystemPtr was null. Probably not running on a Mixed Reality headset. Skipping initing video pose data.");
        }


        Debug.Log("setting up the rest of the conductor...");

        Conductor.Instance.IncomingRawMessage += Conductor_IncomingRawMessage;
        Conductor.Instance.OnSelfRawFrame     += Conductor_OnSelfRawFrame;
        Conductor.Instance.OnPeerRawFrame     += Conductor_OnPeerRawFrame;

        Conductor.Instance.Initialized += Conductor_Initialized;
        Conductor.Instance.Initialize(CoreApplication.MainView.CoreWindow.Dispatcher);
        Conductor.Instance.EnableLogging(Conductor.LogLevel.Verbose);
        Debug.Log("done setting up the rest of the conductor");
#endif
        ServerAddressInputField.text = ServerAddress;
        ServerPortInputField.text    = ServerPort;
        ClientNameInputField.text    = ClientName;
    }