/// mono-behavior Initialization
 public void Start()
 {
     if (m_playerManager == null)
         m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
     if (m_playerManager == null)
         throw new System.Exception("Must have a player manager to control the skeleton!");
     int jointCount = Enum.GetNames(typeof(SkeletonJoint)).Length + 1; // Enum starts at 1
     m_jointsInitialRotations = new Quaternion[jointCount];
     // save all initial rotations
     // NOTE: Assumes skeleton model is in "T" pose since all rotations are relative to that pose
     foreach (SkeletonJoint j in Enum.GetValues(typeof(SkeletonJoint)))
     {
         if((int)j>=m_jointTransforms.Length)
             continue; // if we increased the number of joints since the initialization.
         if (m_jointTransforms[(int)j])
         {
             // we will store the relative rotation of each joint from the game object rotation
             // we need this since we will be setting the joint's rotation (not localRotation) but we 
             // still want the rotations to be relative to our game object
             // Quaternion.Inverse(transform.rotation) gives us the rotation needed to offset the game object's rotation
             m_jointsInitialRotations[(int)j] = Quaternion.Inverse(transform.rotation) * m_jointTransforms[(int)j].rotation;
             if (m_linesDebugger != null)
             {
                 m_linesDebugger.InitJoint(j);
             }
         }
     }
     m_originalRootPosition = transform.localPosition;
     // start out in calibration pose
     RotateToCalibrationPose();
 }
Ejemplo n.º 2
0
    /// @brief Internal method to do the actual drawing.
    ///
    /// Inspectors for users selectors inheriting NIPlayerManager should inherit NIPlayerManagerInspector
    /// and override this method.
    /// @note for best performance, call base.DrawPlayerManager() and only then add the new behavior.
    protected virtual void DrawPlayerManager()
    {
        EditorGUIUtility.LookLikeInspector();
        NIPlayerManager manager = target as NIPlayerManager;

        GUILayout.Label(manager.GetSelectionString());
        EditorGUILayout.Space();
        manager.m_contextManager = EditorGUILayout.ObjectField("Context", manager.m_contextManager, typeof(OpenNISettingsManager), true) as OpenNISettingsManager;
        int maxPlayers = EditorGUILayout.IntField("Max allowed players", manager.m_MaxNumberOfPlayers);

        if (maxPlayers > 0)
        {
            if (EditorApplication.isPlaying)
            {
                // we are running so we need to change manually
                manager.ChangeNumberOfPlayers(maxPlayers);
            }
            else
            {
                manager.m_MaxNumberOfPlayers = maxPlayers;
            }
        }
        int numRetries = EditorGUILayout.IntField("Num retries", manager.m_numRetries);

        if (numRetries > 0)
        {
            manager.m_numRetries = numRetries;
        }
    }
Ejemplo n.º 3
0
 /// mono-behavior initialization
 public void Start()
 {
     m_numBallsHit = 0;
     m_numBallsCreated = 0;
     m_timeToCreateNextBall = 0;
     if(m_playerManager==null)
         m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
 }
Ejemplo n.º 4
0
 /// mono-behavior initialization
 public void Start()
 {
     m_numBallsHit          = 0;
     m_numBallsCreated      = 0;
     m_timeToCreateNextBall = 0;
     if (m_playerManager == null)
     {
         m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
     }
 }
Ejemplo n.º 5
0
    // protected methods


    /// an internal method to initialize the internal structures
    /// @note in most cases, inheriting methods should NOT override the base @ref InitTracking but
    /// rather override this method.
    /// @return true on success and false otherwise.
    protected override void InternalAwake()
    {
        base.InternalAwake();
        if (m_playerManager == null)
        {
            m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
            if (m_playerManager == null)
            {
                throw new System.Exception("No player manager was found.");
            }
        }
    }
    /// mono-behavior initialization
    void Start()
    {
        if (m_playerManager == null)
        {
            m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
        }

        m_basePos = new Rect(0, Screen.height / 2, 150, 30);
        if (m_actionToSelect == null)
        {
            m_actionToSelect = "";
        }
        m_actionToSelectRectWidth = m_actionToSelect.Length * 7;
    }
    /// mono-behavior initialization
	void Start () 
    {
        if (m_playerManager == null)
        {
            m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
        }

        m_basePos=new Rect(0, Screen.height/2,150,30);
        if (m_actionToSelect == null)
        {
            m_actionToSelect = "";
        }
        m_actionToSelectRectWidth = m_actionToSelect.Length * 7;
	}
Ejemplo n.º 8
0
    void Awake()
    {
        playerManager = GetComponent <NIPlayerManager>();


        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

        for (int i = 0; i < skeletons.Length; i++)
        {
            skeletons[i] = new Skeleton();
        }
    }
    public SensorSkeletonReader()
    {
        if (m_playerManager == null)
        {
            m_playerManager = UnityEngine.Object.FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
        }
        if (m_playerManager == null)
        {
            throw new System.Exception("Must have a player manager to control the skeleton!");
        }
        m_jointCount = Enum.GetNames(typeof(Joint)).Length + 1; // Enum starts at 1

        m_jointData = new JointData[m_jointCount];
        ResetSkeletonData();
    }
