/// initializes the list of gestures to use. protected void InitGestureStrings() { NIInput inp = target as NIInput; if (inp.m_gestureManager == null || inp.m_gestureManager.m_gestures == null) { if (m_gestureStrings == null || m_gestureStrings.Length != 1) { m_gestureStrings = new string[1]; m_gestureStrings[0] = "No gesture"; return; } else { // we already have the gesture strings return; } } if (m_gestureStrings != null && m_gestureStrings.Length == inp.m_gestureManager.m_gestures.Length) { return; // it is already initialized properly. } m_gestureStrings = new string[inp.m_gestureManager.m_gestures.Length + 1]; for (int i = 0; i < inp.m_gestureManager.m_gestures.Length; i++) { m_gestureStrings[i] = inp.m_gestureManager.m_gestures[i].GetGestureType(); } m_gestureStrings[inp.m_gestureManager.m_gestures.Length] = "None"; }
private Rect tempRect; ///< @brief Temporary rectangle which sets the position of items (defined here to avoid creating on the fly). /// @brief mono-behavior start for initialization void Start() { m_mode = SkeletonGUIModes.SkeletonMode; // initialize all the external links if (m_input == null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) { throw new System.Exception("Please add an NIInput object to the scene"); } } if (m_settings == null) { m_settings = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_settings == null) { throw new System.Exception("Please add an OpenNISettingsManager object to the scene"); } } // a rect used later, this is mainly an initialization tempRect = new Rect(); tempRect.x = Screen.width / 2 - 60; tempRect.y = Screen.height / 2 - 20; tempRect.width = 120; tempRect.height = 40; m_controllers = FindObjectsOfType(typeof(NISkeletonController)) as NISkeletonController[]; NIGUI.SetActive(false); // we don't want to see the cursor yet so we deactivate NIGUI }
/// mono-behavior start - initializes the input public void Start() { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; // categories.Add(categoryStrings[0], upperGarment); //categories.Add(categoryStrings[1], pant); //categories.Add(categoryStrings[2], dress); //categories.Add(categoryStrings[3], shoes); //categories.Add(categoryStrings[4], accessory); //catTest[0] = upperGarment; //catArray.Add(upperGarment); }
/// the initialization (mono-behavior) public void Start() { m_initialPosition = transform.position; m_initialized = false; m_lastCallbackTime = -1.0f; m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) { throw new System.Exception("No NIInput in scene!!!"); } }
protected override void InternalAwake() { base.InternalAwake(); if (m_input == null) m_input = FindObjectOfType(typeof(NIInput)) as NIInput; m_lastClickFrame = -1; m_lastClickPos = Vector2.zero; m_lastClickTime = -1.0f; int rectSize=15; m_positionRect = new Rect(0, 0, rectSize, rectSize); m_texture = new Texture2D(1, 1); Color[] color = new Color[1]; color[0] = Color.green; m_texture.SetPixels(color); m_texture.Apply(); m_active = true; }
public void Start() { if(m_input==null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) throw new System.Exception("Please add an NIInput object to the scene"); } swipeRightDetector = new InputGestureDetector(m_input, "NIGUI_SWIPE_RIGHT"); swipeLeftDetector = new InputGestureDetector(m_input, "NIGUI_SWIPE_LEFT"); GUI.skin = menuSkin; singleImageWidth = Screen.width; singleImageHeight = Screen.height; container = new Rect(0,0,singleImageWidth,singleImageHeight); }
protected override void InternalAwake() { base.InternalAwake(); if (m_input == null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; } m_lastClickFrame = -1; m_lastClickPos = Vector2.zero; m_lastClickTime = -1.0f; int rectSize = 15; m_positionRect = new Rect(0, 0, rectSize, rectSize); m_texture = new Texture2D(1, 1); Color[] color = new Color[1]; color[0] = Color.green; m_texture.SetPixels(color); m_texture.Apply(); m_active = true; }
/// @brief mono-behavior start for initialization void Start() { m_mode = SkeletonGUIModes.SkeletonMode; // initialize all the external links if(m_input==null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) throw new System.Exception("Please add an NIInput object to the scene"); } if (m_settings == null) { m_settings = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager; if (m_settings == null) throw new System.Exception("Please add an OpenNISettingsManager object to the scene"); } // a rect used later, this is mainly an initialization tempRect = new Rect(); tempRect.x = Screen.width / 2 - 60; tempRect.y = Screen.height / 2 - 20; tempRect.width = 120; tempRect.height = 40; m_controllers = FindObjectsOfType(typeof(NISkeletonController)) as NISkeletonController[]; NIGUI.SetActive(false); // we don't want to see the cursor yet so we deactivate NIGUI }
/// the initialization (mono-behavior) public void Start() { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; }
/// mono-behavior start - initializes the input public void Start() { if(m_input==null) { m_input = FindObjectOfType(typeof(NIInput)) as NIInput; if (m_input == null) throw new System.Exception("Please add an NIInput object to the scene"); } if(m_tracker == null) { m_tracker = FindObjectOfType(typeof(NISkeletonTracker)) as NISkeletonTracker; } swipeRightDetector = new InputGestureDetector(m_input, "NIGUI_SWIPE_RIGHT"); swipeLeftDetector = new InputGestureDetector(m_input, "NIGUI_SWIPE_LEFT"); crossHandDetector = new InputGestureDetector(m_input, "NIGUI_CROSS_HAND"); pushDetector = new InputGestureDetector(m_input, "NIGUI_PUSH"); waveDetector = new InputGestureDetector(m_input, "NIGUI_WAVE"); steadyDetector = new InputGestureDetector(m_input, "NIGUI_CLICK"); leftHandupDetector = new InputGestureDetector(m_input, "NIGUI_LEFT_HANDUP"); menuAreaNormalized = new Rect (menuArea.x * Screen.width - (menuArea.width * 0.5f), menuArea.y * Screen.height - (menuArea.height * 0.5f), menuArea.width, menuArea.height); }
public InputGestureDetector(NIInput input, String gesture) { m_input = input; m_gesture = gesture; }
/// implementation of the Editor inspector GUI (this is what is called to see the inspector). override public void OnInspectorGUI() { if (EditorApplication.isPlaying) { return; } InitGestureStrings(); InitPointTrackerStrings(); EditorGUIUtility.LookLikeInspector(); NIInput inp = target as NIInput; EditorGUI.indentLevel = 0; m_myContent.text = "Hand trackers manager"; m_myContent.tooltip = "The hands tracker manager which holds which hand tracking source we have"; inp.m_pointsTrackingManager = EditorGUILayout.ObjectField(m_myContent, inp.m_pointsTrackingManager, typeof(NIPointTrackerManager), true) as NIPointTrackerManager; m_myContent.text = "Gestures manager"; m_myContent.tooltip = "The gestures manager which holds which gestures we can use"; inp.m_gestureManager = EditorGUILayout.ObjectField(m_myContent, inp.m_gestureManager, typeof(NIGestureManager), true) as NIGestureManager; m_myContent.text = "Axes"; m_myContent.tooltip = "All the axes to use for Natural Interactions"; inp.m_foldAllAxes = EditorGUILayout.Foldout(inp.m_foldAllAxes, m_myContent); if (inp.m_foldAllAxes == false) { return; } EditorGUI.indentLevel += 2; if (arraySize < 0) { arraySize = inp.m_axisList.Count; } m_myContent.text = "Size"; m_myContent.tooltip = "The number of axes used"; int numElements = EditorGUILayout.IntField(m_myContent, arraySize); arraySize = numElements; Event e = Event.current; if (e.keyCode == KeyCode.Return) { if (numElements == 0) { numElements = inp.m_axisList.Count; // don't allow to make it into 0 to avoid "deleting" to change something. arraySize = numElements; } if (numElements != inp.m_axisList.Count) { if (numElements < inp.m_axisList.Count) { while (numElements < inp.m_axisList.Count) { inp.m_axisList.RemoveAt(inp.m_axisList.Count - 1); } } else { for (int i = inp.m_axisList.Count; i < numElements; i++) { NIAxis newAxis = new NIAxis(); newAxis.m_gestureIndex = m_gestureStrings.Length - 1; // initialize to none inp.m_axisList.Add(newAxis); } } List <bool> newFoldout = new List <bool>(); int size = inp.m_foldAxisElement.Count; if (size > inp.m_axisList.Count) { size = inp.m_axisList.Count; } for (int i = 0; i < size; i++) { newFoldout.Add(inp.m_foldAxisElement[i]); } for (int i = size; i < inp.m_axisList.Count; i++) { newFoldout.Add(false); } inp.m_foldAxisElement = newFoldout; } } for (int i = 0; i < inp.m_foldAxisElement.Count; i++) { inp.m_foldAxisElement[i] = EditorGUILayout.Foldout(inp.m_foldAxisElement[i], inp.m_axisList[i].m_axisName); if (inp.m_foldAxisElement[i] == false) { continue; } EditorGUI.indentLevel += 2; m_myContent.text = "Name"; m_myContent.tooltip = "Change the name of the current axis"; inp.m_axisList[i].m_axisName = EditorGUILayout.TextField(m_myContent, inp.m_axisList[i].m_axisName); m_myContent.text = "NIInput axis?"; m_myContent.tooltip = "if checked, the axis is used only by NIInput, if not, it is also used by the input manager"; inp.m_axisList[i].m_NIInputAxisOnly = EditorGUILayout.Toggle(m_myContent, inp.m_axisList[i].m_NIInputAxisOnly); m_myContent.text = "Descriptive Name"; m_myContent.tooltip = "Name presented to the user if relevant"; inp.m_axisList[i].m_descriptiveName = EditorGUILayout.TextField(m_myContent, inp.m_axisList[i].m_descriptiveName); fixGestureIndex(inp.m_axisList[i]); inp.m_axisList[i].m_gestureIndex = EditorGUILayout.Popup("Gesture", inp.m_axisList[i].m_gestureIndex, m_gestureStrings); inp.m_axisList[i].m_gestureString = m_gestureStrings[inp.m_axisList[i].m_gestureIndex]; if (inp.m_axisList[i].m_gestureIndex != m_gestureStrings.Length - 1) { inp.m_axisList[i].m_Type = NIAxis.NIInputTypes.Gesture; // to make sure we use either } m_myContent.text = "Dead"; m_myContent.tooltip = "Movement of less than this value (when changes are used) will be ignored and considered 0"; float deadZone = EditorGUILayout.FloatField(m_myContent, inp.m_axisList[i].m_deadZone); inp.m_axisList[i].m_deadZone = deadZone < NIAxis.m_minDeadZone ? NIAxis.m_minDeadZone : deadZone; m_myContent.text = "Sensitivity"; m_myContent.tooltip = "A scaling factor"; float sensitivity = EditorGUILayout.FloatField(m_myContent, inp.m_axisList[i].m_sensitivity); inp.m_axisList[i].m_sensitivity = sensitivity < NIAxis.m_minSensitivity ? NIAxis.m_minSensitivity : sensitivity; m_myContent.text = "Invert"; m_myContent.tooltip = "Flip the values between positive and negative"; inp.m_axisList[i].m_invert = EditorGUILayout.Toggle(m_myContent, inp.m_axisList[i].m_invert); m_myContent.text = "Type"; m_myContent.tooltip = "The type of movement to do"; inp.m_axisList[i].m_Type = (NIAxis.NIInputTypes)EditorGUILayout.EnumPopup(m_myContent, (System.Enum)inp.m_axisList[i].m_Type); if (inp.m_axisList[i].m_Type != NIAxis.NIInputTypes.Gesture) { inp.m_axisList[i].m_gestureIndex = m_gestureStrings.Length - 1; // make it a "none" gesture } m_myContent.text = "Normalization"; m_myContent.tooltip = "Defines a transformation of the hand's axis to [-1,1] range (clipped)."; m_myContent.tooltip += " -1 is anything smaller than the center minus m_maxMovement,"; m_myContent.tooltip += " +1 is anything larger than the center plus m_maxMovement"; m_myContent.tooltip += " and the values in between are a linear change."; m_myContent.tooltip += " The center is defined based on the type (0 for HandMovement, focus point"; m_myContent.tooltip += " for HandMovementFromFocusPoint etc.). If m_maxMovement is 0 or negative"; m_myContent.tooltip += " then there will be no transformation. \n"; m_myContent.tooltip += "Note the actual value is still multiplied by the sensitivity, "; m_myContent.tooltip += " changed to 0 in the dead zone and can base inverted. "; inp.m_axisList[i].m_maxMovement = EditorGUILayout.FloatField(m_myContent, inp.m_axisList[i].m_maxMovement); m_myContent.text = "Axis"; m_myContent.tooltip = "Axis to use"; inp.m_axisList[i].m_axisUsed = (NIAxis.AxesList)EditorGUILayout.EnumPopup(m_myContent, (System.Enum)inp.m_axisList[i].m_axisUsed); fixTrackerIndex(inp.m_axisList[i]); inp.m_axisList[i].m_sourceTrackerIndex = EditorGUILayout.Popup("Tracker to use", inp.m_axisList[i].m_sourceTrackerIndex, m_pointTrackerStrings); inp.m_axisList[i].m_sourceTrackerString = m_pointTrackerStrings[inp.m_axisList[i].m_sourceTrackerIndex]; EditorGUILayout.Space(); EditorGUI.indentLevel -= 2; } EditorGUI.indentLevel -= 2; EditorGUI.indentLevel = 0; EditorGUILayout.Space(); if (GUI.changed) { EditorUtility.SetDirty(target); } }