Example #1
0
    void OnGUI()
    {
        longWord = GUI.TextField(new Rect(10, 10, 200, 30), readingAngle ? getAngle().ToString() : longWord, 20);

        if (GUI.Button(new Rect(10, 40, 200, 30), "SetElevation"))
        {
            angle = int.Parse(longWord);
            NuiWrapper.NuiCameraElevationSetAngle(angle);
            t = new Thread(setAngle);    //attempted a Paramaterized Thread to no avail
            t.Start();
            Thread.Sleep(0);
        }

        readingAngle = GUI.Toggle(new Rect(10, 80, 200, 30), readingAngle, "Read Angle");


        bool nNearMode = GUI.Toggle(new Rect(10, 160, 200, 20), NearMode, "Near Mode");

        if (nNearMode != NearMode)
        {
            NearMode = nNearMode;
            ZigInput.Instance.SetNearMode(NearMode);
        }
        bool nSeatedMode = GUI.Toggle(new Rect(10, 190, 200, 20), SeatedMode, "Seated Mode");
        bool nTrackSkeletonInNearMode = GUI.Toggle(new Rect(10, 220, 200, 20), TrackSkeletonInNearMode, "Track Skeleton In NearMode");

        if ((nSeatedMode != SeatedMode) || (TrackSkeletonInNearMode != nTrackSkeletonInNearMode))
        {
            SeatedMode = nSeatedMode;
            TrackSkeletonInNearMode = nTrackSkeletonInNearMode;
            ZigInput.Instance.SetSkeletonTrackingSettings(SeatedMode, TrackSkeletonInNearMode);
        }
    }
Example #2
0
    static int getAngle()
    {
        long angleOut;

        NuiWrapper.NuiCameraElevationGetAngle(out angleOut);
        return((int)angleOut);
    }
Example #3
0
    static void setAngle()
    {
        long a = (long)angle;

        NuiWrapper.NuiCameraElevationSetAngle(a);
        Thread.Sleep(0);
    }
        /// <summary>
        /// Attempt to turn on the Kinect 1 device.
        /// </summary>
        /// <returns>Returns true if Kinect 1 is initialized.</returns>
        public override bool TurnOnDevice()
        {
            settings.UpdateImage = true;

            ZigEditorInput.InputType = inputType;
            ZigEditorInput.Settings  = settings;

            ZigEditorInput.Instance.Init();

            long tilt = (long)desiredTilt;

            NuiWrapper.NuiCameraElevationGetAngle(out tilt);
            desiredTilt = (float)tilt;

            return(ZigEditorInput.Instance.ReaderInited);
        }
