public void Connect() { if (!NCamPlugin.NCamIsOpen() && !reconnecting) { StartCoroutine(StartNCam()); } }
void Update() { //if (Input.GetKeyDown(KeyCode.F3) && Input.GetKey(KeyCode.LeftControl)) // showGUI = !showGUI; if (!NCamPlugin.NCamIsOpen() && !reconnecting && Config.AutoConnection) { StartCoroutine(StartNCam()); } }
public Status GetStatus() { if (reconnecting) { return(Status.Connecting); } else if (NCamPlugin.NCamIsOpen()) { return(Status.Connected); } else { return(Status.Disconnected); } }
private IEnumerator StartNCam() { reconnecting = true; yield return(new WaitForEndOfFrame()); StopNCam(); NCamPlugin.NCamResetError(); NCamPlugin.NCamSetPacketType(true, true, true); yield return(new WaitForEndOfFrame()); NCamPlugin.NCamSetIpAddress(Config.Ip, Config.Port); GL.IssuePluginEvent(NCamPlugin.GetNCamRenderEventFunc(), (int)NCamRenderEvent.Initialize); yield return(new WaitForEndOfFrame()); reconnecting = false; while (true) { // Wait until all frame rendering is done yield return(new WaitForEndOfFrame()); if (!NCamPlugin.NCamIsOpen()) { yield return(null); } if (distortionMap == null) { yield return(CreateDistortMap()); } GL.IssuePluginEvent(NCamPlugin.GetNCamRenderEventFunc(), (int)NCamRenderEvent.Update); // Check if we got a valid packet if (NCamPlugin.NCamOpticalTimeCode(Optical.Handle.AddrOfPinnedObject()) > 0) { UpdateCameras(); GL.IssuePluginEvent(NCamPlugin.GetNCamRenderEventFunc(), (int)NCamRenderEvent.UpdateDistortion); } } }