コード例 #1
0
    /// @brief calculates an updated priority for the user
    ///
    /// Base implementation is: priority is based on the z axis of the center of mass and the state
    /// @param user The user object whose priority we need to calculate
    protected virtual void UpdateUserPriority(NIPlayerCandidateObject user)
    {
        NIPlayerCOMCandidateObject userCom = user as NIPlayerCOMCandidateObject;

        if (userCom == null)
        {
            return; // irrelevant
        }
        Vector3 com = m_contextManager.UserGenrator.GetUserCenterOfMass(userCom.OpenNIUserID);

        userCom.m_priority = com.z;
        if (userCom.m_priority > 0)
        {
            userCom.m_priority = -m_maxAllowedDistance; // as far away as possible for an illegal value
        }
        if (user.PlayerStatus == UserStatus.Selected || user.PlayerStatus == UserStatus.Tracking)
        {
            userCom.m_priority += m_hysteresis;
        }
        if (userCom.PlayerStatus == UserStatus.Failure)
        {
            com -= userCom.m_COMWhenFail;
            if (com.magnitude < m_minCOMChangeForFailure)
            {
                userCom.m_priority -= m_failurePenalty;
            }
        }
    }
コード例 #2
0
 /// @brief Utility method to get the player number from the user
 ///
 /// @param user The user whose player we seek.
 /// @return The player number (-1 if not found).
 protected int GetPlayerIdFromUser(NIPlayerCandidateObject user)
 {
     for (int i = 0; i < m_players.Count; i++)
     {
         if (m_players[i].Valid && m_players[i].User == user)
         {
             return(i);
         }
     }
     return(-1);
 }
コード例 #3
0
    /// @brief Internal Method to unselect a specific player
    ///
    /// The difference between this method and @ref UnselectPlayer is that
    /// this method does not check that the player number is legal but rather assumes
    /// it is legal (checked in the @ref UnselectPlayer method).
    /// @param playerNumber the number of the player to be unselected
    /// @return True on success, false on failure
    protected virtual bool UnsafeUnselectPlayer(int playerNumber)
    {
        NIPlayerCandidateObject user = m_players[playerNumber].User;

        m_players[playerNumber].User = null;
        if (user != null)
        {
            return(user.UnselectUser());
        }
        else
        {
            return(true);
        }
    }
コード例 #4
0
 /// @brief A callback method to handle changing of a user in the tracked player
 ///
 /// This method is called as a callback whenever the tracked player changes the user it tracks.
 /// @param origUser The user object for the user @b before the change
 /// @param newUser The user object for the user @b after the change
 protected void PlayerUserChangeHandler(NIPlayerCandidateObject origUser, NIPlayerCandidateObject newUser)
 {
     if (m_context == null || m_context.UserSkeletonValid == false)
     {
         return; // no context to work with
     }
     if (origUser != null && validRequestedPoseDetection)
     {
         m_context.UserGenrator.ReleasePoseDetection(m_poseName, origUser.OpenNIUserID);
         validRequestedPoseDetection = false;
     }
     if (newUser != null)
     {
         validRequestedPoseDetection = m_context.UserGenrator.RequestPoseDetection(m_poseName, newUser.OpenNIUserID);
     }
 }
コード例 #5
0
 /// @brief calculates an updated priority for the user
 ///  
 /// Base implementation is: priority is based on the z axis of the center of mass and the state
 /// @param user The user object whose priority we need to calculate
 protected virtual void UpdateUserPriority(NIPlayerCandidateObject user)
 {
     NIPlayerCOMCandidateObject userCom = user as NIPlayerCOMCandidateObject;
     if (userCom == null)
         return; // irrelevant
     Vector3 com=m_contextManager.UserGenrator.GetUserCenterOfMass(userCom.OpenNIUserID);
     userCom.m_priority = com.z;
     if (userCom.m_priority > 0)
     {
         userCom.m_priority = -m_maxAllowedDistance; // as far away as possible for an illegal value
     }
     if(user.PlayerStatus==UserStatus.Selected || user.PlayerStatus==UserStatus.Tracking)
     {
         userCom.m_priority += m_hysteresis;
     }
     if(userCom.PlayerStatus==UserStatus.Failure)
     {
         com -= userCom.m_COMWhenFail;
         if (com.magnitude < m_minCOMChangeForFailure)
         {
             userCom.m_priority -= m_failurePenalty;
         }
     }
 }
コード例 #6
0
 /// @brief constructor
 public NISelectedPlayer()
 {
     m_user = null;
 }
コード例 #7
0
 /// @brief Utility method to get the player number from the user
 /// 
 /// @param user The user whose player we seek.
 /// @return The player number (-1 if not found).
 protected int GetPlayerIdFromUser(NIPlayerCandidateObject user)
 {
     for (int i = 0; i < m_players.Count; i++)
     {
         if (m_players[i].Valid && m_players[i].User == user)
             return i;
     }
     return -1;
 }
コード例 #8
0
 /// @brief A callback method to handle changing of a user in the tracked player
 /// 
 /// This method is called as a callback whenever the tracked player changes the user it tracks.
 /// @param origUser The user object for the user @b before the change
 /// @param newUser The user object for the user @b after the change
 protected void PlayerUserChangeHandler(NIPlayerCandidateObject origUser, NIPlayerCandidateObject newUser)
 {
     if (m_context == null || m_context.UserSkeletonValid == false)
         return; // no context to work with
     if (origUser != null && validRequestedPoseDetection)
     {
         m_context.UserGenrator.ReleasePoseDetection(m_poseName, origUser.OpenNIUserID);
         validRequestedPoseDetection = false;
     }
     if (newUser != null)
     {
         validRequestedPoseDetection=m_context.UserGenrator.RequestPoseDetection(m_poseName, newUser.OpenNIUserID);
     }
 }