public void UpdateMapInEditor() { MapData mapData = Generator(); MapDisplay display = FindObjectOfType <MapDisplay>(); if (mode == DrawMode.Biome) { display.DisplayTexture(TextureGen.FromBiome(mapData.colorMap, mapSize, mapSize)); } else if (mode == DrawMode.Noise) { display.DisplayTexture(TextureGen.FromNoiseScale(mapData.noiseMap)); } else if (mode == DrawMode.Mesh) { MeshData meshData = MeshGen.TerrainMesh(mapData.noiseMap, heightMultiplier, HeightGradiant, LevelOfDetail); display.DisplayMesh(meshData, TextureGen.FromBiome(mapData.colorMap, mapSize, mapSize)); if (addvegetation) { List <GameObject> spawnedVeget = new List <GameObject>(); spawnedVeget = VegetationGenerator.PlaceVegetation(mapData.noiseMap, meshData, LevelOfDetail, biomes, density, spawnedVeget); spawnedVeget = RaycastSpawning.Adjust(spawnedVeget, InGround); spawnedVeget.Clear(); } } }
public static MeshData GenerateTerrainMesh(float[,] heightMap, float heightMulti, AnimationCurve heightCurve, Vector2 chunkCoords, TerrainType[] regions) { int width = heightMap.GetLength(0); int height = heightMap.GetLength(1); float topLeftX = (width - 1) / -2f; float topLeftZ = (height - 1) / 2f; Texture2D meshTexture = TextureGen.TextureFromColorMap(ColorGen.GenerateColorMapFromHeightMap(heightMap, regions), width, height); Color[] colorMap = ColorGen.GenerateColorMapFromHeightMap(heightMap, regions); MeshData currentMeshData = new MeshData(width, height, chunkCoords, meshTexture, colorMap); int vertexIndex = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { currentMeshData.vertices[vertexIndex] = new Vector3(topLeftX + x, heightCurve.Evaluate(heightMap[x, y]) * heightMulti, topLeftZ - y); currentMeshData.uvs[vertexIndex] = new Vector2(x / (float)width, y / (float)height); if (x < width - 1 && y < height - 1) { currentMeshData.AddTriangle(vertexIndex, vertexIndex + width + 1, vertexIndex + width); currentMeshData.AddTriangle(vertexIndex + width + 1, vertexIndex, vertexIndex + 1); } vertexIndex++; } } return(currentMeshData); }
public void GenerateMap() { float[,] noiseMap = Noise.GenNoiseMap(mapChunkSize, mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, offset); Color[] colormap = new Color[mapChunkSize * mapChunkSize]; for (int y = 0; y < mapChunkSize; y++) { for (int x = 0; x < mapChunkSize; x++) { float currentHeight = noiseMap [x, y]; for (int i = 0; i < regions.Length; i++) { if (currentHeight <= regions [i].height) { colormap [y * mapChunkSize + x] = regions [i].color; break; } } } MapDisplay display = FindObjectOfType <MapDisplay> (); if (drawMode == DrawMode.NoiseMap) { display.DrawTexture(TextureGen.TextureFromHeightMap(noiseMap)); } else if (drawMode == DrawMode.ColorMap) { display.DrawTexture(TextureGen.TextureFromColorMap(colormap, mapChunkSize, mapChunkSize)); } else if (drawMode == DrawMode.Mesh) { display.DrawMesh(MeshGen.GenerateTerrainMesh(noiseMap, meshHeightMultiplier, MeshHeightCurve, levelOfDetail), TextureGen.TextureFromColorMap(colormap, mapChunkSize, mapChunkSize)); } } }
void OnMapDataRecieved(MapData mapData) { this.mapData = mapData; mapDataRecieved = true; Texture2D texture = TextureGen.TextureFromColorMap(mapData.colorMap, MapGen.mapChunkSize, MapGen.mapChunkSize); meshRenderer.material.mainTexture = texture; UpdateTerrainChunk(); }
void OnMapDataRecieved(MapData mapData) { this.mapData = mapData; this.heightMap = mapData.getHeightMap(); recievedMapdata = true; int c = mapGen.getSize(); Texture2D t = TextureGen.TextureFromColourMap(mapData.colMap, c, c); mRend.material.mainTexture = t; UpdateTerainChunk(); }
// Use this for initialization void Start() { // Create base map TextureGen base_gen = new TextureGen(); base_gen.texture_width = 40; base_gen.fractalType = FractalType.RIDGEDMULTI; base_gen.frequency = Random.Range(2.0f, 3.0f); // Set the texture GetComponent <Renderer>().material.SetTexture("_DiffuseTexture", base_gen.getTexture()); }
public override void LoadContent(ContentManager cm) { //var worldTexture = Texture2D.FromFile(Global.Device,"../Build/Content/RuntimeContent/Biomes.bmp"); //AssetManager.LoadTexture("world",worldTexture); Database.Load("../Build/Content/RuntimeContent/Equipment.txt"); AssetManager.LoadFont("../Build/Content/RuntimeContent/profont_12.fnt", "profont_12"); AssetManager.LoadFont("../Build/Content/RuntimeContent/profont.fnt", "profont"); AssetManager.LoadTexture("selectionrect4"); //AssetManager.LoadTexture("tree"); //AssetManager.LoadTexture("dawn"); AssetManager.LoadTexture("pixel", TextureGen.Pixel(Global.Device, "ffffff")); base.LoadContent(cm); }
private void prepiewTexture() { //preview if ((!String.IsNullOrEmpty(szTextureFilenames[0])) && (!String.IsNullOrEmpty(szTextureFilenames[1])) && (!String.IsNullOrEmpty(szTextureFilenames[2])) && (m_pRaster != null)) { double[,] dbData = TextureGen.raster2double(m_pRaster); int[] nTempValues = (int[])nThresholdValues.Clone(); picPreview.Image = TextureGen.textureGen(dbData, szTextureFilenames, nTempValues); picPreview.Refresh(); } }
public void GenerateMap() { float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, seed, noiseScale, octaves, persistance, lacunarity, offset); Color[] colourMap = new Color[mapWidth * mapHeight]; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { if (useFallOff) { noiseMap[x, y] = Mathf.Clamp01(fallOffMap[x, y] - noiseMap[x, y]); } float currentHeight = noiseMap[x, y]; for (int i = 0; i < Regions.Length; i++) { if (currentHeight <= Regions[i].height) { colourMap[y * mapWidth + x] = Regions[i].colour; break; } } } } MapDisplay display = FindObjectOfType <MapDisplay>(); if (drawMode == DrawMode.NoiseMap) { display.drawTexture(TextureGen.textureFromHeightMap(noiseMap)); } else if (drawMode == DrawMode.ColourMap) { display.drawTexture(TextureGen.textureFromColourMap(colourMap, mapWidth, mapHeight)); } else if (drawMode == DrawMode.Mesh) { display.drawMesh(MeshGenerator.generateTerrainMesh(noiseMap, meshHeightMult, heightCurve, useFlatshading), TextureGen.textureFromColourMap(colourMap, mapWidth, mapHeight)); } else if (drawMode == DrawMode.FallOff) { display.drawTexture(TextureGen.textureFromHeightMap(FalloffGen.GenerateFallOffMap(mapWidth))); } }
private void CreateHeightMap(PlanetConfig _p_config) { Debug.Log("Creating planet heightmap", gameObject); //// Create base map TextureGen base_gen = new TextureGen(); base_gen.frequency = Random.Range((float)_p_config.size, 1.0f + (float)_p_config.size + (float)_p_config.size * 2); // Set the texture GetComponent <Renderer>().material.SetTexture("_DiffuseTexture", base_gen.getTexture()); //// Create civ map CivTexGen civ_gen = new CivTexGen(); GetComponent <Renderer>().material.SetTexture("_CivTexture", civ_gen.getTexture(base_gen.getTexture(), _p_config.has_civ, _p_config.density)); }
public void DrawMapInEditor() { MapData map = GenerateMapData(Vector2.zero); if (drawMode == DrawMode.NoiseMap) { display.DrawTexture(TextureGen.TextureFromNoiseMap(map.heightMap)); } else if (drawMode == DrawMode.ColourMap) { display.DrawTexture(TextureGen.TextureFromColourMap(map.colMap, mapChunkSize, mapChunkSize)); } else if (drawMode == DrawMode.Mesh) { display.DrawMesh(MeshGen.GenerateTerrainMesh(map.heightMap, heightCoefficient, heightExponent, meshHeightCurve, editorLOD), TextureGen.TextureFromColourMap(map.colMap, mapChunkSize, mapChunkSize)); } }
public void DrawMapInEditor() { MapData mapData = GenerateMapData(Vector2.zero); MapDisplay display = FindObjectOfType <MapDisplay>(); if (drawMode == DrawMode.NoiseMap) { display.DrawTexture(TextureGen.TextureFromHeightMap(mapData.heightMap)); } else if (drawMode == DrawMode.ColorMap) { display.DrawTexture(TextureGen.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize)); } else if (drawMode == DrawMode.Mesh) { display.DrawMesh(MeshGen.GenerateMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD), TextureGen.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize)); } }
private void Update() { chunkSize = terrain.getChunkSize(); terrainDict = terrain.getCoordsTerrainDict(); var playerPos = player.position; Vector2 chunkCoord = new Vector2(0, 0); chunkCoord.x = Mathf.RoundToInt(playerPos.x / chunkSize); chunkCoord.y = Mathf.RoundToInt(playerPos.z / chunkSize); float scale = mapGen.noiseScale; var heightMap = terrainDict[chunkCoord].getHeightMap(); var newNoise = Noise.GenerateNoiseMap(chunkSize + 1, chunkSize + 1, scale, 1, 0.5f, 2f, 0, Vector2.zero); var newItem = spawnables[0]; var spawnMask = getPossibleSpawnPoints(heightMap, newNoise, newItem.startRange, newItem.endRange); var spawnHeights = applyMask(heightMap, spawnMask); var text = TextureGen.TextureFromNoiseMap(spawnHeights); DrawTexture(text); for (int i = 0; i < maxSpawned; i++) { GameObject item = spawnedItems[i]; if (item == null) { if (terrainDict.ContainsKey(chunkCoord)) { } } else if (sqrDist(player, item.transform) > sqrDespawnDist) { // delete gameobject and set item to null } } }
public void DrawingInEditor() { MapData mapData = GenMapData(); //referenceing MapDisplay & TextureGen for noise and color with width & height MapDisplay display = FindObjectOfType <MapDisplay>(); if (drawMode == DrawMode.NoiseMap) { display.DrawTexture(TextureGen.TextureFromHeight(mapData.heightMap)); } else if (drawMode == DrawMode.ColorMap) { display.DrawTexture(TextureGen.TextureFromMap(mapData.colorMap, mapChunkSize, mapChunkSize)); } else if (drawMode == DrawMode.Mesh) { display.DrawMesh(MeshGen.GenTerrain(mapData.heightMap, meshHeightMultipler, meshHeightCurve, levelOfDetail), TextureGen.TextureFromMap(mapData.colorMap, mapChunkSize, mapChunkSize)); } }
public void DrawMapInEditor() { MapData mapdata = GenThatMapData(Vector2.zero); Map map = FindObjectOfType <Map>(); if (drawMode == DrawMode.NoiseMap) { map.DrawTexture(TextureGen.TextureFromHeightMap(mapdata.heightMap)); } else if (drawMode == DrawMode.ColorMap) { map.DrawTexture(TextureGen.TextureFromColorMap(mapdata.colorMap, mapChunkSize, mapChunkSize)); } else if (drawMode == DrawMode.DrawMesh) { map.DrawMesh(MeshGen.GennerateTerrainMesh(mapdata.heightMap, meshHeight, meshHeightCurve, editorlevelOfDetail), TextureGen.TextureFromColorMap(mapdata.colorMap, mapChunkSize, mapChunkSize)); } else if (drawMode == DrawMode.FallOffMap) { map.DrawTexture(TextureGen.TextureFromHeightMap(FalloffMapGenerator.GenerateFalloffMapp(mapChunkSize))); } }
void OnScene(SceneView scene) { if (stampMode == StampMode.Nothing) { return; } HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); Event e = Event.current; terrainGenerator = gameObject.GetComponent <TerrainGenerator>(); if (e.type == EventType.MouseDown && e.button == 0) { Vector3 mousePos = e.mousePosition; float ppp = EditorGUIUtility.pixelsPerPoint; mousePos.y = scene.camera.pixelHeight - mousePos.y * ppp; mousePos.x *= ppp; Ray ray = scene.camera.ScreenPointToRay(mousePos); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Mesh mesh = hit.collider.gameObject.GetComponent <MeshFilter>().sharedMesh; MeshRenderer meshRenderer = hit.collider.gameObject.GetComponent <MeshRenderer>(); MeshFields meshFields = hit.collider.gameObject.GetComponent <MeshFields>(); MeshCollider meshCollider = hit.collider.gameObject.GetComponent <MeshCollider>(); Transform trans = hit.collider.gameObject.transform; Vector3[] verts = mesh.vertices; List <VertexData> verticesToChange = new List <VertexData>(); float nearestDistance = Mathf.Infinity; for (int i = 0; i < verts.Length; i++) { Vector3 worldPt = trans.TransformPoint(verts[i]); float dist = Vector2.Distance(new Vector2(worldPt.x, worldPt.z), new Vector2(hit.point.x, hit.point.z)); if (dist < radius) { if (stampMode == StampMode.Mountain) { verts[i].y += (radius - dist) * heightMultiplier + Random.Range(0, persistance); meshFields.MeshData.colorMap[i] = checkColorFromHeight(verts[i].y, terrainGenerator.regions, terrainGenerator.meshHeightCurve, terrainGenerator.meshHeightMultiplier); } if (stampMode == StampMode.Flatten) { bool nearestToCursor = false; if (dist < nearestDistance) { nearestDistance = dist; nearestToCursor = true; } VertexData vertex = new VertexData(i, verts[i], nearestToCursor); verticesToChange.Add(vertex); } if (stampMode == StampMode.Paint) { meshFields.MeshData.colorMap[i] = paintColor; } } } if (stampMode == StampMode.Flatten) { float referenceY = 0f; foreach (VertexData vertexData in verticesToChange.Where(vertexData => vertexData.closestToCursor)) { referenceY = vertexData.position.y; } foreach (VertexData vertexData in verticesToChange) { float dif = referenceY - verts[vertexData.index].y; if (Math.Abs(dif) < flattenStepSize) { verts[vertexData.index].y = referenceY; } else if (dif < 0) { verts[vertexData.index].y -= flattenStepSize; } else if (dif > 0) { verts[vertexData.index].y += flattenStepSize; } meshFields.MeshData.colorMap[vertexData.index] = checkColorFromHeight(verts[vertexData.index].y, terrainGenerator.regions, terrainGenerator.meshHeightCurve, terrainGenerator.meshHeightMultiplier); } } mesh.vertices = verts; mesh.RecalculateBounds(); mesh.RecalculateNormals(); meshCollider.sharedMesh = mesh; Texture2D meshTexture = TextureGen.TextureFromColorMap(meshFields.MeshData.colorMap, meshFields.MeshData.dims.x, (int)mesh.bounds.size.z); meshRenderer.sharedMaterial.mainTexture = meshTexture; } e.Use(); } HandleUtility.Repaint(); }
public void GenerateMap() { numOfTrees = 0; numOfStones = 0; parentObject = GameObject.FindGameObjectWithTag("Objects").transform; //SceneManager.LoadScene("LevelGenScrene"); //EditorSceneManager.LoadScene("LevelGenScrene"); GameObject cleanup; while (cleanup = GameObject.FindWithTag("Tree")) { Object.DestroyImmediate(cleanup); } while (cleanup = GameObject.FindWithTag("Stone")) { Object.DestroyImmediate(cleanup); } while (cleanup = GameObject.FindWithTag("Bush")) { Object.DestroyImmediate(cleanup); } while (cleanup = GameObject.FindWithTag("Boulder")) { Object.DestroyImmediate(cleanup); } while (cleanup = GameObject.FindWithTag("Grass")) { Object.DestroyImmediate(cleanup); } float a = Random.Range(5f, 20f); float b = Random.Range(0f, 20f); float c = Random.Range(5f, 20f); float d = Random.Range(0f, 20f); float[,] noiseMap = NoiseMapGen.GenerateNoiseMap(mapWidth, mapHeight, a, b, c, d); MeshData meshData = MeshGen.GenerateTerrainMesh(noiseMap, meshHeightMulitplier, heightCurve); triangles = meshData.triangles; Color[] colorMap = new Color[mapWidth * mapHeight]; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { float currentHeight = Mathf.InverseLerp(0, 20, noiseMap[x, y]); for (int i = 0; i < regions.Length; i++) { if (currentHeight <= regions[i].height) { //New code to try and get lerp from one zone to another //Skipping earth into grass transition if (regions[i].name.Equals("Earth")) { float tempMaxHeightOfRegion = regions[i].height; float tempMinHeightOfRegion = regions[i - 1].height; float tempMidHeightOfRegion = regions[i - 1].height + ((regions[i].height - regions[i - 1].height) / 2); if (currentHeight > tempMidHeightOfRegion) { colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i + 1].color, Mathf.InverseLerp(tempMidHeightOfRegion, tempMaxHeightOfRegion, currentHeight)); } else { colorMap[y * mapWidth + x] = regions[i].color; } } else if (i > 0 && i < regions.Length - 1) { float tempMaxHeightOfRegion = regions[i].height; float tempMinHeightOfRegion = regions[i - 1].height; float tempMidHeightOfRegion = regions[i - 1].height + ((regions[i].height - regions[i - 1].height) / 2); /*if (currentHeight >= tempMinHeightOfRegion) * colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i + 1].color, /*(float) noiseMap[x, y]/10 Mathf.InverseLerp(tempMidHeightOfRegion, tempMaxHeightOfRegion, currentHeight)); * else if (currentHeight < tempMinHeightOfRegion) * { * colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i - 1].color, /*(float) noiseMap[x, y]/10 Mathf.InverseLerp(tempMinHeightOfRegion, tempMidHeightOfRegion, currentHeight)); * }*/ //colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i + 1].color, /*(float) noiseMap[x, y]/10*/ Mathf.InverseLerp(tempMinHeightOfRegion, tempMaxHeightOfRegion, currentHeight) - 0.1f); if (currentHeight > tempMidHeightOfRegion) { colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i + 1].color, Mathf.InverseLerp(tempMidHeightOfRegion, tempMaxHeightOfRegion, currentHeight)); } else { colorMap[y * mapWidth + x] = regions[i].color; } } else if (i == 0) { /*float tempMaxHeightOfRegion = regions[i].height; * float tempMinHeightOfRegion = 0; * float tempMidHeightOfRegion = 0 + ((regions[i].height - 0) / 2); * if(currentHeight > tempMidHeightOfRegion) * colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i + 1].color, /*(float) noiseMap[x, y]/10 Mathf.InverseLerp(tempMidHeightOfRegion, tempMaxHeightOfRegion, currentHeight)); * else*/ colorMap[y * mapWidth + x] = regions[i].color; } else { /*float tempMaxHeightOfRegion = regions[i].height; * float tempMinHeightOfRegion = regions[i - 1].height; * float tempMidHeightOfRegion = regions[i - 1].height + ((regions[i].height - regions[i - 1].height) / 2); * colorMap[y * mapWidth + x] = Color.Lerp(regions[i].color, regions[i - 1].color, /*(float) noiseMap[x, y]/10 Mathf.InverseLerp(tempMinHeightOfRegion, tempMaxHeightOfRegion, currentHeight)); */ colorMap[y * mapWidth + x] = regions[i].color; } //OG code for coolour depending on height //colorMap[y * mapWidth + x] = regions[i].color; //place Gameobjects //trees/bushes on grassy area if (regions[i].name.Equals("Grass")) { if (Random.Range(0f, 1f) > 0.9f) { Vector3 treePos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(trees[(int)Random.Range(0, trees.Length)], treePos, Quaternion.identity); numOfTrees++; currentInstance.transform.parent = parentObject; } else if (Random.Range(0f, 1f) > 0.8f) { Vector3 bushPos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(bushes[(int)Random.Range(0, bushes.Length)], bushPos, Quaternion.identity); currentInstance.transform.parent = parentObject; } if (Random.Range(0f, 1f) > 0.75f) { Vector3 grassPos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(grasses[(int)Random.Range(0, grasses.Length)], grassPos, Quaternion.identity); currentInstance.transform.parent = parentObject; } } //Stones on Sand else if (regions[i].name.Equals("Sand")) { if (Random.Range(0f, 1f) > 0.9f) { Vector3 stonePos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(stones[(int)Random.Range(0, stones.Length)], stonePos, Quaternion.identity); numOfStones++; currentInstance.transform.parent = parentObject; } } else if (regions[i].name.Equals("Earth")) { if (Random.Range(0f, 1f) > 0.96f) { Vector3 treePos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(beachTrees[(int)Random.Range(0, beachTrees.Length)], treePos + new Vector3(0, 3.5f, 0), Quaternion.Euler(-90, 0, 0)); currentInstance.transform.parent = parentObject; } else if (Random.Range(0f, 1f) > 0.9f) { Vector3 stonePos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(stones[(int)Random.Range(0, stones.Length)], stonePos, Quaternion.identity); currentInstance.transform.parent = parentObject; } else if (Random.Range(0f, 1f) > 0.90f) { Vector3 grassPos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(deadGrass, grassPos + new Vector3(0, 0.3f, 0), Quaternion.identity); currentInstance.transform.parent = parentObject; } } else if (regions[i].name.Equals("Mountain")) { if (Random.Range(0f, 1f) > 0.95f) { Vector3 boulderPos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(bouldersMountain[(int)Random.Range(0, bouldersMountain.Length)], boulderPos, Quaternion.identity); currentInstance.transform.localScale = new Vector3(Random.Range(8, 10), Random.Range(8, 10), Random.Range(8, 10)); currentInstance.transform.parent = parentObject; } else if (Random.Range(0f, 1f) > 0.99f) { float temp = Random.Range(5, 10); Vector3 boulderPos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(treesMountain[(int)Random.Range(0, treesMountain.Length)], boulderPos, Quaternion.identity); currentInstance.transform.localScale = new Vector3(temp, temp, temp); currentInstance.transform.parent = parentObject; } } else if (regions[i].name.Equals("Snow")) { if (Random.Range(0f, 1f) > 0.9f) { Vector3 boulderPos = Vector3.Scale(meshData.vertices[y * mapWidth + x], new Vector3(5, 1, 5)); currentInstance = Instantiate(boulders[(int)Random.Range(0, boulders.Length)], boulderPos, Quaternion.identity); currentInstance.transform.parent = parentObject; } } break; } } } } //Force conditions if (numOfTrees < minNumOfTree || numOfStones < minNumOfStones) { Debug.Log("Not Enough"); GenerateMap(); } else { Debug.Log("Enough"); MapDisplay display = FindObjectOfType <MapDisplay>(); //display.DrawTexture(TextureGen.TextureFromColorMap(colorMap, mapWidth, mapHeight)); //Select render type just 2d colour or 3d mesh display.DrawMesh(meshData, TextureGen.TextureFromColorMap(colorMap, mapWidth, mapHeight)); //Texture try //setTextureTriangles(meshData); //display.DrawMeshWithSubMesh(meshData/*, water.ToArray(), sand.ToArray(), earth.ToArray(), forest.ToArray(), mountain.ToArray(), snow.ToArray()*/); } }
private void Start() { Map map = FindObjectOfType <Map>(); MapData mapdata = GenThatMapData(Vector2.zero); if (drawMode == DrawMode.DrawMesh) { map.DrawMesh(MeshGen.GennerateTerrainMesh(mapdata.heightMap, meshHeight, meshHeightCurve, editorlevelOfDetail), TextureGen.TextureFromColorMap(mapdata.colorMap, mapChunkSize, mapChunkSize)); } }