public void transformCube(Matrix4x4 latestTransMatrixLeft, Matrix4x4 latestTransMatrixRight) { if (leftCube != null && rightCube != null) { if (latestTransMatrixLeft != null && latestTransMatrixRight != null) { // World anchored dummyGameObjectLeft.transform.localRotation = VeriUtils.QuaternionFromMatrix(latestTransMatrixLeft); dummyGameObjectLeft.transform.position = leftCam.ScreenToWorldPoint(VeriUtils.PositionFromMatrix(latestTransMatrixLeft)); dummyGameObjectRight.transform.localRotation = VeriUtils.QuaternionFromMatrix(latestTransMatrixRight); dummyGameObjectRight.transform.position = rightCam.ScreenToWorldPoint(VeriUtils.PositionFromMatrix(latestTransMatrixRight)); VeriUtils.SetMatrix4x4ToGameObject(ref leftCube, dummyGameObjectLeft.transform.localToWorldMatrix); VeriUtils.SetMatrix4x4ToGameObject(ref rightCube, dummyGameObjectRight.transform.localToWorldMatrix); // !World anchored //leftCube.transform.position = leftCam.ScreenToWorldPoint(VeriUtils.PositionFromMatrix(latestTransMatrixLeft)); //leftCube.transform.rotation = VeriUtils.QuaternionFromMatrix(latestTransMatrixLeft); //rightCube.transform.position = rightCam.ScreenToWorldPoint(VeriUtils.PositionFromMatrix(latestTransMatrixRight)); //rightCube.transform.rotation = VeriUtils.QuaternionFromMatrix(latestTransMatrixRight); Debug.Log("transformed leftCube position: " + leftCam.WorldToScreenPoint(leftCube.transform.position)); Debug.Log("transformed rightCube position: " + rightCam.WorldToScreenPoint(rightCube.transform.position)); } else { Debug.Log("Empty matrix!!!"); } } else { Debug.Log("Cube is empty!!!"); } }
public void processMessage(string ms) { processFlag = 0; Debug.Log("In processMessage, ms = " + ms); char delimiter = ';'; bool leftFlag = false; bool rightFlag = false; if (ms != null) { string[] msSubString = ms.Split(delimiter); if (msSubString.Length == 2) { int count = 0; foreach (string substring in msSubString) { string[] array = substring.Split(','); if (array.Length == 12) { float[] matrxArray = new float[12]; for (int i = 0; i < matrxArray.Length; i++) { matrxArray[i] = float.Parse(array[i]); } if (count == 0) { latestTransMatrixLeft = VeriUtils.ConvertARUWPFloatArrayToMatrix4x4(matrxArray); leftFlag = true; } else if (count == 1) { latestTransMatrixRight = VeriUtils.ConvertARUWPFloatArrayToMatrix4x4(matrxArray); rightFlag = true; } else { Debug.Log("Wrong Count!!!"); } } else { Debug.Log("Array size != 12!!!"); } count++; }//End of foreach (string substring in msSubString) if (leftFlag && rightFlag) { transformCube(latestTransMatrixLeft, latestTransMatrixRight); leftFlag = false; rightFlag = false; } } else { Debug.Log("Message larger than 2 array!!!"); } }//End of if (ms != null) }