void InitPoints() //Create the initial { globeNodeList = new List <GlobeNode>(); Vector3[] vertexArr = new Vector3[] { new Vector3(-1, t, 0), new Vector3(1, t, 0), new Vector3(-1, -t, 0), new Vector3(1, -t, 0), new Vector3(0, -1, t), new Vector3(0, 1, t), new Vector3(0, -1, -t), new Vector3(0, 1, -t), new Vector3(t, 0, -1), new Vector3(t, 0, 1), new Vector3(-t, 0, -1), new Vector3(-t, 0, 1) }; for (int i = 0; i < vertexArr.Length; i++) { GlobeNode newNode = Instantiate(nodePrefab, transform); newNode.transform.position = vertexArr[i]; newNode.transform.localScale /= (Mathf.Pow(numTessellations, 2) + 1); newNode.Orient(transform.position, radius, 0); newNode.listIndex = i; globeNodeList.Add(newNode); } }
public void Tessellate() //Only called by neighbors if hasTessellated = false { hasTessellated = true; for (int i = 0; i < neighbors.Count; i++) { if (!neighbors[i].hasTessellated) { GlobeNode newNode = Instantiate(nodePrefab, GetComponentInParent <Globe>().transform); newNode.transform.position = (transform.position + neighbors[i].transform.position) / 2; newNode.Orient(new Vector3(), GetComponentInParent <Globe>().radius, 1); newNode.listIndex = -1; newNode.newNeighbors = new List <GlobeNode>(6) //gives the baby node two neighbors it needs to succeed in life { this, neighbors[i] }; GetComponentInParent <Globe>().globeNodeList.Add(newNode); newNeighbors.Add(newNode); neighbors[i].newNeighbors2.Add(newNode); } } OrganizeNeighbors(); AssignNeighborsNeighbors(); for (int i = 0; i < neighbors.Count; i++) { if (!neighbors[i].hasTessellated) { neighbors[i].Tessellate(); } } }