예제 #1
0
    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);
        }
    }