public void processCalibration(string calibration) { string[] tokens = calibration.Split(MessageSeparators.L1); foreach (string s in tokens) { if (s == "") { break; } string[] chunks = s.Split(';'); string id = chunks[0]; float px = float.Parse(chunks[1]); float py = float.Parse(chunks[2]); float pz = float.Parse(chunks[3]); float rx = float.Parse(chunks[4]); float ry = float.Parse(chunks[5]); float rz = float.Parse(chunks[6]); float rw = float.Parse(chunks[7]); GameObject cloudobj = new GameObject(id); cloudobj.transform.localPosition = new Vector3(px, py, pz); cloudobj.transform.localRotation = new Quaternion(rx, ry, rz, rw); cloudobj.transform.localScale = new Vector3(-1, 1, 1); cloudobj.AddComponent <PointCloudDepth>(); PointCloudDepth cloud = cloudobj.GetComponent <PointCloudDepth>(); cloud.Init(); _clouds.Add(id, cloud); _cloudGameObjects.Add(id, cloudobj); cloudobj.transform.parent = _parent; } }
public void processCalibrationMatrix(string calibration) { string[] tokens = calibration.Split(MessageSeparators.L1); foreach (string s in tokens) { if (s == "") { break; } string[] chunks = s.Split(';'); string id = chunks[0]; Matrix4x4 mat = new Matrix4x4(new Vector4(float.Parse(chunks[1]), float.Parse(chunks[5]), float.Parse(chunks[9]), float.Parse(chunks[13])), new Vector4(float.Parse(chunks[2]), float.Parse(chunks[6]), float.Parse(chunks[10]), float.Parse(chunks[14])), new Vector4(float.Parse(chunks[3]), float.Parse(chunks[7]), float.Parse(chunks[11]), float.Parse(chunks[15])), new Vector4(float.Parse(chunks[4]), float.Parse(chunks[8]), float.Parse(chunks[12]), float.Parse(chunks[16]))); GameObject cloudobj = new GameObject(id); cloudobj.transform.localPosition = new Vector3(mat[0, 3], mat[1, 3], mat[2, 3]); cloudobj.transform.localRotation = mat.rotation; cloudobj.transform.localScale = new Vector3(-1, 1, 1); cloudobj.AddComponent <PointCloudDepth>(); PointCloudDepth cloud = cloudobj.GetComponent <PointCloudDepth>(); cloud.Init(); _clouds.Add(id, cloud); _cloudGameObjects.Add(id, cloudobj); } }