コード例 #1
0
 void Start()
 {
     adjacencies  = graph.GetAdjacencies();
     weights      = graph.GetWeights();
     vertexTables = new VertexTable[graph.vertex.Count];
     for (int i = 0; i < vertexTables.Length; i++)
     {
         vertexTables[i] = new VertexTable();
     }
     Search();
 }
コード例 #2
0
        /// <summary>
        /// Move a vertex of the polygon and recreate the mesh
        /// </summary>
        /// <param name="data">MoveArgs</param>
        public void ShapeMoveVertex(MoveArgs data)
        {
            Mesh         mesh = Shape.GetComponent <MeshFilter>().mesh;
            MeshCollider mc   = Shape.GetComponent <MeshCollider>();
            MeshRenderer mr   = Shape.GetComponent <MeshRenderer>();
            Material     mat  = mr.material;

            Destroy(mc);
            mc = Shape.AddComponent <MeshCollider>();
            Vector3[] vertices = mesh.vertices;
            vertices[VertexTable.Find(item => item.Id == data.id).pVertex] = Shape.transform.InverseTransformPoint(data.pos);
            mesh.vertices = vertices;
            mesh.uv       = BuildUVs(vertices);
            mesh.RecalculateBounds();
            mesh.RecalculateNormals();
            try {
                Physics.BakeMesh(mesh.GetInstanceID(), false);
                mc.sharedMesh = mesh;
            } catch (Exception e) {
                Debug.Log(e.ToString());
            }
            mat.SetVector("_Tiling", new Vector2(scaleX / _tiling_size, scaleY / _tiling_size));
        }