WTG (Wade Terrain Generator) v 0.3
This post continues the development of the WTG (Wade Terrain Generator).
A Few Notes Before I Get Started
- This demo uses Wade 4.0.1
- D3 is freely available here and is released under the BSD license.
- Azgaar’s blog is here. I have used many of his ideas and some of his code in this endeavor.
- I have also used ideas and code from, “Christophe Le Besnerais”, his island terrain implementation is located on github here.
Wade Terrain Generator v 0.3
At the end of the last post, there were a few things I planned to do for this version
- Change coastline to just draw edges, not entire polygon — done
- Adding rivers — done, need to improve drawing method for river segments
- Adding noise for moisture to extend biome list — done, but adding moisture via Christophe’s code, not using noise
- Add selectors to map parameters (noise octaves, noise frequency) — you can change island size and moisture level, but code doesn’t use noise
- Change noise library to released version – made no changes to how noise is generated, still using perlin.js and Simplex.js
Final Results Preview
When you load the page, you see a blank grey screen with three tabs, (Geometry, Map, Export). The export tab is currently not implemented, so don’t bother with that.
Click the geometry tab and you should see a menu to create a voronoi diagram (the map’s underlying geometry). You can drag the sliders to change the map’s x and y dimensions as well as the approximate radius between polygon centers. Based on your adjustments, the estimated number of polygons will be displayed . Click the build button to create the underlying geometry. You can draw or hide the geometry information as before.
Click the map tab and you should see a menu with two sliders. The generator always creates an island, but you can use the size slider to make the land mass bigger or smaller relative to the surrounding ocean. The second slider controls the amount of moisture that will be created on the terrain. I wouldn’t push the slider too high as the rivers and lakes will start to look clunky (something to improve in the future). Click the build button build to create an island with some terrain features. You can use the scroll wheel to zoom the map in our out.
Note: If you create a map without first creating an underlying geometry, nothing will happen (you’ll see an error if you have the console open). If you create a map, you can change the sliders and then click the map button to erase it and create a new map. Once you create a map, if you change the underlying geometry you will have to rebuild the map to see the changes.
So, where to go from here, some ideas (in no particular order) :
- Improve map display by implementing some sort of elevation shading or terrain contouring.
- Add, ‘political’, map layer, i.e. cities, countries, borders
- Add path finding from locations on the map
- Do something with the, ‘Export‘, tab. Export an image, or json data (???).
- Clean up the code. There are some redundant loops and checks. Do more error checking.
- Change noise library to released version (same as last time – if I keep writing it down maybe I will actually get to it).
Mainly, I have no idea if anyone will be using this, so I’m not sure what would be the most useful next step.
If you do plan to use this, feel free to post your suggestions here or on the Wade forum and I’ll see what I can do.
Download and extract the zip file, load wtgDemo.html in your browser to see it in action.
The code contains comments, so I hope it is easy to follow. Feel free to play around and use the code however you want.
cheers – Shri