// Zombie Avatar /* * private Dictionary<string, string> _RigMap = new Dictionary<string, string>() * { * {"SpineBase", "Bip01"}, * {"KneeRight", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 L Thigh"}, * {"KneeLeft", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 R Thigh"}, * {"AnkleRight", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 L Thigh/Bip01 L Calf"}, * {"AnkleLeft", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 R Thigh/Bip01 R Calf"}, * {"FootRight", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot"}, * {"FootLeft", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot"}, * }; */ void Update() { if (BodySourceManager == null) { return; } Dictionary <ulong, Vector3[]> bodies_pos = null; Dictionary <ulong, Quaternion[]> bodies_rot = null; _BodyDataConverter = BodySourceManager.GetComponent <BodyDataConverter>(); if (_BodyDataConverter == null) { _BodyDataReceiver = BodySourceManager.GetComponent <BodyDataReceiver>(); if (_BodyDataReceiver == null) { Debug.Log("No body data receiver"); return; } else { Debug.Log("Getting bodies position orientation data"); bodies_pos = _BodyDataReceiver.GetPosData(); bodies_rot = _BodyDataReceiver.GetRotData(); } } else { //bodies = _BodyDataConverter.GetData(); } if (bodies_pos == null || bodies_rot == null) { Debug.Log("No bodies position orientation data"); return; } List <ulong> trackedIDs = new List <ulong>(bodies_pos.Keys); List <ulong> knownIDs = new List <ulong>(_Bodies.Keys); foreach (ulong trackingID in knownIDs) { if (!trackedIDs.Contains(trackingID)) { Destroy(_Bodies[trackingID]); _Bodies.Remove(trackingID); } } foreach (ulong trackingID in bodies_pos.Keys) { Debug.Log("Checking bodies with tracking ID:" + trackingID); if (!_Bodies.ContainsKey(trackingID)) { Debug.Log("Create Body Object"); _Bodies[trackingID] = CreateBodyObject(trackingID); } RefreshBodyObject(trackingID, bodies_pos, bodies_rot); } }
// Zombie Avatar /* * private Dictionary<string, string> _RigMap = new Dictionary<string, string>() * { * {"SpineBase", "Bip01"}, * {"KneeRight", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 L Thigh"}, * {"KneeLeft", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 R Thigh"}, * {"AnkleRight", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 L Thigh/Bip01 L Calf"}, * {"AnkleLeft", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 R Thigh/Bip01 R Calf"}, * {"FootRight", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot"}, * {"FootLeft", "Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot"}, * }; */ void Update() { if (BodySourceManager == null) { return; } Dictionary <ulong, Vector3[]> bodies_pos = null; Dictionary <ulong, Quaternion[]> bodies_rot = null; _BodyDataConverter = BodySourceManager.GetComponent <BodyDataConverter>(); if (_BodyDataConverter == null) { _BodyDataReceiver = BodySourceManager.GetComponent <BodyDataReceiver>(); if (_BodyDataReceiver == null) { Debug.Log("No body data receiver"); return; } else { Debug.Log("Getting bodies position orientation data"); bodies_pos = _BodyDataReceiver.GetPosData(); bodies_rot = _BodyDataReceiver.GetRotData(); Debug.Log(bodies_pos + " " + bodies_rot); } } else { //bodies = _BodyDataConverter.GetData(); } if (bodies_pos == null || bodies_rot == null) { Debug.Log("No bodies position orientation data"); return; } List <ulong> trackedIDs = new List <ulong>(bodies_pos.Keys); List <ulong> knownIDs = new List <ulong>(_Bodies.Keys); foreach (ulong trackingID in knownIDs) { if (!trackedIDs.Contains(trackingID)) { Destroy(_Bodies[trackingID]); _Bodies.Remove(trackingID); } } // if calibration is not yet done and calibration is active, teh counter is started if (CalibrationActive == true && CalibrationDone == false && FrameCounter < 240) { GetComponent <TextMesh>().text = "Calibration in process"; { foreach (ulong trackingID in bodies_pos.Keys) { // doing the calibration only if the person is in the marked area if (bodies_pos[trackingID][0].z >= 8 && bodies_pos[trackingID][0].z <= 10 && bodies_pos[trackingID][0].x >= -1 && bodies_pos[trackingID][0].x <= 1) { // saves trackingID of person in marked area as UserID UserID = trackingID; break; } else { // if user is out of area: change instruction to specific sprite ChangeInstruction(noCalibration); ShowInstruction(); CalibrationActive = false; //hide "Calibration in process" GetComponent <TextMesh>().text = ""; } } } // adds the current position of spineShoulder/ SpineBase to the list in order to calculate average Vector averageSpineShoulder.Add(bodies_pos[UserID][20]); averageSpineBase.Add(bodies_pos[UserID][0]); FrameCounter++; // after 4 seconds... if (FrameCounter == 240) { // the SaveCalibration function calculates the average Vector and saves the backStraight Vector SaveCalibration(bodies_pos[UserID][20], bodies_pos[UserID][0]); GetComponent <TextMesh>().text = ""; FrameCounter++; // an information for the user is shown, that the calibration is done } } if (CalibrationDone == true) { // skeleton for user ID is created and updated foreach (ulong trackingID in bodies_pos.Keys) { if (!_Bodies.ContainsKey(trackingID) && trackingID == UserID) { _Bodies[trackingID] = CreateBodyObject(trackingID); } RefreshBodyObject(UserID, bodies_pos, bodies_rot); } Debug.Log("Calibration is done."); if (TaskDone == false) { CreateTask(); ThresholdsCalculation(UserID, bodies_pos, GetComponent <TextMesh>()); } } }