public static void ApplyTerrainTextures(Planet planet, TerrainTexture[] textures) { //MeshFilter filter = sphere.GetComponent<MeshFilter>(); //Mesh mesh = filter.mesh; //foreach (TerrainTexture t in textures) { //planet.land.renderer.material = (Material) GameObject.Instantiate (planetProps.landMaterial); //} }
public static void GenerateSubTerrain(Planet planet, HeightmapProperties heightProps, float scale, int seed, float cutoff = 0f) { GameObject sphere = planet.land.gameObject; System.Random rand = new System.Random(seed); UnityEngine.Random.seed = rand.Next (); HeightMap terrainMap = HeightMapGen.GenBasicTerrainMap(heightProps, rand.Next()); int subTimes = UnityEngine.Random.Range (8, 16); for (int i = 0; i < subTimes; i++) { UnityEngine.Random.seed = rand.Next (); string blendMode = HeightmapProperties.heightBlendModes[UnityEngine.Random.Range (0, HeightmapProperties.heightBlendModes.Length - 1)]; float blendAmount = 1f + UnityEngine.Random.value; int posX = UnityEngine.Random.Range (0, Mathf.Abs (terrainMap.Heights.GetLength(0) - 1)); int posY = UnityEngine.Random.Range (0, Mathf.Abs (terrainMap.Heights.GetLength(1) - 1)); int nx = rand.Next (); HeightmapProperties submap = HeightmapProperties.GetRandSub(nx); HeightMap subTerrainMap = HeightMapGen.GenBasicTerrainMap(submap, rand.Next()); terrainMap.Blend(subTerrainMap, blendMode, posX, posY, blendAmount); } terrainMap.AntiAlias (); terrainMap.Smoothen (); terrainMap.MendSeams (); SphereGenerator.ApplyHeightMap(sphere, scale, terrainMap.Heights, cutoff); }