void createNewChildren(/*bool putTrees*/) { //float interval2 = radius / planetInfo.squareSectionAmmount; MeshRenderer mr; //Generate the noise for all of the terrain for (int i = 0; i < planetInfo.chunksAmmount; i++) { Vector3 xyz = planetInfo.calculateXYZ(i); // float xDisp = -radius + interval2 + (interval2 * 2 * xyz.x); // float yDisp = -radius + interval2 + (interval2 * 2 * xyz.y); planetInfo.nmArray[i] = Noise.GenerateNoiseMap(textQual, textQual, seed, noiseScale, octaves, persistance, lacunarity, getOffset(xyz), Noise.NormalizeMode.Global); GameObject gO = new GameObject(); planetInfo.chunkArray [i] = gO.transform; planetInfo.chunkObject [i] = gO; gO.transform.parent = gameObject.transform; gO.transform.localPosition = new Vector3(0, 0, 0); planetInfo.mfChunkArray [i] = gO.AddComponent(typeof(MeshFilter)) as MeshFilter; //MeshCollider mc = gO.AddComponent (typeof(MeshCollider)) as MeshCollider; //mc.enabled = false; //mc.convex = true; //if(pMaterial)mc.sharedMaterial = pMaterial; planetInfo.lodIdentifier [i] = LOD; //planetInfo.chunkObject [i].AddComponent<PlanetChunkID> ().chunkID = i; gO.transform.localEulerAngles = getAngle((int)xyz.z); planetInfo.mcArray[i] = gO.AddComponent <MeshCollider>(); planetInfo.mcArray [i].enabled = false; } //Fixing the terrain to concadenate well with eachother // for (int i = 0; i < planetInfo.chunksAmmount; i++) { // Vector3 xyz = planetInfo.calculateXYZ (i); // float xDisp = -radius + interval2 + (interval2 * 2 * xyz.x); // float yDisp = -radius + interval2 + (interval2 * 2 * xyz.y); // //fixTerrain (); // } // Material and Color for (int i = 0; i < planetInfo.chunksAmmount; i++) { planetInfo.colorArray[i] = generateColorAndFalloff(planetInfo.nmArray[i], textQual, useFalloff, false); Texture2D texture = new Texture2D(textQual, textQual); texture.filterMode = FilterMode.Point; texture.wrapMode = TextureWrapMode.Clamp; texture.SetPixels(planetInfo.colorArray [i]); texture.anisoLevel = 9; texture.Apply(); mr = planetInfo.chunkObject[i].AddComponent(typeof(MeshRenderer)) as MeshRenderer; mr.sharedMaterial = new Material(Shader.Find("Diffuse")); mr.sharedMaterial.mainTexture = texture; planetInfo.chunkObject [i].layer = gameObject.layer; planetInfo.chunkObject [i].name = (gameObject.name + "_" + i.ToString()); } if (waterPrefab) { GameObject water = GameObject.Instantiate(waterPrefab); water.transform.parent = gameObject.transform; water.transform.localPosition = Vector3.zero; float scale = radius * waterHeight; water.transform.localScale = new Vector3(scale, scale, scale); } //Create the mesh and show the terrain if (psh == null) { var localGO = gameObject.GetComponent <SpawningManager>(); if (localGO != null) { psh = localGO; } } if (objPlacerObj != null) { for (int i = 0; i < planetInfo.chunksAmmount; i++) { ObjectPlacer tp1 = planetInfo.chunkObject [i].AddComponent(typeof(ObjectPlacer)) as ObjectPlacer; objPlacerObj.copyTo(tp1); tp1.calculateObjectID(); } } StartCoroutine(updateAllMeshesCoroutine()); //This is where the making of the mesh and making of trees was done now it was moved to a // coroutine for immediate seeing of the meshes and possibly a more responsive UI //DebugConsole.Log ("AvailableSpawnPositions: " + psh.availableSpawns.Count.ToString (), "normal"); }