public void dfsChains(GameObject component) { List <Transform> properChildren = this.getProperChildren(component); bool previousSpheresExist = (properChildren.Count != component.transform.childCount); // Generate crossing for parent sphere Vector3[] parentCorners; // Cross a section through the middle of the sphere if it is a normal node. // If it's a leaf, cross a tiny section through its top side, so that the total mesh ends // with a corner. if (properChildren.Count == 0) { parentCorners = MeshGenerationUtils.generateQuadSection(this.container, component, MeshGenerationUtils.sphereRadius, .5f); } else if (component.Equals(this.parentSphere)) { parentCorners = MeshGenerationUtils.generateQuadSection(this.container, component, -MeshGenerationUtils.sphereRadius, .5f); } else { parentCorners = MeshGenerationUtils.generateQuadSection(this.container, component); } this.sphereCrosses.Add(component.GetInstanceID(), parentCorners); foreach (Transform child in properChildren) { dfsChains(child.gameObject); } if (properChildren.Count == 1) { // Populate linear path between parent sphere and child sphere with spheres if (!previousSpheresExist) { MeshGenerationUtils.generateParentChildSpheres(component, properChildren[0].gameObject); } // Get all child spheres, before adding other things to the hierarchy of the Transform. List <Transform> sphereChildren = getSphereChildren(component); // Place a quad in each of the spheres on the way from parent to child // In order to get the 4 points that the sphere contributes to creating the mesh. List <Vector3[]> meshPoints = generateQuadSections(component, sphereChildren); //Vector3[] parentPoints = List <Vector3> points = new List <Vector3> (); foreach (Vector3[] meshPoint in meshPoints) { points.AddRange(meshPoint); } Mesh m = MeshGenerationUtils.createConvexHullMesh(points); GameObject selection = MeshGenerationUtils.createGOFromMesh(MeshGenerationUtils.PARTIAL_MESH_NAME, this.container, m); meshes.Add(selection); // Create a mesh out of the corner points obtained in generateQuadSections //GameObject mesh = generateMesh (parentSphere, meshPoints); //meshes.Add (mesh); } }
public void dfsSplits(GameObject component) { List <Transform> properChildren = this.getProperChildren(component); foreach (Transform child in properChildren) { dfsSplits(child.gameObject); } if (properChildren.Count > 1) { List <Vector3> points = new List <Vector3>(); foreach (Transform child in properChildren) { points.AddRange(this.sphereCrosses [child.gameObject.GetInstanceID()]); } points.AddRange(this.sphereCrosses[component.GetInstanceID()]); // Mesh mesh = MeshGenerationUtils.createMesh (points); Mesh m = MeshGenerationUtils.createConvexHullMesh(points); GameObject selection = MeshGenerationUtils.createGOFromMesh(MeshGenerationUtils.PARTIAL_MESH_NAME, this.container, m); meshes.Add(selection); } }