// protected methods protected override bool InternalInit(NIPointTracker hand) { NISkeletonTracker curHand = hand as NISkeletonTracker; if (curHand == null) { return(false); } if (m_context == null || m_context.UserSkeletonValid == false) { return(false); } NISelectedPlayer player = curHand.GetTrackedPlayer(); if (player == null) { return(false); // no player } player.m_userChangeEventHandler += PlayerUserChangeHandler; if (player.Valid) { validRequestedPoseDetection = m_context.UserGenrator.RequestPoseDetection(m_poseName, player.OpenNIUserID); return(validRequestedPoseDetection); } validRequestedPoseDetection = false; return(true); }
/// @brief makes sure we release everything on quit /// /// This will make sure everything the context is released when quitting (important for playing and /// stopping in the editor). /// @note - This is based on the MonoBehavior.OnAppliactionQuit. public void OnApplicationQuit() { if (m_tracker != null) { m_manager.ReleaseTracker("Primary point tracker (session based)"); m_tracker = null; } }
/// @brief makes sure we release everything on destroy /// /// This will make sure everything released when the object is destroyed /// (important for playing and stopping in the editor). /// @note - This is based on the MonoBehavior.OnDestroy. public void OnDestroy() { if (m_tracker != null) { m_manager.ReleaseTracker("Primary point tracker (session based)"); m_tracker = null; } }
/// Gesture initialization /// /// This method is responsible for initializing the gesture to work with a specific hand tracker /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). public virtual bool Init(NIPointTracker hand) { if (hand.Valid == false) return false; if (InternalInit(hand) == false) return false; m_pointTracker = hand; return true; }
void initTrakers() { LeftShoulder = manager.GetTracker(Skeleton_LeftShoulder.GetTrackerType()); LeftElbow = manager.GetTracker(Skeleton_LeftElbow.GetTrackerType()); LeftHand = manager.GetTracker(Skeleton_LeftHand.GetTrackerType()); RightShoulder = manager.GetTracker(Skeleton_RightShoulder.GetTrackerType()); RightElbow = manager.GetTracker(Skeleton_RightElbow.GetTrackerType()); RightHand = manager.GetTracker(Skeleton_RightHand.GetTrackerType()); Neck = manager.GetTracker(Skeleton_Neck.GetTrackerType()); }
// protected methods /// Gesture initialization /// /// This method is responsible for initializing the gesture to work with a specific hand tracker /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). protected override bool InternalInit(NIPointTracker hand) { NIHandTracker curHand = hand as NIHandTracker; if (curHand == null) { return(false); } return(curHand.AddListener(m_steadyDetector)); }
/// Gesture initialization /// /// This method is responsible for initializing the gesture to work with a specific hand tracker /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). protected override bool InternalInit(NIPointTracker hand) { NISkeletonTracker curHand = hand as NISkeletonTracker; if (curHand == null) { return(false); } return(true); }
/// This method is called by the GestureManager to create the the tracker /// @note it it the responsibility of the caller to later call @ref ReleaseTracker on this object /// @param hand the hand tracker to work with /// @return The relevant tracker class @note INIGestureTracker is NOT mono-behavior. public virtual NIGestureTracker GetGestureTracker(NIPointTracker hand) { NIGestureTracker obj = GetNewTrackerObject(); if (obj == null) return null; // we failed. if (obj.Init(hand) == false) { return null; // we failed to initialize } m_trackersList.Add(obj); return obj; }
/// Gesture initialization /// /// This method is responsible for initializing the gesture to work with a specific hand tracker /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). public virtual bool Init(NIPointTracker hand) { if (hand.Valid == false) { return(false); } if (InternalInit(hand) == false) { return(false); } m_pointTracker = hand; return(true); }
/// the initialization (mono-behavior) public void Start() { if (m_manager == null) { m_manager = FindObjectOfType(typeof(NIPointTrackerManager)) as NIPointTrackerManager; } m_tracker = m_manager.GetTracker("Primary point tracker (session based)"); if (m_tracker == null) { throw new System.Exception("The requested tracker is not attached!"); } m_initialPosition = transform.position; }
// protected methods /// Gesture initialization /// /// This method is responsible for initializing the gesture to work with a specific hand tracker /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). protected override bool InternalInit(NIPointTracker hand) { NIHandTracker curHand = hand as NIHandTracker; if (curHand == null) { return(false); } if (curHand.AddListener(m_pushDetector) == false) { return(false); } m_immediateDuration = ((float)m_pushDetector.ImmediateDuration) / 1000.0f; return(true); }
/// This method is called by the GestureManager to create the the tracker /// @note it it the responsibility of the caller to later call @ref ReleaseTracker on this object /// @param hand the hand tracker to work with /// @return The relevant tracker class @note INIGestureTracker is NOT mono-behavior. public virtual NIGestureTracker GetGestureTracker(NIPointTracker hand) { NIGestureTracker obj = GetNewTrackerObject(); if (obj == null) { return(null); // we failed. } if (obj.Init(hand) == false) { return(null); // we failed to initialize } m_trackersList.Add(obj); return(obj); }
public NIAxis() { m_axisName = "New Axis"; m_descriptiveName = ""; m_gestureIndex = 0; m_deadZone = m_minDeadZone; m_sensitivity = m_minSensitivity; m_invert = false; m_Type = NIInputTypes.HandMovement; m_maxMovement = -1.0f; m_axisUsed = AxesList.xAxis; m_sourceTrackerIndex = 0; m_sourceTrackerString = "none"; m_sourceTracker = null; m_sourceGesture = null; m_NIInputAxisOnly = true; }
// protected methods protected override bool InternalInit(NIPointTracker hand) { NISkeletonTracker curHand = hand as NISkeletonTracker; if (curHand == null) return false; if(m_context==null || m_context.UserSkeletonValid==false) return false; NISelectedPlayer player = curHand.GetTrackedPlayer(); if (player == null) return false; // no player player.m_userChangeEventHandler += PlayerUserChangeHandler; if (player.Valid) { validRequestedPoseDetection=m_context.UserGenrator.RequestPoseDetection(m_poseName,player.OpenNIUserID); return validRequestedPoseDetection; } validRequestedPoseDetection = false; return true; }
// protected methods. /// used to perform all internal initialization on the gesture. /// @note it can assume the validity of the hand is checked before calling and that after a successful /// return (true) m_handTracker is initialized /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). protected abstract bool InternalInit(NIPointTracker hand);
protected float m_timeDetected; ///< holds the last time (in time.time) the gesture was detected. -1 if it was never detected #endregion Fields #region Constructors /// constructor. @note it is protected to make sure only child classes can be created. protected NIGestureTracker() { m_timeDetected = -100.0f; m_frameDetected = -100; m_pointTracker = null; }
public NIAxis() { m_axisName="New Axis"; m_descriptiveName=""; m_gestureIndex = 0; m_deadZone=m_minDeadZone; m_sensitivity=m_minSensitivity; m_invert=false; m_Type=NIInputTypes.HandMovement; m_maxMovement=-1.0f; m_axisUsed=AxesList.xAxis; m_sourceTrackerIndex=0; m_sourceTrackerString = "none"; m_sourceTracker = null; m_sourceGesture = null; m_NIInputAxisOnly=true; }
/// a callback to get the click event. /// /// @param hand The point tracker which is the basis of the movement. private void GestureEventHandler(NIPointTracker hand) { m_lastClickTime = Time.time; m_lastClickFrame = Time.frameCount; m_lastClickPos = Position; }
// protected methods /// Gesture initialization /// /// This method is responsible for initializing the gesture to work with a specific hand tracker /// @param hand the hand tracker to work with /// @return true on success, false on failure (e.g. if the hand tracker does not work with the gesture). protected override bool InternalInit(NIPointTracker hand) { NISkeletonTracker curHand = hand as NISkeletonTracker; if (curHand == null) return false; return true; }
/// internal callback to check the callback /// @param hand the hand tracker which created this callback protected void InternalCallback(NIPointTracker hand) { m_lastCallbackTime = Time.time; m_lastCallbackFrame = Time.frameCount; }