Giter VIP home page Giter VIP logo

voronoimapgen's Introduction

VoronoiMapGen

Generation of random Island maps with Voronoi using C++

About the Procedural Island Generator

This project is a procedural island generator following the tutorial at http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/

It has the following steps:

  • Place a number of random but uniformly distributed points.
  • Calculate the Voronoi diagran of the points.
  • Determine which cells are land and which are water.
  • Calculate the elevation of each point as its distance to the sea. Normalize all the heights.
  • Place river sources in random spots and let them flow downwards.
  • Calculate the moisture value each point given its distance to the sea (less moisture) and rivers (more moisture)
  • Calculate the Biome according to moisture

How to Use

Run the exe Executable file under Bin\Debug\ or Bin\Release floder, some parameters as below:

  • the 2D image size can be changed from 20 to 65535, I think too small image size is meaningless.
  • In a shape number like 20928-2, 20928 chooses the overall island shape and 2 is the random number seed for the details (random points, noisy edges, rivers). You can type in a shape number and press "Generate" button to generate that map. The details will vary based on the other options you’ve selected.
  • Radial, Perlin, Square, Blob are about the island shape.
  • Relaxed, PoissonDisk, Squared, Hexagon are about how the map is divided up into polygons.
  • site number also can be changed, but using 4000 or 8000 points can be slow.
  • Roads also be calculated according to contour lines along the corners. Where the contour level changes, there’s a road.
  • The PNG output is now 1024x1024, and draws the selected mode (biomes, polygons, smooth, 2d slopes, 3d slopes etc.).
  • The PNG output and XML output will be generated under the Data\Output\ directory.

Example

Map Generation example

Requirements

No other requirment, the project is based my SGP Engine. You can open Builds\VisualStudio2010\VoronoiMapGen.sln with VS 2010, Compile and Enjoy it!

Developed By

I would like to give thanks to the people whose libraries helped make this project a reality(It seems changing my project from C++ to C! orz:)):

  • ImGui Immediate Mode Graphical User interface for C++ with minimal dependencies
  • stb_image.hSingle file Library: image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
  • stb_image_resize.hSingle file Library: resize images larger/smaller with good quality
  • stb_image_write.hSingle file Library: image writing to disk: PNG, TGA, BMP
  • tinyfiledialogs Single file Library: modal dialogs inc. file open/save
  • pugixml Light-weight, simple and fast XML parser for C++ with XPath support
  • Bresenham's algorithm The Beauty of Bresenham's Algorithm

by phoenixzz (Weng xiao yi) - [email protected]

voronoimapgen's People

Contributors

phoenixzz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.