Ejemplo n.º 10
0
    void Awake()
    {
        inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

        playerManager   = GetComponent <NIPlayerManager>();
        RUISKinect2Data = GetComponent <RUISKinect2Data>();

        if (!inputManager.enableKinect)
        {
            playerManager.enabled = false;
        }
        if (!inputManager.enableKinect2)
        {
            RUISKinect2Data.enabled = false;
        }

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

        for (int x = 0; x < 3; x++)         // Kinect 1, Kinect 2, Custom Tracker
        {
            for (int i = 0; i < 6; i++)
            {
                skeletons [x, i] = new Skeleton();

                // HACK  for filtering Kinect 2 arm rotations
                if (x == kinect2SensorID)
                {
                    for (int k = 0; k < skeletons[x, i].filterRot.Length; ++k)
                    {
                        skeletons[x, i].filterRot[k] = new KalmanFilteredRotation();
                        skeletons[x, i].filterRot[k].skipIdenticalMeasurements = true;
                        skeletons[x, i].filterRot[k].rotationNoiseCovariance   = skeletons[x, i].rotationNoiseCovariance;
                        skeletons[x, i].previousRotation[k] = Quaternion.identity;
                    }
                }
            }
        }

        isNewKinect2Frame         = false;
        timeSinceLastKinect2Frame = 0;
    }
    /// mono-behavior Initialization
    public void Start()
    {
        if (m_playerManager == null)
        {
            m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
        }
        if (m_playerManager == null)
        {
            throw new System.Exception("Must have a player manager to control the skeleton!");
        }
        int jointCount = Enum.GetNames(typeof(SkeletonJoint)).Length + 1; // Enum starts at 1

        m_jointsInitialRotations = new Quaternion[jointCount];


        // save all initial rotations
        // NOTE: Assumes skeleton model is in "T" pose since all rotations are relative to that pose
        foreach (SkeletonJoint j in Enum.GetValues(typeof(SkeletonJoint)))
        {
            if ((int)j >= m_jointTransforms.Length)
            {
                continue; // if we increased the number of joints since the initialization.
            }
            if (m_jointTransforms[(int)j])
            {
                // we will store the relative rotation of each joint from the game object rotation
                // we need this since we will be setting the joint's rotation (not localRotation) but we
                // still want the rotations to be relative to our game object
                // Quaternion.Inverse(transform.rotation) gives us the rotation needed to offset the game object's rotation
                m_jointsInitialRotations[(int)j] = Quaternion.Inverse(transform.rotation) * m_jointTransforms[(int)j].rotation;
                if (m_linesDebugger != null)
                {
                    m_linesDebugger.InitJoint(j);
                }
            }
        }
        m_originalRootPosition = transform.localPosition;
        // start out in calibration pose
        RotateToCalibrationPose();

//		m_gestTester = GetComponent<GestureTester>(); // yk added
    }
Ejemplo n.º 12
0
    void Awake()
    {
		inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;

		playerManager = GetComponent<NIPlayerManager>();
		RUISKinect2Data = GetComponent<RUISKinect2Data>();

		if (!inputManager.enableKinect) playerManager.enabled = false;
		if (!inputManager.enableKinect2) RUISKinect2Data.enabled = false;

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

		for (int x = 0; x < 3; x++) // Kinect 1, Kinect 2, Custom Tracker
		{
			for (int i = 0; i < 6; i++) 
			{
				skeletons [x, i] = new Skeleton ();

				// HACK  for filtering Kinect 2 arm rotations
				if(x == kinect2SensorID)
				{
					for(int k = 0; k < skeletons[x, i].filterRot.Length; ++k)
					{
						skeletons[x, i].filterRot[k] = new KalmanFilteredRotation();
						skeletons[x, i].filterRot[k].skipIdenticalMeasurements = true;
						skeletons[x, i].filterRot[k].rotationNoiseCovariance = skeletons[x, i].rotationNoiseCovariance;
						skeletons[x, i].previousRotation[k] = Quaternion.identity;
					}
				}
			}
		}
		
		isNewKinect2Frame = false;
		timeSinceLastKinect2Frame = 0;
    }
Ejemplo n.º 13
0
 // protected methods
 /// an internal method to initialize the internal structures
 /// @note in most cases, inheriting methods should NOT override the base @ref InitTracking but
 /// rather override this method.
 /// @return true on success and false otherwise.
 protected override void InternalAwake()
 {
     base.InternalAwake();
     if (m_playerManager == null)
     {
         m_playerManager = FindObjectOfType(typeof(NIPlayerManager)) as NIPlayerManager;
         if (m_playerManager == null)
             throw new System.Exception("No player manager was found.");
     }
 }
Ejemplo n.º 14
0
    void Awake()
    {
        playerManager = GetComponent<NIPlayerManager>();

        if (coordinateSystem == null)
        {
            coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        }

        for (int i = 0; i < skeletons.Length; i++)
        {
            skeletons[i] = new Skeleton();
        }
    }