private void Update() { if (screenMesh != null) { updateTimer.StartUpdateTimer(); IRPoint[] irs = GetIrs(); if (irs != null) { handles = GameObject.FindGameObjectsWithTag("handle"); if (handles.Length == irs.Length) { for (int i = 0; i < handles.Length; i++) { Handle handle = handles[i].GetComponent <Handle>(); IRPoint iRPoint = Array.Find(irs, element => element.id == handle.id); handle.X = iRPoint.x; handle.Y = iRPoint.y; handle.Z = iRPoint.z; List <int> indices = handle.GetIndices(); foreach (int index in indices) { verts[index] = new Vector3(iRPoint.x, iRPoint.y, iRPoint.z); } } screenMesh.vertices = verts; screenMesh.RecalculateBounds(); screenMesh.RecalculateNormals(); } } else { Debug.Log(string.Format("Lost points, had {0} points, now have {1}", handles.Length, irs.Length)); } updateTimer.StopUpdateTimer(irs.Length); } }
private void SetIrs(float[] floatArray) { int len = floatArray.Length / 3; message = "hej " + len + " " + (floatArray.Length); IRPoint[] irs2 = new IRPoint[len]; IRPoint ir; int id = 0; int i = 0; for (int j = 0; j < len; j++) { float zo; if (firstIrs == null) { zo = floatArray[i + 2]; } else { zo = floatArray[i + 2]; } ir = new IRPoint { id = j, x = -1 * floatArray[i], y = floatArray[i + 1], z = zo }; i += 3; irs2[j] = ir; } if (firstIrs == null) { firstIrs = this.irs; first = false; } this.irs = irs2; }