Ejemplo n.º 1
0
	void Update () 
	{
		KinectManager manager = KinectManager.Instance;
		
		if(manager && manager.IsInitialized())
		{
			if(backgroundImage && (backgroundImage.texture == null))
			{
				backgroundImage.texture = manager.GetUsersClrTex();
			}

			MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[];

			foreach(MonoBehaviour monoScript in monoScripts)
			{
				if(typeof(AvatarScaler).IsAssignableFrom(monoScript.GetType()))
				{
					AvatarScaler scaler = (AvatarScaler)monoScript;

					int userIndex = scaler.playerIndex;
					long userId = manager.GetUserIdByIndex(userIndex);

					if(userId != scaler.currentUserId)
					{
						scaler.currentUserId = userId;
					
						if(userId != 0)
						{
							scaler.GetUserBodySize(true, true, true);
							scaler.FixJointsBeforeScale();
							scaler.ScaleAvatar(0f);
						}
					}
				}
			}

			if(!manager.IsUserDetected())
			{
				if(debugText != null)
				{
					debugText.GetComponent<GUIText>().text = "Please stand in T-pose for calibration.";
				}
			}

		}

	}
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            if (manager.autoHeightAngle == KinectManager.AutoHeightAngle.AutoUpdate ||
                manager.autoHeightAngle == KinectManager.AutoHeightAngle.AutoUpdateAndShowInfo)
            {
                // update the cameras automatically, according to the current sensor height and angle
                KinectInterop.SensorData sensorData = manager.GetSensorData();

                if (foregroundCamera != null && sensorData != null)
                {
                    foregroundCamera.transform.position = new Vector3(sensorData.depthCameraOffset, manager.sensorHeight, 0f);
                    foregroundCamera.transform.rotation = Quaternion.Euler(-manager.sensorAngle, 0f, 0f);
                }

                if (backgroundCamera != null && sensorData != null)
                {
                    backgroundCamera.transform.position = new Vector3(0f, manager.sensorHeight, 0f);
                    backgroundCamera.transform.rotation = Quaternion.Euler(-manager.sensorAngle, 0f, 0f);
                }
            }

            if (backgroundImage && (backgroundImage.texture == null))
            {
                backgroundImage.texture = manager.GetUsersClrTex();
            }

            MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[];

            foreach (MonoBehaviour monoScript in monoScripts)
            {
                if (typeof(AvatarScaler).IsAssignableFrom(monoScript.GetType()))
                {
                    AvatarScaler scaler = (AvatarScaler)monoScript;

                    int  userIndex = scaler.playerIndex;
                    long userId    = manager.GetUserIdByIndex(userIndex);

                    if (userId != scaler.currentUserId)
                    {
                        scaler.currentUserId = userId;

                        if (userId != 0)
                        {
                            scaler.GetUserBodySize(true, true, true);
                            scaler.FixJointsBeforeScale();
                            scaler.ScaleAvatar(0f);
                        }
                    }
                }
            }

            if (!manager.IsUserDetected())
            {
                if (debugText != null)
                {
                    debugText.GetComponent <GUIText>().text = "Please stand in T-pose for calibration.";
                }
            }
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            long userId = manager.GetUserIdByIndex(playerIndex);

            if (userId != 0)
            {
                MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[];
                foreach (MonoBehaviour monoScript in monoScripts)
                {
//					if(typeof(AvatarScaler).IsAssignableFrom(monoScript.GetType()) &&
//						monoScript.enabled)
                    if ((monoScript is AvatarScaler) && monoScript.enabled)
                    {
                        AvatarScaler scaler = (AvatarScaler)monoScript;

                        if (scaler.scalerInited && scaler.playerIndex == playerIndex &&
                            scaler.currentUserId != userId)
                        {
                            scaler.currentUserId = userId;

                            if (userId != 0)
                            {
                                scaler.GetUserBodySize(true, true, true);

                                if (fixModelHipsAndShoulders)
                                {
                                    scaler.FixJointsBeforeScale();
                                }
                                scaler.ScaleAvatar(0f);
                            }
                        }
                    }
                }

                if (lastUserId != userId)
                {
                    if (infoText != null)
                    {
                        string sMessage = swipeToChangeModel && modelSelector ? "Swipe left or right to change clothing." : string.Empty;
                        if (raiseHandToChangeCategory && allModelSelectors.Length > 1)
                        {
                            sMessage += " Raise hand to change category.";
                        }

                        infoText.text = sMessage;
                    }

                    lastUserId = userId;
                }
            }

            if (userId == 0 && userId != lastUserId)
            {
                lastUserId = userId;

                if (modelSelector)
                {
                    modelSelector.DestroyCurrentModel();
                }

                if (infoText != null)
                {
                    infoText.text = "Please stand in T-pose for calibration.";
                }
            }
        }
    }