Exemplo n.º 1
0
 /// <summary>
 /// Sets the default values.
 /// </summary>
 public void SetToDefault()
 {
     HasError = false;
     TargetDevices.Clear();
     NextDevice = false;
     Tag        = null;
 }
Exemplo n.º 2
0
    public CameraView Find(Camera cam, TargetDevices tgt, bool flipHand)
    {
        CameraView view = null;

        if (false == this.ContainsKey(cam))
        {
            view = new CameraView(this.Count(), cam, tgt, flipHand);
            Add(cam, view);
        }
        view = base[cam];
        return(view);
    }
Exemplo n.º 3
0
 /// <summary>
 /// Add or delete the target device by checked checkbox.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void checkBox_CheckedChanged(object sender, EventArgs e)
 {
     _targetDevices       = TargetDevices.None;
     btnPdfExport.Enabled = false;
     if (checkBoxPaper.Checked)
     {
         _targetDevices = _targetDevices ^ TargetDevices.Paper;
     }
     if (checkBoxPDF.Checked)
     {
         _targetDevices = _targetDevices ^ TargetDevices.Export;
     }
     if (checkBoxScreen.Checked)
     {
         _targetDevices = _targetDevices ^ TargetDevices.Screen;
     }
 }
Exemplo n.º 4
0
    public CameraView(int id, Camera cam, TargetDevices tgt, bool flipHand)
    {
        cameraId   = id;
        isFlipHand = flipHand;

        viewportWidth   = (float)cam.pixelWidth;
        viewportHeight  = (float)cam.pixelHeight;
        isGameCamera    = (cam.cameraType == CameraType.Game);
        isPreviewCamera = (cam.name == "Preview Camera");

        q1       = new Matrix4x4();
        q1       = Matrix4x4.identity;
        q1[1, 1] = -1.0f;

        if (tgt == TargetDevices.AutoDetect)
        {
            AutoDetectDevice();
        }
        else
        {
            ConfigureSetupMVP(tgt);
        }

        isStereoscopic = cam.stereoEnabled;
        if (cam.stereoEnabled)
        {
            if (cam.stereoTargetEye != StereoTargetEyeMask.Left && cam.stereoTargetEye != StereoTargetEyeMask.Right)
            {
                Debug.LogError("ERROR: stereo camera must be either Left or Right, cannot be 'None' or 'Both'");
                throw new Exception("Fix the camera settings");
            }
        }
        targetEye = (false == cam.stereoEnabled) ? StereoTargetEyeMask.Left : cam.stereoTargetEye;
        MVP       = new Matrix4x4();
        // When isGameCamera is true the plugin does backface culling and front face culling when false.
        _svfCamView = new SVFCameraView()
        {
            cameraId = cameraId, isGameCamera = isLeftHandedness, isStereoscopic = isStereoscopic, viewportWidth = viewportWidth, viewportHeight = viewportHeight, targetEye = targetEye
        };
    }
Exemplo n.º 5
0
    public void AutoDetectDevice()
    {
        TargetDevices tgt = TargetDevices.AutoDetect;

        if (XRSettings.enabled)
        {
            string stDevice = XRSettings.loadedDeviceName.ToLower();
            if (stDevice == "windowsmr")
            {
                tgt = TargetDevices.WindowsMixedReality;
            }
            else if (stDevice == "oculus")
            {
                tgt = TargetDevices.Oculus;
            }
            else if (stDevice == "openvr")
            {
                tgt = TargetDevices.Vive;
            }
        }
        ConfigureSetupMVP(tgt);
    }
