示例#1
0
        public virtual void UpdateObject(int id, Vector3[] vertices, int[] triangles = null, Vector2[] uv = null)
        {
            if (showingObjects.ContainsKey(id))
            {
                TrackedMesh tm = showingObjects[id];

                if (vertices.Length != tm.MeshFilter.mesh.vertices.Length)
                {
                    Debug.LogError("The number of vertices does not match.");
                }
                tm.MeshFilter.mesh.vertices = vertices;

                if (triangles != null)
                {
                    tm.MeshFilter.mesh.triangles = triangles;
                }
                if (uv != null)
                {
                    tm.MeshFilter.mesh.uv = uv;
                }

                tm.MeshFilter.mesh.RecalculateBounds();
                tm.MeshFilter.mesh.RecalculateNormals();
            }
        }
示例#2
0
 public virtual TrackedMesh CreateObject(int id, Texture2D tex = null)
 {
     if (!showingObjects.ContainsKey(id))
     {
         GameObject obj = getPoolObject(overlayTransform);
         if (obj == null)
         {
             return(null);
         }
         TrackedMesh tm = obj.GetComponent <TrackedMesh>();
         if (tm != null)
         {
             tm.Id = id;
             tm.transform.localPosition = new Vector3(0, 0, 0);
             tm.transform.localRotation = new Quaternion();
             tm.transform.localScale    = new Vector3(1, 1, 1);
             if (tex != null)
             {
                 tm.Material.mainTexture = tex;
             }
             showingObjects.Add(id, tm);
         }
         return(tm);
     }
     else
     {
         return(null);
     }
 }