Example #5
0
    /// <summary>
    /// Load up the Zigfu driver and turn on the NUI device.
    /// </summary>
    private void turnOnNUIDevice()
    {
        settings.UpdateImage = true;

        ZigEditorInput.InputType = inputType;
        ZigEditorInput.Settings  = settings;

        ZigEditorInput.Instance.Init();
        isNUIOn = ZigEditorInput.Instance.ReaderInited;

        depthViewer = new ZigEditorDepthViewer();
        imageViewer = new ZigEditorImageViewer();
        //mixedViewer = new ZigEditorMixedViewer();
        usersRadar = new ZigEditorUsersRadar();
        usersRadar.Start();

        long tilt = (long)desiredTilt;

        NuiWrapper.NuiCameraElevationGetAngle(out tilt);
        desiredTilt = (float)tilt;
    }
        /// <summary>
        /// Draw the options panel for hardware device settings.
        /// </summary>
        public override void DrawInputSettings()
        {
            SmoothingOptions newSmoothingOptions = (SmoothingOptions)EditorGUILayout.EnumPopup(new GUIContent(SMOOTHING_OPTIONS), smoothingOptions);

            if (newSmoothingOptions != smoothingOptions)
            {
                smoothingOptions = newSmoothingOptions;
                if (smoothingOptions == SmoothingOptions.None)
                {
                    settings.KinectSDKSpecific.SmoothingParameters.SetNoSmoothing();
                }
                else if (smoothingOptions == SmoothingOptions.Light)
                {
                    settings.KinectSDKSpecific.SmoothingParameters.SetLightSmoothing();
                }
                else if (smoothingOptions == SmoothingOptions.Moderate)
                {
                    settings.KinectSDKSpecific.SmoothingParameters.SetModerateSmoothing();
                }
                else if (smoothingOptions == SmoothingOptions.Heavy)
                {
                    settings.KinectSDKSpecific.SmoothingParameters.Smoothing          = 0.6f;
                    settings.KinectSDKSpecific.SmoothingParameters.Correction         = 0.4f;
                    settings.KinectSDKSpecific.SmoothingParameters.Prediction         = 0.6f;
                    settings.KinectSDKSpecific.SmoothingParameters.JitterRadius       = 0.15f;
                    settings.KinectSDKSpecific.SmoothingParameters.MaxDeviationRadius = 0.10f;
                }
                else if (smoothingOptions == SmoothingOptions.Custom)
                {
                    settings.KinectSDKSpecific.SmoothingParameters.SetModerateSmoothing();
                }
                if (ZigEditorInput.Instance.ReaderInited)
                {
                    ZigEditorInput.Instance.SetSmoothingParameters((smoothingOptions != SmoothingOptions.None), settings.KinectSDKSpecific.SmoothingParameters);
                }
            }

            if (smoothingOptions == SmoothingOptions.Custom)
            {
                EditorGUI.indentLevel++;
                float tempSmoothing          = EditorGUILayout.Slider(new GUIContent("Smoothing"), settings.KinectSDKSpecific.SmoothingParameters.Smoothing, 0f, 1f);
                float tempCorrection         = EditorGUILayout.Slider(new GUIContent("Correction"), settings.KinectSDKSpecific.SmoothingParameters.Correction, 0f, 1f);
                float tempPrediction         = EditorGUILayout.Slider(new GUIContent("Prediction"), settings.KinectSDKSpecific.SmoothingParameters.Prediction, 0f, 1f);
                float tempJitterRadius       = EditorGUILayout.Slider(new GUIContent("JitterRadius"), settings.KinectSDKSpecific.SmoothingParameters.JitterRadius, 0f, 1f);
                float tempMaxDeviationRadius = EditorGUILayout.Slider(new GUIContent("MaxDeviationRadius"), settings.KinectSDKSpecific.SmoothingParameters.MaxDeviationRadius, 0f, 1f);
                EditorGUI.indentLevel--;

                if (settings.KinectSDKSpecific.SmoothingParameters.Smoothing != tempSmoothing ||
                    settings.KinectSDKSpecific.SmoothingParameters.Correction != tempCorrection ||
                    settings.KinectSDKSpecific.SmoothingParameters.Prediction != tempPrediction ||
                    settings.KinectSDKSpecific.SmoothingParameters.JitterRadius != tempJitterRadius ||
                    settings.KinectSDKSpecific.SmoothingParameters.MaxDeviationRadius != tempMaxDeviationRadius)
                {
                    settings.KinectSDKSpecific.SmoothingParameters.Smoothing          = tempSmoothing;
                    settings.KinectSDKSpecific.SmoothingParameters.Correction         = tempCorrection;
                    settings.KinectSDKSpecific.SmoothingParameters.Prediction         = tempPrediction;
                    settings.KinectSDKSpecific.SmoothingParameters.JitterRadius       = tempJitterRadius;
                    settings.KinectSDKSpecific.SmoothingParameters.MaxDeviationRadius = tempMaxDeviationRadius;
                    if (ZigEditorInput.Instance.ReaderInited)
                    {
                        ZigEditorInput.Instance.SetSmoothingParameters(true, settings.KinectSDKSpecific.SmoothingParameters);
                    }
                }
            }

            float newDesiredTilt = desiredTilt;

            EditorGUI.BeginDisabledGroup(!IsDeviceOn);
            newDesiredTilt = EditorGUILayout.IntSlider(new GUIContent(DEVICE_TILT), (int)desiredTilt, -27, 27);
            EditorGUI.EndDisabledGroup();

            if (newDesiredTilt != desiredTilt)
            {
                desiredTilt = newDesiredTilt;
                NuiWrapper.NuiCameraElevationSetAngle((long)desiredTilt);
            }
        }
