public static Mesh BuildMesh(List <CSGNode> nodes) { Mesh mesh = new Mesh(); CSGTree tree = new CSGTree(); tree.RootNode = CreateTree(nodes); var updateNodes = CSGUtility.FindChildBrushes(tree); var modifiedMeshes = CSGCategorization.ProcessCSGNodes(tree.RootNode, updateNodes); Dictionary <CSGNode, CSGMesh> validMeshes = new Dictionary <CSGNode, CSGMesh>(); foreach (var item in modifiedMeshes) { validMeshes[item.Key] = item.Value; } Vector4[] vertices = new Vector4[65535]; int[] polyIndices = new int[65535 * 4]; int[] lineIndices = new int[65535 * 3]; Dictionary <Vector4, int> vertexLookup = new Dictionary <Vector4, int>(); int[] vertexIndexLookup = new int[65535]; int vertexCount; int polyIndexCount; int lineIndexCount; CreateListsFromMeshes(vertexLookup, vertexIndexLookup, validMeshes, vertices, out vertexCount, polyIndices, out polyIndexCount, lineIndices, out lineIndexCount); Vector4[] verts = new Vector4[vertexCount]; int[] indicies = new int[polyIndexCount]; Array.Copy(vertices, verts, verts.Length); Array.Copy(polyIndices, indicies, indicies.Length); mesh.Vertices = verts; mesh.Indicies = indicies; return(mesh); }
public static Mesh BuildMesh(List<CSGNode> nodes) { Mesh mesh = new Mesh(); CSGTree tree = new CSGTree(); tree.RootNode = CreateTree(nodes); var updateNodes = CSGUtility.FindChildBrushes(tree); var modifiedMeshes = CSGCategorization.ProcessCSGNodes(tree.RootNode, updateNodes); Dictionary<CSGNode, CSGMesh> validMeshes = new Dictionary<CSGNode, CSGMesh>(); foreach (var item in modifiedMeshes) validMeshes[item.Key] = item.Value; Vector4[] vertices = new Vector4[65535]; int[] polyIndices = new int[65535 * 4]; int[] lineIndices = new int[65535 * 3]; Dictionary<Vector4, int> vertexLookup = new Dictionary<Vector4, int>(); int[] vertexIndexLookup = new int[65535]; int vertexCount; int polyIndexCount; int lineIndexCount; CreateListsFromMeshes(vertexLookup, vertexIndexLookup, validMeshes, vertices, out vertexCount, polyIndices, out polyIndexCount, lineIndices, out lineIndexCount); Vector4[] verts = new Vector4[vertexCount]; int[] indicies = new int[polyIndexCount]; Array.Copy(vertices, verts, verts.Length); Array.Copy(polyIndices, indicies, indicies.Length); mesh.Vertices = verts; mesh.Indicies = indicies; return mesh; }
public static IEnumerable <CSGNode> FindChildBrushes(CSGTree tree) { return(FindChildBrushes(tree.RootNode)); }
public static IEnumerable<CSGNode> FindChildBrushes(CSGTree tree) { return FindChildBrushes(tree.RootNode); }