// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateBodies(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateBodies(); } bodies = rtClient.Bodies; if (bodies == null || bodies.Count == 0) { return; } if (bodiesGO.Count != bodies.Count) { InitiateBodies(); } for (int i = 0; i < bodies.Count; i++) { if (!float.IsNaN(bodies[i].Position.sqrMagnitude)) { bodiesGO[i].name = bodies[i].Name; bodiesGO[i].GetComponent <Renderer>().material.color = bodies[i].Color; bodiesGO[i].transform.localPosition = bodies[i].Position; bodiesGO[i].transform.localRotation = bodies[i].Rotation; bodiesGO[i].SetActive(true); bodiesGO[i].GetComponent <Renderer>().enabled = visibleBodies; bodiesGO[i].transform.localScale = Vector3.one * bodyScale; } else { // Hide markers if we cant find them bodiesGO[i].SetActive(false); } } }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateMarkers(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateMarkers(); } markerData = rtClient.Markers; if (markerData == null || markerData.Count == 0) { return; } if (markers.Count != markerData.Count) { InitiateMarkers(); } for (int i = 0; i < markerData.Count; i++) { if (!float.IsNaN(markerData[i].Position.sqrMagnitude)) { markers[i].name = markerData[i].Name; markers[i].GetComponent <Renderer>().material.color = markerData[i].Color; markers[i].transform.localPosition = markerData[i].Position; markers[i].SetActive(true); markers[i].GetComponent <Renderer>().enabled = visibleMarkers; markers[i].transform.localScale = Vector3.one * markerScale; } else { // Hide markers if we cant find them markers[i].SetActive(false); } } }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateGazeVectors(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateGazeVectors(); } gazeVectorData = rtClient.GazeVectors; if (gazeVectorData == null && gazeVectorData.Count == 0) { return; } if (gazeVectors.Count != gazeVectorData.Count) { InitiateGazeVectors(); } gazeRoot.SetActive(true); for (int i = 0; i < gazeVectorData.Count; i++) { if (gazeVectorData[i].Position.magnitude > 0) { gazeVectors[i].SetPosition(0, gazeVectorData[i].Position); gazeVectors[i].SetPosition(1, gazeVectorData[i].Position + gazeVectorData[i].Direction * gazeVectorLength); gazeVectors[i].startWidth = gazeVectorWidth; gazeVectors[i].endWidth = gazeVectorWidth; gazeVectors[i].gameObject.SetActive(true); } else { gazeVectors[i].gameObject.SetActive(true); } } }
void Update() { if (!visibleBones) { allBones.SetActive(false); return; } if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (!rtClient.GetStreamingStatus()) { return; } var boneData = rtClient.Bones; if (boneData == null || boneData.Count == 0) { return; } if (bones.Count != boneData.Count) { InitiateBones(); } allBones.SetActive(true); for (int i = 0; i < boneData.Count; i++) { if (!float.IsNaN(boneData[i].FromMarker.Position.sqrMagnitude) && !float.IsNaN(boneData[i].ToMarker.Position.sqrMagnitude)) { bones[i].SetPosition(0, boneData[i].FromMarker.Position); bones[i].SetPosition(1, boneData[i].ToMarker.Position); bones[i].startWidth = boneScale; bones[i].endWidth = boneScale; bones[i].gameObject.SetActive(true); } else { //hide bones if we cant find markers. bones[i].gameObject.SetActive(false); } } }
// Update is called once per frame void Update() { //if (GameObject.FindGameObjectWithTag("Camera (eye)").transform.position.x <= 0 || GameObject.FindGameObjectWithTag("Camera (eye)").transform.position.x >= 0) //{ Headset_Position = GameObject.FindObjectOfType <Camera>().transform.position; //} if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateMarkers(); InitiateAvatar(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateMarkers(); InitiateAvatar(); } markerData = rtClient.Markers; if (markerData == null && markerData.Count == 0) { return; } if (markers.Count != markerData.Count) { InitiateMarkers(); InitiateAvatar(); } for (int i = 0; i < markerData.Count; i++) { if (markerData[i].Position.magnitude > 0) { markers[i].name = markerData[i].Label; markers[i].GetComponent <Renderer>().material.color = markerData[i].Color; //markers[i].transform.position = markerData[i].Position; markers[i].transform.position = Virtual_LFrame.TF_RV * markerData[i].Position; markers[i].transform.position = markers[i].transform.position - new Vector3(Virtual_LFrame.o_r.x - Virtual_LFrame.VLF_LG[0, 3], Virtual_LFrame.o_r.y - Virtual_LFrame.VLF_LG[1, 3], Virtual_LFrame.o_r.z - Virtual_LFrame.VLF_LG[2, 3]); markers[i].transform.position = markers[i].transform.position + new Vector3(Headset_Position.x - Virtual_LFrame.VLF_LG[0, 3], Headset_Position.y - Virtual_LFrame.VLF_LG[1, 3], Headset_Position.z - Virtual_LFrame.VLF_LG[2, 3]); markers[i].SetActive(true); markers[i].GetComponent <Renderer>().enabled = visibleMarkers; markers[i].transform.localScale = Vector3.one * markerScale; } else { //hide markers if we cant find them. markers[i].SetActive(false); } vector_1.x = (markers[0].transform.position.x + markers[2].transform.position.x) / 2.0F - markers[1].transform.position.x; vector_1.y = -1 * ((markers[0].transform.position.y + markers[2].transform.position.y) / 2.0F - markers[1].transform.position.y); vector_1.z = (markers[0].transform.position.z + markers[2].transform.position.z) / 2.0F - markers[1].transform.position.z; Avatar[0].transform.rotation = Quaternion.FromToRotation(vector_1, transform.up); Avatar[0].transform.position = (markers[1].transform.position + markers[8].transform.position + markers[0].transform.position + markers[2].transform.position) / 4.0F; Avatar[0].transform.localScale = new Vector3(0.1f, vector_1.magnitude / 2.0f, 0.1f); Avatar[0].SetActive(true); Avatar[0].GetComponent <Renderer>().enabled = true; vector_2.x = (markers[8].transform.position.x + markers[1].transform.position.x) / 2.0F - ((markers[3].transform.position.x + markers[4].transform.position.x) / 2.0F); vector_2.y = -1 * ((markers[8].transform.position.y + markers[1].transform.position.y) / 2.0F - ((markers[3].transform.position.y + markers[4].transform.position.y) / 2.0F)); vector_2.z = ((markers[8].transform.position.z + markers[1].transform.position.z) / 2.0F - ((markers[3].transform.position.z + markers[4].transform.position.z) / 2.0F)); Avatar[1].transform.rotation = Quaternion.FromToRotation(vector_2, transform.up); Avatar[1].transform.position = (markers[8].transform.position + markers[1].transform.position + markers[3].transform.position + markers[4].transform.position) / 4.0F; Avatar[1].transform.localScale = new Vector3(0.1f, vector_2.magnitude / 2.0f, 0.1f); Avatar[1].SetActive(true); Avatar[1].GetComponent <Renderer>().enabled = true; vector_3.x = ((markers[3].transform.position.x + markers[4].transform.position.x) / 2.0F) - ((markers[7].transform.position.x + markers[6].transform.position.x) / 2.0F); vector_3.y = -1 * (((markers[3].transform.position.y + markers[4].transform.position.y) / 2.0F) - ((markers[7].transform.position.y + markers[6].transform.position.y) / 2.0F)); vector_3.z = (((markers[3].transform.position.z + markers[4].transform.position.z) / 2.0F) - ((markers[7].transform.position.z + markers[6].transform.position.z) / 2.0F)); Avatar[2].transform.rotation = Quaternion.FromToRotation(vector_3, transform.up); Avatar[2].transform.position = (markers[3].transform.position + markers[4].transform.position + markers[6].transform.position + markers[7].transform.position) / 4.0F; Avatar[2].transform.localScale = new Vector3(0.1f, vector_3.magnitude / 2.0f, 0.1f); Avatar[2].SetActive(true); Avatar[2].GetComponent <Renderer>().enabled = true; } //Headset_Position[0] = GameObject.Find("C7"); //Headset_Position[1] = GameObject.Find("SN"); //Headset_Position[2] = GameObject.Find("r_acromion"); }
// Update is called once per frame void Update() { frame = rtClient.GetFrame(); if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateMarkers(); //InitiateCO(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateMarkers(); //InitiateCO(); } markerData = rtClient.Markers; if (markerData == null && markerData.Count == 0) { return; } if (markers.Count != markerData.Count) { InitiateMarkers(); //InitiateCO(); } for (int i = 0; i < markerData.Count; i++) { if (markerData[i].Label == "a0") { O = markerData[i].Position; //markers[i].transform.position = VR_LL * O; } if (markerData[i].Label == "a1") { A = markerData[i].Position; } if (markerData[i].Label == "b1") { B = markerData[i].Position; } if (markerData[i].Label == "c1") { C = markerData[i].Position; } } if (frame == 100) { if (RUN == true) { a = Vector3.Cross(A - O, B - O); a = a.normalized; b = Vector3.Cross(A - O, a); b = b.normalized; c = Vector3.Cross(a, b); c = c.normalized; o = O; R_LG.SetColumn(0, new Vector4(a.x, a.y, a.z, 0)); R_LG.SetColumn(1, new Vector4(b.x, b.y, b.z, 0)); R_LG.SetColumn(2, new Vector4(c.x, c.y, c.z, 0)); R_LG.SetColumn(3, new Vector4(O.x, O.y, O.z, 0)); //V_LG = V_LG.transpose; //VR_LL = R_LG*V_LG.transpose; VR_LL = V_LG * R_LG.transpose; a4 = new Vector4(a.x, a.y, a.z, 0); af4 = VR_LL * a4; af = VR_LL * a; bf = VR_LL * b; cf = VR_LL * c; of = VR_LL * o; V_Lframe[0].transform.position = af; V_Lframe[1].transform.position = bf; V_Lframe[2].transform.position = cf; V_Lframe[3].transform.position = of; V_Lframe[0].SetActive(true); V_Lframe[1].SetActive(true); V_Lframe[2].SetActive(true); V_Lframe[3].SetActive(true); V_Lframe[0].GetComponent <Renderer>().enabled = visibleMarkers; V_Lframe[1].GetComponent <Renderer>().enabled = visibleMarkers; V_Lframe[2].GetComponent <Renderer>().enabled = visibleMarkers; V_Lframe[3].GetComponent <Renderer>().enabled = visibleMarkers; V_Lframe[0].GetComponent <Renderer>().material.color = new Vector4(0, 1, 0, 1); V_Lframe[1].GetComponent <Renderer>().material.color = new Vector4(0, 0, 1, 1); V_Lframe[2].GetComponent <Renderer>().material.color = new Vector4(1, 0, 0, 1); V_Lframe[3].GetComponent <Renderer>().material.color = new Vector4(0, 0, 0, 1); RUN = false; } } for (int i = 0; i < markerData.Count; i++) { if (markerData[i].Position.magnitude > 0) { markers[i].name = markerData[i].Label; markers[i].GetComponent <Renderer>().material.color = markerData[i].Color; markers[i].transform.localPosition = VR_LL * markerData[i].Position; //+ (of - new Vector3(V_LG.m30, V_LG.m31, V_LG.m32)); markers[i].transform.localPosition = markers[i].transform.localPosition - new Vector3(of.x - V_LG[0, 3], of.y - V_LG[1, 3], of.z - V_LG[2, 3]); markers[i].SetActive(true); markers[i].GetComponent <Renderer>().enabled = visibleMarkers; markers[i].transform.localScale = Vector3.one * markerScale; } else { //hide markers if we cant find them. markers[i].SetActive(false); } } //using (StreamWriter sw = new StreamWriter(writePath)) //{ // sw.WriteLine(of.ToString()); // sw.WriteLine(V_LG.GetColumn(3).ToString()); // sw.WriteLine(V_LG.m30.ToString()); // sw.WriteLine(V_LG.m31.ToString()); // sw.WriteLine(V_LG.m32.ToString()); //} }
void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateMarkers(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateMarkers(); } markerData = rtClient.Markers; if (markerData == null && markerData.Count == 0) { return; } if (markers.Count != markerData.Count) { InitiateMarkers(); } for (int i = 0; i < markerData.Count; i++) { if (markerData[i].Position.magnitude > 0) { if (markerData[i].Label == HeadMarker) { HeadPosition_qtm_x = markerData[i].Position.z; HeadPosition_qtm.x = HeadPosition_qtm_x; HeadPosition_qtm_y = markerData[i].Position.y; HeadPosition_qtm.y = HeadPosition_qtm_y; HeadPosition_qtm_z = markerData[i].Position.x; HeadPosition_qtm.z = HeadPosition_qtm_z; } markers[i].name = markerData[i].Label; //markers[i].GetComponent<Renderer>().material.color = markerData[i].Color; //markers[i].transform.localPosition = markerData[i].Position; // markers[i].SetActive(true); // markers[i].GetComponent<Renderer>().enabled = visibleMarkers; // markers[i].transform.localScale = Vector3.one * markerScale; } else { //hide markers if we cant find them. markers[i].SetActive(false); } } char[] delimiter1 = new char[] { ',' }; var strvalues = lastReceivedUDPPacket.Split(delimiter1, StringSplitOptions.None); foreach (string word in strvalues) { UDP_values++; // Qualysis x direction if (UDP_values == 1) { float.TryParse(word, out HeadPosition_labview_x); HeadPosition_labview.x = HeadPosition_labview_x / 1000; //ParticipantPosition.x = HeadPosition.x; } //Qualysis y direction = AP direction if (UDP_values == 2) { float.TryParse(word, out HeadPosition_labview_y); HeadPosition_labview.z = HeadPosition_labview_y / 1000; //ParticipantPosition.z = HeadPosition.y; // NOT USED IN TREADMILL - AP DIRECTION // } //Qualysis z direction = Vertical if (UDP_values == 3) { float.TryParse(word, out HeadPosition_labview_z); HeadPosition_labview.y = HeadPosition_labview_z / 1000; //ParticipantPosition.y = HeadPosition.z; } if (UDP_values == 4) { // float.TryParse (word, out beltSpeed); float.TryParse(word, out beltSpeed); } if (UDP_values == 5) { float.TryParse(word, out falling_rotation_y_labview); } } UDP_values = 0; // update camera position based on labview or qtm data stream if (QTM == true) { PlayerPerspective.transform.position = HeadPosition_qtm; } if (QTM == false) { PlayerPerspective.transform.position = HeadPosition_labview; } // visual perturbation //PlayerPerspective.transform.localRotation.z = falling_rotation_y_labview; // Tunnel Movement // pos_z1 = Plane1.transform.position.z; pos_z2 = Plane2.transform.position.z; pos_z3 = Plane3.transform.position.z; pos_z4 = Plane4.transform.position.z; Plane1.transform.Translate(0, 0, -beltSpeed * Time.deltaTime); Plane2.transform.Translate(0, 0, -beltSpeed * Time.deltaTime); Plane3.transform.Translate(0, 0, -beltSpeed * Time.deltaTime); Plane4.transform.Translate(0, 0, -beltSpeed * Time.deltaTime); if (pos_z1 < -10.2f) { Plane1.transform.position = new Vector3(0, 0, pos_z4 + 10.2f); } if (pos_z2 < -10.2f) { Plane2.transform.position = new Vector3(0, 0, pos_z1 + 10.2f); } if (pos_z3 < -10.2f) { Plane3.transform.position = new Vector3(0, 0, pos_z2 + 10.2f); } if (pos_z4 < -10.2f) { Plane4.transform.position = new Vector3(0, 0, pos_z3 + 10.2f); } }