Example #7
0
    /// <summary>
    /// Draw the Window's contents
    /// </summary>
    protected void OnGUI()
    {
        if (workingResolution == null)
        {
            workingResolution = ResolutionData.FromZigResolution(kinectCaptureResolution);
        }
        float aspectRatio    = workingResolution.Width / workingResolution.Height;
        float textureWidth   = (base.position.width - (UI_SPACING * 3)) / 2;
        float textureHeight  = textureWidth * aspectRatio;
        float newDesiredTilt = desiredTilt;

        if (isNUIOn && ZigEditorInput.Instance.ReaderInited)
        {
            if (viewerType == NUIViewerType.DepthViewer)
            {
                GUI.DrawTexture(new Rect(UI_SPACING, UI_SPACING, textureWidth, textureHeight), depthViewer.Texture);
            }
            else if (viewerType == NUIViewerType.ImageViewer)
            {
                GUI.DrawTexture(new Rect(UI_SPACING, UI_SPACING, textureWidth, textureHeight), imageViewer.Texture);
            }
            //else if (viewerType == NUIViewerType.DepthAndImageViewer)
            //{
            //    GUI.DrawTexture(new Rect(UI_SPACING, UI_SPACING, textureWidth, textureHeight), mixedViewer.Texture);
            //}
            if (captureState == RecordingState.PreRecording)
            {
                int      timeLeft      = (int)(((delaySeconds * 1000) - stopwatch.ElapsedMilliseconds) / 1000) + 1;
                GUIStyle countdownFont = new GUIStyle(EditorStyles.label);
                countdownFont.fontSize         = (int)(textureHeight / 6);
                countdownFont.normal.textColor = Color.white;
                Vector2 size = countdownFont.CalcSize(new GUIContent(timeLeft.ToString()));
                GUI.Label(new Rect(textureWidth - (size.x), textureHeight - size.y, size.x, size.y), timeLeft.ToString(), countdownFont);
            }
            if (captureState == RecordingState.Recording)
            {
                GUI.DrawTexture(new Rect((textureWidth) - recordingImage.width, (UI_SPACING + textureHeight) - recordingImage.height, recordingImage.width, recordingImage.height), recordingImage);
            }
            GUI.DrawTexture(new Rect((UI_SPACING * 2) + textureWidth, UI_SPACING, textureWidth, textureHeight), radarLogo);
            usersRadar.Render(ZigEditorInput.Instance, new Rect((UI_SPACING * 2) + textureWidth, UI_SPACING, textureWidth, textureHeight));
        }
        else if (mocapLogo != null && workingResolution != null)
        {
            // Draw place holders
            GUI.DrawTexture(new Rect(UI_SPACING, UI_SPACING, textureWidth, textureHeight), mocapLogo);
            GUI.DrawTexture(new Rect((UI_SPACING * 2) + textureWidth, UI_SPACING, textureWidth, textureHeight), radarLogo);
        }

        float panelHeight = base.position.height - textureHeight - (UI_SPACING * 3);

        if (panelHeight > 5)
        {
            GUILayout.BeginArea(new Rect(UI_SPACING, textureHeight + (UI_SPACING * 2), textureWidth, panelHeight), string.Empty, "box");
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(new GUIContent(DEVICE_TRACKING));
                bool  toggleOn = false;
                Color temp     = GUI.color;
                if (isNUIOn)
                {
                    GUI.color = Color.green;
                    toggleOn  = GUILayout.Toggle(isNUIOn, ON, EditorStyles.miniButton);
                }
                else
                {
                    GUI.color = Color.red;
                    toggleOn  = GUILayout.Toggle(isNUIOn, OFF, EditorStyles.miniButton);
                }
                GUI.color = temp;
                EditorGUILayout.EndHorizontal();

                if (toggleOn && !isNUIOn)
                {
                    turnOnNUIDevice();
                }
                else if (!toggleOn && isNUIOn)
                {
                    turnOffNUIDevice();
                }

                viewerType = (NUIViewerType)EditorGUILayout.EnumPopup(new GUIContent(VIEWER), viewerType);

                List <GUIContent> resolutions = new List <GUIContent>();
                foreach (string name in Enum.GetNames(typeof(ZigResolution)))
                {
                    resolutions.Add(new GUIContent(name.Replace('_', ' ')));
                }
                kinectCaptureResolution = (ZigResolution)EditorGUILayout.Popup(new GUIContent(KINECT_RESOLUTION), (int)kinectCaptureResolution, resolutions.ToArray());

                SmoothingOptions newSmoothingOptions = (SmoothingOptions)EditorGUILayout.EnumPopup(new GUIContent(SMOOTHING_OPTIONS), smoothingOptions);
                if (newSmoothingOptions != smoothingOptions)
                {
                    smoothingOptions = newSmoothingOptions;
                    if (smoothingOptions == SmoothingOptions.None)
                    {
                        settings.KinectSDKSpecific.SmoothingParameters.SetNoSmoothing();
                    }
                    else if (smoothingOptions == SmoothingOptions.Light)
                    {
                        settings.KinectSDKSpecific.SmoothingParameters.SetLightSmoothing();
                    }
                    else if (smoothingOptions == SmoothingOptions.Moderate)
                    {
                        settings.KinectSDKSpecific.SmoothingParameters.SetModerateSmoothing();
                    }
                    else if (smoothingOptions == SmoothingOptions.Heavy)
                    {
                        settings.KinectSDKSpecific.SmoothingParameters.Smoothing          = 0.6f;
                        settings.KinectSDKSpecific.SmoothingParameters.Correction         = 0.4f;
                        settings.KinectSDKSpecific.SmoothingParameters.Prediction         = 0.6f;
                        settings.KinectSDKSpecific.SmoothingParameters.JitterRadius       = 0.15f;
                        settings.KinectSDKSpecific.SmoothingParameters.MaxDeviationRadius = 0.10f;
                        //settings.KinectSDKSpecific.SmoothingParameters.SetHeavySmoothing();
                    }
                    ZigEditorInput.Instance.SetSmoothingParameters((smoothingOptions != SmoothingOptions.None), settings.KinectSDKSpecific.SmoothingParameters);
                }
                viewNodes = EditorGUILayout.Toggle(JOINT_VIEW, viewNodes);

                EditorGUI.BeginDisabledGroup(!isNUIOn);
                newDesiredTilt = EditorGUILayout.IntSlider(new GUIContent(DEVICE_TILT), (int)desiredTilt, -27, 27);
                EditorGUI.EndDisabledGroup();

                workingResolution = ResolutionData.FromZigResolution(kinectCaptureResolution);
            }
            GUILayout.EndArea();

            GUILayout.BeginArea(new Rect((UI_SPACING * 2) + textureWidth, textureHeight + (UI_SPACING * 2), textureWidth, panelHeight), String.Empty, "box");
            {
                fileName = EditorGUILayout.TextField(new GUIContent("Filename"), fileName);

                /*
                 * isFilterFoldout = EditorGUILayout.Foldout(isFilterFoldout, new GUIContent("Filters"));
                 * if (isFilterFoldout)
                 * {
                 *  EditorGUI.indentLevel = 1;
                 *  EditorGUILayout.Toggle(new GUIContent("Smooth"), false);
                 *  EditorGUILayout.Toggle(new GUIContent("Mirror"), false);
                 *  EditorGUILayout.Toggle(new GUIContent("Correct Sensor Tilt"), false);
                 *  EditorGUILayout.Toggle(new GUIContent("Correct Sensor Offset"), false);
                 *  EditorGUI.indentLevel = 0;
                 * }
                 *
                 * GUILayout.Space(UI_SPACING);*/
                //recordingStart = (RecordingStart)EditorGUILayout.EnumPopup(new GUIContent("Start On"), recordingStart);

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(new GUIContent("Model Preview"));
                if (GUILayout.Button("Generate"))
                {
                    createModelPreview();
                }
                EditorGUILayout.EndHorizontal();

                delaySelection = EditorGUILayout.Popup(new GUIContent("Start Delay"), delaySelection, delays);

                isAdvancedExposed = EditorGUILayout.Foldout(isAdvancedExposed, new GUIContent("Advanced"));
                if (isAdvancedExposed)
                {
                    transformationType = (TransformationType)EditorGUILayout.EnumPopup(new GUIContent("Transformation Type"), transformationType);
                }

                GUILayout.Space(UI_SPACING);
                EditorGUI.BeginDisabledGroup(!isNUIOn);
                if (GUILayout.Button(captureState == RecordingState.NotRecording ? new GUIContent("Record") : new GUIContent("Stop")))
                {
                    if (captureState == RecordingState.NotRecording)
                    {
                        BeginPreRecording();
                    }
                    else
                    {
                        StopRecording();
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            GUILayout.EndArea();
        }
        GUI.skin = null;

        if (newDesiredTilt != desiredTilt)
        {
            desiredTilt = newDesiredTilt;
            NuiWrapper.NuiCameraElevationSetAngle((long)desiredTilt);
        }
    }