Welcome to Spline Tools, an extension for MapMagic, a node based procedural and infinite game map generator.
To use this addon a full version of MapMagic is required.
While MapMagic itself can generate infinite maps, this addon can only be used if a finite map is required.
It allows to limit the map size by creating an island/continent or generating mountains at the borders that cannot be passed.
Limiting the world to a defined size allows to generate stuff that crosses multiple chunks and requires knowledge of the neighbors.
It is assumed that a basic setup of MapMagic is already up and running.
First the main script Map Magic - Spline Tools must be added to your scene. You can add it to the same gameobject that already holds MapMagic, but you are free to add it to any other gameobject.
The Main Script
The script in the inspector looks like this:
Log Level - Useful for debugging purposes
Cache Size - Number of chunk's height maps that fit into cache
Spill to Disk - If too many chunks are cached they are persisted to disk. If disabled, the chunks need to be computed again when needed.
Cache (Sub)Directory - Where to persist the spilled chunks
Clear, Rebuild - Reset and/or rebuild the state of the Cache and Worldgraph
Please note that MapMagic's Generate Changed and Force Generate All will NOT reset the Worldgraph or the Cache. Every time you make changes to generators that affect the creation of nodes or edges, you must use the Clear & Rebuild buttons of this script. Some generators may also cache the height input, so you have to at least clear the height cache in order to see the effect of changes.
From code you can call this to clear and rebuild the graph and chunks:
The Bounds Node defines an area of 1x1 MapMagic Chunks in which the POI can be placed. All chunks within this area will be partly precomputed once before the first chunk is actually created.
The Bounded Scatter Node will try to place at most 10 POI randomly within the bounded area. The placement of each node will be tried 10 times until a valid position is found. This position is constrained by the distance between POI. This distance must be at least 250, all POI that would be placed with a shorter distance will be discarded.
The Connections Node connects each POI with the nearest other POI. The Max Slope parameter limits the possible height changes for each new Edge. The new connection will have a Width of 10, which will be relevant for the next Node.
The Path Node creates a Mask along the Egdes. The width of the edge will be taken as basis and a border could be added. On the endpoints (the POI) the path will fade out.
The resulting graph looks like this:
This graph is also included in the QuickStart scene.
This is the central element of Spline Tools. All required information to provide the splines is stored in a WorldGraph which contains nodes and edges.
It is possible to have multiple graphs, which will act independently.
A node is a single POI. This may be one of the following:
The actual type will be defined by the user.
Normal intermediate node between two edges.
Special node that is located on the chunk borders.
Special node that is located at the perimeter of an endpoint, which is defined by the endpoint's radius.
Section node with more than 2 adjacent edges.
Special node that is located at the perimeter of a crossing, which is defined by the main connection's width.
An edge is the direct connection between two nodes. It also has Bezier data connected to it, wich is stored in a public field.
FAQ / Common Issues
Flying / displaced edges
There are multiple possibilities:
Stale graph: Make sure your graph is not stale by using the Clear & Rebuild button.
Usage of HeightsCache with unspupported input: Since most of MapMagic's generators need special handling to be scaled down in some way, the usage of unhandled generators will lead to wrong results. Use the Preview output to check if the normal and the low-resolution terrain match.
Usage of HeightsCache with very low resolution: With too low resolution the details will get lost.
Using the wrong height input for ConnectionsGenerator: Different connection steps may require different height input to e.g. consider already flattened areas.
All egdes can be accessed via the Worldgraph at runtime. These (or their Bezier data) could be used to place waypoints.
Another possibility could be to create a custom generator that extends EdgeWalkingGenerator to place waypoints.
Usage of splines with biomes is currently untested/unsupported, but will be supported in the future.