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
        //////////////////////////////////////////////////////////////////
        // Unity Monobehaviour Callbacks
        //////////////////////////////////////////////////////////////////

        void OnPreCull()
        {
            if (this.PreCull != null)
            {
                this.PreCull(this);
            }

            switch (this.Eye)
            {
            case ZCore.Eye.Left:
                ZCore.IssuePluginEvent(ZCore.PluginEvent.SetRenderTargetLeft);
                break;

            case ZCore.Eye.Right:
                ZCore.IssuePluginEvent(ZCore.PluginEvent.SetRenderTargetRight);
                break;

            case ZCore.Eye.Center:
                ZCore.IssuePluginEvent(ZCore.PluginEvent.FrameDone);
                ZCore.IssuePluginEvent(ZCore.PluginEvent.DisableStereo);
                GL.InvalidateState();

                // Disable the Unity camera to prevent the center stereo camera
                // from rendering.
                this.SetCameraEnabled(false);
                break;

            default:
                break;
            }
        }
Example #3
0
        private void LoadSerializedPropertyValues()
        {
            ZCore zCore = (ZCore)this.target;

            _viewportCenter   = this.Round(zCore.GetViewportWorldCenter());
            _viewportRotation = this.Round(zCore.GetViewportWorldRotation().eulerAngles);
        }
Example #4
0
        private void DrawStylusSection()
        {
            ZCore core = (ZCore)this.target;

            _isStylusSectionExpanded = this.DrawSectionHeader("Stylus", _stylusIconTexture, _isStylusSectionExpanded);
            if (_isStylusSectionExpanded)
            {
                this.DrawToggleLeft("Enable Mouse Emulation", this.EnableMouseEmulationProperty);
                this.DrawToggleLeft("Enable Mouse Auto-Hide", this.EnableMouseAutoHideProperty);
                EditorGUILayout.Space();

                EditorGUILayout.Slider(this.MouseAutoHideDelayProperty, 0.0f, 60.0f, new GUIContent("Mouse Auto-Hide Delay"));
                EditorGUILayout.Space();

                // Display pose information (readonly).
                if (core.IsInitialized())
                {
                    this.DrawPoseInfo("Tracker-Space Pose:", core.GetTargetPose(ZCore.TargetType.Primary, ZCore.CoordinateSpace.Tracker));
                    this.DrawPoseInfo("World-Space Pose:", core.GetTargetPose(ZCore.TargetType.Primary, ZCore.CoordinateSpace.World));
                }
                else
                {
                    EditorGUILayout.LabelField("Tracker-Space Pose: Unknown");
                    EditorGUILayout.LabelField("World-Space Pose: Unknown");
                }
            }
        }
Example #5
0
        private void RenderPreview(PreviewRenderMode renderMode)
        {
            // If the current camera isn't valid, early out.
            if (_currentCamera == null)
            {
                return;
            }

            // Check if the window size has changed. If it has,
            // recreate the preview window's associated resources
            // based on the new size.
            if (_windowWidth != _previousPreviewWindowWidth || _windowHeight != _previousPreviewWindowHeight)
            {
                this.DestroyPreviewResources();
                this.CreatePreviewResources();
            }

            // Disable the camera render callbacks while rendering the left
            // and right frames for the preview window.
            if (_cameraRenderCallbacks != null)
            {
                _cameraRenderCallbacks.enabled = false;
            }

            // Perform the render.
            switch (renderMode)
            {
            case PreviewRenderMode.LRPattern:
                this.RenderPreviewLRPattern();
                break;

            case PreviewRenderMode.Default:
                this.RenderPreviewDefault();
                break;

            default:
                break;
            }

            // Re-enable the camera render callbacks so that the center eye view
            // is rendered for the GameView window.
            if (_cameraRenderCallbacks != null)
            {
                _cameraRenderCallbacks.enabled = true;
            }

            // Set the stereo frame textures for the preview window.
            zcuSetPreviewStereoFrame(_leftPreviewNativeTexturePtr, _rightPreviewNativeTexturePtr);

            // Issue a plugin render event to copy the stereo frame textures to
            // underlying shared texture resources, which are available to the
            // preview window.
            ZCore.IssuePluginEvent(PluginEvent.CopyPreviewStereoFrame);

            // Update the previous window width and height in order to determine if they
            // have changed.
            _previousPreviewWindowWidth  = _windowWidth;
            _previousPreviewWindowHeight = _windowHeight;
        }
Example #6
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();
            }
        }
Example #7
0
        //////////////////////////////////////////////////////////////////
        // Section Draw Helpers
        //////////////////////////////////////////////////////////////////

        private void CheckCoreInitialized()
        {
            ZCore core = (ZCore)this.target;

            if (!core.IsInitialized())
            {
                EditorGUILayout.HelpBox(
                    "Failed to properly initialize the zSpace Core SDK. As a result, most zSpace " +
                    "Core functionality will be disabled. Please make sure that the zSpace System " +
                    "Software has been properly installed on your machine.",
                    MessageType.Error);
                EditorGUILayout.Space();
            }
        }
