Example #1
0
        private void DrawDisplaySection()
        {
            ZCore core = (ZCore)this.target;

            int    numDisplays = core.IsInitialized() ? core.GetNumDisplays() : 0;
            string sectionName = (numDisplays == 1) ? "Display" : "Displays";

            _isDisplaySectionExpanded = this.DrawSectionHeader(sectionName, _displayIconTexture, _isDisplaySectionExpanded);
            if (_isDisplaySectionExpanded)
            {
                for (int i = 0; i < numDisplays; ++i)
                {
                    IntPtr displayHandle = core.GetDisplay(i);
                    string displayName   = string.Format("{0}. {1}{2} ({3})",
                                                         core.GetDisplayNumber(displayHandle),
                                                         core.GetDisplayAttributeString(displayHandle, ZCore.DisplayAttribute.ManufacturerName),
                                                         core.GetDisplayAttributeString(displayHandle, ZCore.DisplayAttribute.ProductCode),
                                                         core.GetDisplayType(displayHandle));

                    EditorGUILayout.LabelField(displayName);
                    EditorGUI.indentLevel++;
                    {
                        GUI.enabled = false;
                        EditorGUILayout.Vector2Field(new GUIContent("Position"), core.GetDisplayPosition(displayHandle));
                        EditorGUILayout.Vector2Field(new GUIContent("Size"), core.GetDisplaySize(displayHandle));
                        EditorGUILayout.Vector2Field(new GUIContent("Resolution"), core.GetDisplayNativeResolution(displayHandle));
                        EditorGUILayout.Vector3Field(new GUIContent("Angle"), core.GetDisplayAngle(displayHandle));
                        GUI.enabled = true;
                    }
                    EditorGUI.indentLevel--;
                    EditorGUILayout.Space();
                }
                EditorGUILayout.Space();
            }
        }
Example #2
0
        private void DrawStereoRigSection()
        {
            ZCore core = (ZCore)this.target;

            _isStereoRigSectionExpanded = this.DrawSectionHeader("Stereo Rig", _cameraIconTexture, _isStereoRigSectionExpanded);
            if (_isStereoRigSectionExpanded)
            {
                EditorGUILayout.PropertyField(this.CurrentCameraObjectProperty, new GUIContent("Current Camera"));
                EditorGUILayout.Space();

                _viewportCenter   = EditorGUILayout.Vector3Field(new GUIContent("Viewport World Center"), _viewportCenter);
                _viewportRotation = EditorGUILayout.Vector3Field(new GUIContent("Viewport World Rotation"), _viewportRotation);

                GUI.enabled = core.IsInitialized();
                if (GUILayout.Button(new GUIContent("Update Current Camera Transform")))
                {
                    Vector3 displayAngle     = core.GetDisplayAngle();
                    Vector3 cameraOffset     = core.GetFrustumCameraOffset();
                    Vector3 displayDirection = Quaternion.Euler(-displayAngle.x, 0.0f, 0.0f) * Vector3.forward;
                    float   angle            = Vector3.Angle(cameraOffset.normalized, displayDirection.normalized);

                    Quaternion cameraRotation = Quaternion.Euler(_viewportRotation) * Quaternion.Euler(90.0f - angle, 0.0f, 0.0f);
                    Vector3    cameraPosition = core.ComputeCameraPosition(_viewportCenter, cameraRotation);

                    if (core.CurrentCameraObject != null)
                    {
                        core.CurrentCameraObject.transform.position = cameraPosition;
                        core.CurrentCameraObject.transform.rotation = cameraRotation;
                    }
                }
                GUI.enabled = true;
                EditorGUILayout.Space();

                this.DrawToggleLeft("Enable Stereo", this.EnableStereoProperty);
                this.DrawToggleLeft("Enable Auto-Transition to Mono", this.EnableAutoStereoProperty);
                this.DrawToggleLeft("Copy Current Camera Attributes", this.CopyCurrentCameraAttributesProperty);
                this.DrawToggleLeft("Minimize Latency", this.MinimizeLatencyProperty);

                if (this.MinimizeLatencyProperty.boolValue)
                {
                    EditorGUILayout.HelpBox(
                        "Minimizing latency may cause undesirable effects with respect to maintaining " +
                        "synchronization between the head pose queryable through ZCore.GetTargetPose() " +
                        "and the head pose used to calculate the view/projection matrices for the " +
                        "ZCore stereo rig.",
                        MessageType.Warning);
                }

                EditorGUILayout.Space();

                EditorGUILayout.Slider(this.IpdProperty, 0.0f, 0.1f, new GUIContent("IPD"));
                EditorGUILayout.Slider(this.ViewerScaleProperty, 0.001f, 500.0f, new GUIContent("Viewer Scale"));
                EditorGUILayout.Slider(this.AutoStereoDelayProperty, 0.0f, 60.0f, new GUIContent("Auto Stereo Delay"));
                EditorGUILayout.Slider(this.AutoStereoDurationProperty, 0.0f, 60.0f, new GUIContent("Auto Stereo Duration"));
                EditorGUILayout.Space();
            }
        }