Exemple #1
0
        /// <summary>
        /// A co-routine that checks for when the sensor becomes available.
        /// </summary>
        protected IEnumerator WaitForSensorAvailable()
        {
            int      timeoutMS = 4000;
            long     startTime = DateTime.Now.Ticks;
            TimeSpan elapsedTime;

            do
            {
                elapsedTime = new TimeSpan(DateTime.Now.Ticks - startTime);
                if (InputProfile.IsDeviceOn)
                {
                    break;
                }
                yield return(null);
            }while (elapsedTime.TotalMilliseconds < timeoutMS);

            if (!InputProfile.IsDeviceOn)
            {
                Debug.LogWarning("Cinema Mocap: Device failed to turn on. Ensure drivers are installed and your device is connected properly.");
                InputProfile.TurnOffDevice(); //profile can be "open" even when device isn't plugged in, close it.
            }
            else
            {
                Debug.Log("Cinema Mocap: Device started.");
                this.startTime = DateTime.Now;
            }
        }
Exemple #2
0
        public override void DrawInputSettings()
        {
            EditorGUILayout.BeginHorizontal();

            bool isDeviceActive = (InputProfile != null) && InputProfile.IsDeviceOn;

            EditorGUI.BeginDisabledGroup(isDeviceActive);

            GUIContent[] content = new GUIContent[inputProfiles.Count];
            for (int i = 0; i < inputProfiles.Count; i++)
            {
                content[i] = new GUIContent(inputProfiles[i].Attribute.ProfileName);
            }
            int tempSelection = EditorGUILayout.Popup(new GUIContent(INPUT), mocapProfileSelection, content);


            if (mocapProfileSelection != tempSelection || InputProfile == null)
            {
                mocapProfileSelection = tempSelection;

                InputProfile = Activator.CreateInstance(inputProfiles[mocapProfileSelection].Type) as InputProfile;
                InputProfile.FrameCaptured            += MocapProfile_SkeletonFrameCaptured;
                InputProfile.InputSkeletonTypeChanged += InputProfile_InputSkeletonTypeChanged;

                // Input Profile changed.
                inputProfileChanged();
            }

            EditorGUI.EndDisabledGroup();


            bool  toggleOn = false;
            Color temp     = GUI.color;

            if (InputProfile.IsDeviceOn)
            {
                GUI.color = Color.green;
                toggleOn  = GUILayout.Toggle(InputProfile.IsDeviceOn, ON, EditorStyles.miniButton, GUILayout.Width(40f));
            }
            else
            {
                GUI.color = Color.red;
                toggleOn  = GUILayout.Toggle(InputProfile.IsDeviceOn, OFF, EditorStyles.miniButton, GUILayout.Width(40f));
            }
            GUI.color = temp;

            if (toggleOn && !InputProfile.IsDeviceOn)
            {
                Debug.Log("Cinema Mocap: Starting your device...");
                InputProfile.TurnOnDevice();
                EditorCoroutine.start(WaitForSensorAvailable());
            }
            else if (!toggleOn && InputProfile.IsDeviceOn)
            {
                if (InputProfile != null)
                {
                    if (this.RecordingState != RecordingState.NotRecording)
                    {
                        StopRecording();
                    }
                    InputProfile.TurnOffDevice();
                }

                if (OutputProfile != null)
                {
                    OutputProfile.Reset();
                }
            }

            EditorGUILayout.EndHorizontal();

            InputProfile.DrawInputSettings();
        }