Example #8
0
        private void DrawStereoRigSection()
        {
            ZCore zCore = (ZCore)this.target;

            _isStereoRigSectionExpanded = this.DrawSectionHeader("Stereo Camera", _cameraIconTexture, _isStereoRigSectionExpanded);
            if (_isStereoRigSectionExpanded)
            {
                // Grab the previous stereo property values.
                Vector3 previousViewportCenter   = _viewportCenter;
                Vector3 previousViewportRotation = _viewportRotation;
                float   previousViewerScale      = zCore.ViewerScale;

                EditorGUILayout.PropertyField(this.CurrentCameraObjectProperty, new GUIContent("Current Camera"));
                EditorGUILayout.Space();

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

                this.DrawToggleLeft("Enable Auto-Transition to Mono", this.EnableAutoStereoProperty);
                EditorGUILayout.Space();

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

                // Update the viewport's transform.
                if (_viewportCenter != previousViewportCenter ||
                    _viewportRotation != previousViewportRotation ||
                    this.ViewerScaleProperty.floatValue != previousViewerScale)
                {
                    try
                    {
                        zCore.SetViewportWorldTransform(
                            _viewportCenter,
                            Quaternion.Euler(_viewportRotation),
                            this.ViewerScaleProperty.floatValue);

                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    }
                    catch
                    {
                        Debug.LogWarning("Failed to set viewport transform.");
                    }
                }
            }
        }
Example #9
0
        private void DrawInfoSection()
        {
            ZCore core = (ZCore)this.target;

            _isInfoSectionExpanded = this.DrawSectionHeader("General Info", _infoIconTexture, _isInfoSectionExpanded);
            if (_isInfoSectionExpanded)
            {
                string pluginVersion  = core.GetPluginVersion();
                string runtimeVersion = core.IsInitialized() ? core.GetRuntimeVersion() : "Unknown";

                EditorGUILayout.LabelField("Plugin Version: " + pluginVersion);
                EditorGUILayout.LabelField("Runtime Version: " + runtimeVersion);
                EditorGUILayout.Space();
            }
        }
Example #10
0
        private void DrawDebugSection()
        {
            _isDebugSectionExpanded = this.DrawSectionHeader("Debug", _debugIconTexture, _isDebugSectionExpanded);
            if (_isDebugSectionExpanded)
            {
                this.DrawToggleLeft("Show Labels", this.ShowLabelsProperty);
                this.DrawToggleLeft("Show Viewport (Zero Parallax)", this.ShowViewportProperty);
                this.DrawToggleLeft("Show Comfort Zone (Negative Parallax)", this.ShowCCZoneProperty);
                this.DrawToggleLeft("Show Comfort Zone (Positive Parallax)", this.ShowUCZoneProperty);
                this.DrawToggleLeft("Show Display", this.ShowDisplayProperty);
                this.DrawToggleLeft("Show Real-World Up", this.ShowRealWorldUpProperty);
                this.DrawToggleLeft("Show Ground Plane", this.ShowGroundPlaneProperty);
                this.DrawToggleLeft("Show Glasses", this.ShowGlassesProperty);
                this.DrawToggleLeft("Show Stylus", this.ShowStylusProperty);
                EditorGUILayout.Space();

                GUI.enabled = ZCore.IsPreviewWindowInitialized();
                if (!ZCore.IsPreviewWindowOpen())
                {
                    if (GUILayout.Button("Open Preview Window"))
                    {
                        ZCore.SetPreviewWindowEnabled(Application.isPlaying);
                        ZCore.OpenPreviewWindow();
                    }
                }
                else
                {
                    if (GUILayout.Button("Close Preview Window"))
                    {
                        ZCore.ClosePreviewWindow();
                    }
                }
                GUI.enabled = true;
                EditorGUILayout.Space();

                if (!ZCore.IsPreviewWindowInitialized())
                {
                    EditorGUILayout.HelpBox(
                        "The zSpace preview  window is only available for Unity's D3D11 rendering pipeline.",
                        MessageType.Warning);
                    EditorGUILayout.Space();
                }
            }
        }
Example #11
0
        private void DrawGlassesSection()
        {
            ZCore core = (ZCore)this.target;

            _isGlassesSectionExpanded = this.DrawSectionHeader("Glasses", _glassesIconTexture, _isGlassesSectionExpanded);
            if (_isGlassesSectionExpanded)
            {
                // Display pose information (readonly).
                if (core.IsInitialized())
                {
                    this.DrawPoseInfo("Tracker-Space Pose:", core.GetTargetPose(ZCore.TargetType.Head, ZCore.CoordinateSpace.Tracker));
                    this.DrawPoseInfo("World-Space Pose:", core.GetTargetPose(ZCore.TargetType.Head, ZCore.CoordinateSpace.World));
                }
                else
                {
                    EditorGUILayout.LabelField("Tracker-Space Pose: Unknown");
                    EditorGUILayout.LabelField("World-Space Pose: Unknown");
                }
            }
        }