public static Dictionary <Corners, MeshPart> GetPartSet(int resolution) { Dictionary <Corners, MeshPart> Parts = new Dictionary <Corners, MeshPart>(); for (int i = 0; i < Tables.TriTable.Length; i++) { Corners corner = (Corners)i; int[] tris = Tables.TriTable[i]; List <int> validTris = new List <int>(); for (int x = 0; x < tris.Length; x++) { if (tris[x] > -1) { validTris.Add(tris[x]); } } MeshPart part = new MeshPart(Meshes.Edges, validTris.ToArray()); part.verts.ScaleVerts(resolution); Parts.Add(corner, part); } return(Parts); }
/// <summary> /// Recalculates the node's neighbouring vacancy /// </summary> public void Recalculate() { Corners lastNeighbours = m_VacantNeighbours; // if there is a point inside -> all of the neighbours will be populated if (m_PointInside) { m_VacantNeighbours = Corners.None; } else { // by default none of the neighbours are populated m_VacantNeighbours = Corners.All; foreach (KeyValuePair <Corners, Vector3> item in m_Manager.RelativeNeighbourPositions) { Node neighbourNode = m_Manager.GetNode(m_NodePos + item.Value); if (neighbourNode != null) { // if a neighbouring node has a point inside, remove that neighbour from being vacant if (neighbourNode.PointInside) { m_VacantNeighbours &= ~item.Key; } } } } // update mesh only if a change has happened if (lastNeighbours != m_VacantNeighbours) { m_Manager.TryGetMeshPart(this, out MeshPart part); m_Mesh = part; m_Mesh.color = Color; } }
public MeshPart(MeshPart basemesh, Color vertcolor) { color = vertcolor; verts = new Vector3[basemesh.verts.Length]; basemesh.verts.CopyTo(verts, 0); tris = new int[basemesh.tris.Length]; basemesh.tris.CopyTo(tris, 0); }
public MeshPart(MeshPart basemesh, int[] newTris) { color = basemesh.color; verts = new Vector3[basemesh.verts.Length]; basemesh.verts.CopyTo(verts, 0); tris = new int[newTris.Length]; newTris.CopyTo(tris, 0); }
/// <summary> /// Gets a mesh part for given node /// </summary> /// <param name="node">Node to get mesh for</param> /// <param name="part">Part for the node</param> /// <returns>True if a part was found, false otherwise</returns> public bool TryGetMeshPart(Node node, out MeshPart part) { part = new MeshPart(Meshes.INVALID); part.color = node.Color; if (Parts.ContainsKey(node.VacantNeighbours)) { part = new MeshPart(Parts[node.VacantNeighbours]); for (int i = 0; i < part.verts.Length; i++) { part.verts[i] += node.NodePos; } return(true); } return(false); }