// Update is called once per frame void Update() { foreach (KeyValuePair <int, GameObject> entry in userObjMap) { entry.Value.transform.localPosition = Vector3.Scale(scale, UserTracker.GetUserCenterOfMass(entry.Key)); } }
// Update is called once per frame void Update() { foreach (KeyValuePair <int, GameObject> entry in userObjMap) { entry.Value.transform.localPosition = Vector3.Scale(scale, UserTracker.GetUserCenterOfMass(entry.Key)); } //scale = new Vector3(Camera.main.orthographicSize * ratio, Camera.main.orthographicSize * ratio, Camera.main.orthographicSize * ratio); scale = new Vector3(ratio, ratio, ratio); }
void OnGUI() { int width = (int)((float)PixelsPerMeter * (RadarRealWorldDimensions.x / 1000.0f)); int height = (int)((float)PixelsPerMeter * (RadarRealWorldDimensions.y / 1000.0f)); GUI.BeginGroup(new Rect(Screen.width - width - 20, 20, width, height)); GUI.Box(new Rect(0, 0, width, height), "Users Radar"); foreach (int userId in UserTracker.AllUsers) { // normalize the center of mass to radar dimensions Vector3 com = UserTracker.GetUserCenterOfMass(userId); Vector2 radarPosition = new Vector2(com.x / RadarRealWorldDimensions.x, -com.z / RadarRealWorldDimensions.y); // X axis: 0 in real world is actually 0.5 in radar units (middle of field of view) radarPosition.x += 0.5f; // clamp radarPosition.x = Mathf.Clamp(radarPosition.x, 0.0f, 1.0f); radarPosition.y = Mathf.Clamp(radarPosition.y, 0.0f, 1.0f); // we always want the radar to mirror the view, even if the depth doesn't if (!OpenNIContext.Instance.Mirror) { radarPosition.x = 1.0f - radarPosition.x; } // draw GUI.Box(new Rect(radarPosition.x * width - 10, radarPosition.y * height - 10, 20, 20), userId.ToString()); } GUI.EndGroup(); }
void CalibrateUser() { // do we have a valid calibrated user? if (IsTracking) { // is the user still valid? if (!UserTracker.CalibratedUsers.Contains(USER_ID)) { USER_ID = 0; foreach (OpenNISkeleton skel in Skeletons) { skel.RotateToCalibrationPose(); } } } // look for a new userId if we dont have one if (!IsTracking) { // just take the first calibrated user if (UserTracker.CalibratedUsers.Count > 0) { USER_ID = UserTracker.CalibratedUsers[0]; outOfFrame = false; } } // we have a valid userId, lets use it for something! if (IsTracking) { // see if user is out o'frame Vector3 com = UserTracker.GetUserCenterOfMass(USER_ID); if (outOfFrame != (com == Vector3.zero)) { outOfFrame = (com == Vector3.zero); SendMessage("UserOutOfFrame", outOfFrame, SendMessageOptions.DontRequireReceiver); } // update our skeleton based on active user id foreach (OpenNISkeleton skel in Skeletons) { UserTracker.UpdateSkeleton(USER_ID, skel); } // Always update skeleton points STATIC_SKELETON = Skeletons[0]; if (IS_FIRST_RUN) // Only calibrate once { TIME = Time.time; IS_FIRST_RUN = false; } } }
// Update is called once per frame void Update() { //Debug.Log(IsTracking); // do we have a valid calibrated user? if (0 != userId) { // is the user still valid? if (!UserTracker.CalibratedUsers.Contains(userId)) { userId = 0; foreach (OpenNISkeleton skel in Skeletons) { skel.RotateToCalibrationPose(); } } } // look for a new userId if we dont have one if (0 == userId) { // just take the first calibrated user if (UserTracker.CalibratedUsers.Count > 0) { userId = UserTracker.CalibratedUsers[0]; outOfFrame = false; } } // we have a valid userId, lets use it for something! if (0 != userId) { // see if user is out o'frame Vector3 com = UserTracker.GetUserCenterOfMass(userId); if (outOfFrame != (com == Vector3.zero)) { outOfFrame = (com == Vector3.zero); SendMessage("UserOutOfFrame", outOfFrame, SendMessageOptions.DontRequireReceiver); } // update our skeleton based on active user id foreach (OpenNISkeleton skel in Skeletons) { UserTracker.UpdateSkeleton(userId, skel); } } }