コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public static IEnumerable <CSGNode> FindChildBrushes(CSGTree tree)
 {
     return(FindChildBrushes(tree.RootNode));
 }
コード例 #4
0
 public static IEnumerable<CSGNode> FindChildBrushes(CSGTree tree)
 {
     return FindChildBrushes(tree.RootNode);
 }