Exemplo n.º 6
0
    public void ConfigureSetupMVP(TargetDevices tgt)
    {
        switch (tgt)
        {
        case TargetDevices.Vive:
        case TargetDevices.Oculus:
        case TargetDevices.PostEffects:
        case TargetDevices.WindowsMixedReality:
#if UNITY_5_6_OR_NEWER && !UNITY_EDITOR
        case TargetDevices.AutoDetect:
        case TargetDevices.AppStore:
        case TargetDevices.Hololens:
        case TargetDevices.PC:
#endif
            isLeftHandedness = isFlipHand;
            if (isPreviewCamera)
            {
                isLeftHandedness = !isFlipHand;
                q1[1, 1]         = 1.0f;
            }
            break;

#if !UNITY_5_6_OR_NEWER || UNITY_EDITOR
        case TargetDevices.AutoDetect:
        case TargetDevices.AppStore:
        case TargetDevices.Hololens:
        case TargetDevices.PC:
#endif
        case TargetDevices.Unity55PC:
        default:
            isLeftHandedness = isFlipHand ^ isGameCamera;
            if (isGameCamera)
            {
                q1[1, 1] = 1.0f;
            }
            break;
        }
    }
Exemplo n.º 7
0
 /// <summary>
 /// Layer Constructor.
 /// </summary>
 public LayersForm()
 {
     InitializeComponent();
     _targetDevices = TargetDevices.All;
 }
Exemplo n.º 8
0
        private void OnComPortEventReceived(PortEventType comPortEvent, string portNumber)
        {
            bool peformDeviceDiscovery = false;

            if (comPortEvent == PortEventType.Insertion)
            {
                peformDeviceDiscovery = true;
                //_ = LoggingClient.LogInfoAsync($"Comport Plugged. ComportNumber '{portNumber}'. Detecting a new connection...");
                Console.WriteLine($"Comport Plugged. ComportNumber '{portNumber}'. Detecting a new connection...");
            }
            else if (comPortEvent == PortEventType.Removal)
            {
                if (TargetDevices != null)
                {
                    // dispose of all existing connections so that device recovery re-validates them
                    var deviceDisconnected = TargetDevices.Where(a => a.DeviceInformation.ComPort.Equals(portNumber, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                    if (deviceDisconnected != null)
                    {
                        peformDeviceDiscovery = true;

                        // dispose of all connections so that device recovery re-validates them
                        foreach (var device in TargetDevices)
                        {
                            if (string.Equals(portNumber, device.DeviceInformation.ComPort, StringComparison.CurrentCultureIgnoreCase))
                            {
                                //_ = LoggingClient.LogInfoAsync($"Comport unplugged. ComportNumber '{portNumber}', " +
                                //    $"DeviceType '{device.ManufacturerConfigID}', SerialNumber '{device.DeviceInformation?.SerialNumber}'");
                                Console.WriteLine($"Comport unplugged. ComportNumber '{portNumber}', " +
                                                  $"DeviceType '{device.ManufacturerConfigID}', SerialNumber '{device.DeviceInformation?.SerialNumber}'");
                            }
                            device.Dispose();
                        }
                    }
                }
                //else
                //{
                //_ = LoggingClient.LogInfoAsync($"Comport unplugged. ComportNumber '{portNumber}', " +
                //    $"DeviceType '{TargetDevice?.ManufacturerConfigID}', SerialNumber '{TargetDevice?.DeviceInformation?.SerialNumber}'");
                //TargetDevice?.Dispose();
                //}

                Console.WriteLine($"Comport unplugged. ComportNumber '{portNumber}'");
            }
            else
            {
                //_ = LoggingClient.LogInfoAsync($"Comport Event '{comPortEvent}' is not implemented ");
                Console.WriteLine($"Comport Event '{comPortEvent}' is not implemented ");
            }

            // only perform discovery when an existing device is disconnected or a new connection is detected
            if (peformDeviceDiscovery)
            {
                //LoggingClient.LogInfoAsync($"Device recovery in progress...");
                Console.WriteLine($"Device recovery in progress...");

                if (currentStateAction.WorkflowStateType == DeviceWorkflowState.Manage)
                {
                    currentStateAction.DoDeviceDiscovery();
                }
                else
                {
                    StateActionRules.NeedsDeviceRecovery = true;

                    if (subStateController != null)
                    {
                        IDeviceSubStateManager subStateManager = subStateController as IDeviceSubStateManager;
                        subStateManager.ComportEventReceived(comPortEvent, portNumber);
                    }
                }
            }
        }