public abstract class WorldMapGenerator
extends java.lang.Object
implements java.io.Serializable
WorldMapGenerator.SphereMap
are valid for spherical world projections,
while the maps from WorldMapGenerator.TilingMap
are for toroidal world projections and will wrap from edge to opposite edge
seamlessly thanks to a technique from the
Accidental Noise Library that involves getting a 2D slice of 4D Simplex noise. Because of how Simplex noise
works, this also allows extremely high zoom levels for all types of map as long as certain parameters are within
reason. Other world maps produce more conventional shapes, like WorldMapGenerator.SpaceViewMap
and WorldMapGenerator.RotatingSpaceMap
make a view of a marble-like world from space, and others make more unconventional shapes, like WorldMapGenerator.EllipticalMap
or WorldMapGenerator.EllipticalHammerMap
, which form a 2:1 ellipse shape that accurately keeps sizes but not relative shapes,
WorldMapGenerator.HexagonalMap
, which forms a pill-shape, and WorldMapGenerator.HyperellipticalMap
, which takes parameters so it can fit
any shape between a circle or ellipse and a rectangle (the default is a slightly squared-off ellipse). You can access
the height map with the heightData
field, the heat map with the heatData
field, the moisture map
with the moistureData
field, and a special map that stores ints representing the codes for various ranges of
elevation (0 to 8 inclusive, with 0 the deepest ocean and 8 the highest mountains) with heightCodeData
. The
last map should be noted as being the simplest way to find what is land and what is water; any height code 4 or
greater is land, and any height code 3 or less is water.
WorldMapGenerator.SimpleBiomeMapper
,
which stores one biome per cell, and WorldMapGenerator.DetailedBiomeMapper
, which gives each cell a midway value between two
biomes.Modifier and Type | Class and Description |
---|---|
static interface |
WorldMapGenerator.BiomeMapper |
static class |
WorldMapGenerator.DetailedBiomeMapper
A way to get biome information for the cells on a map when you want an area's biome to be a combination of two
main biome types, such as "Grassland" or "TropicalRainforest", with the biomes varying in weight between areas.
|
static class |
WorldMapGenerator.EllipticalHammerMap
A concrete implementation of
WorldMapGenerator that projects the world map onto an ellipse that should be
twice as wide as it is tall (although you can stretch it by width and height that don't have that ratio). |
static class |
WorldMapGenerator.EllipticalMap
A concrete implementation of
WorldMapGenerator that projects the world map onto an ellipse that should be
twice as wide as it is tall (although you can stretch it by width and height that don't have that ratio). |
static class |
WorldMapGenerator.HexagonalMap
A modified version of the Eckert II projection, shaped like an elongated hexagon.
|
static class |
WorldMapGenerator.HyperellipticalMap
A concrete implementation of
WorldMapGenerator that projects the world map onto a shape that resembles a
mix part-way between an ellipse and a rectangle. |
static class |
WorldMapGenerator.LocalMap
A concrete implementation of
WorldMapGenerator that does no projection of the map, as if the area were
completely flat or small enough that curvature is impossible to see. |
static class |
WorldMapGenerator.LocalMimicMap
An unusual map generator that imitates an existing local map (such as a map of Australia, which it can do by
default), without applying any projection or changing heat levels in the polar regions or equator.
|
static class |
WorldMapGenerator.MimicMap
An unusual map generator that imitates an existing map (such as a map of Earth, which it can do by default).
|
static class |
WorldMapGenerator.RotatingSpaceMap
A concrete implementation of
WorldMapGenerator that imitates an infinite-distance perspective view of a
world, showing only one hemisphere, that should be as wide as it is tall (its outline is a circle). |
static class |
WorldMapGenerator.RoundSideMap
A concrete implementation of
WorldMapGenerator that projects the world map onto a shape with a flat top
and bottom but near-circular sides. |
static class |
WorldMapGenerator.SimpleBiomeMapper
A way to get biome information for the cells on a map when you only need a single value to describe a biome, such
as "Grassland" or "TropicalRainforest".
|
static class |
WorldMapGenerator.SpaceViewMap
A concrete implementation of
WorldMapGenerator that imitates an infinite-distance perspective view of a
world, showing only one hemisphere, that should be as wide as it is tall (its outline is a circle). |
static class |
WorldMapGenerator.SphereMap
A concrete implementation of
WorldMapGenerator that distorts the map as it nears the poles, expanding the
smaller-diameter latitude lines in extreme north and south regions so they take up the same space as the equator;
this counteracts certain artifacts that are common in Simplex noise world maps by using a 4D noise call to
generate terrain, using a normal 3D noise call's result as the extra 4th dimension. |
static class |
WorldMapGenerator.TilingMap
A concrete implementation of
WorldMapGenerator that tiles both east-to-west and north-to-south. |
Modifier and Type | Field and Description |
---|---|
int |
cacheA |
int |
cacheB |
protected double |
centerLongitude |
static double |
coastalWaterLower |
static double |
coastalWaterUpper |
static double |
deepWaterLower |
static double |
deepWaterUpper |
static FastNoise |
DEFAULT_NOISE
A FastNoise that has a higher frequency than that class defaults to, which is useful for maps here.
|
static double |
forestLower |
static double |
forestUpper |
static double |
grassLower |
static double |
grassUpper |
double[][] |
heatData |
double |
heatModifier |
int |
height |
int[][] |
heightCodeData |
double[][] |
heightData |
GreasedRegion |
landData |
double |
landModifier |
double |
maxHeat |
double |
maxHeight |
double |
maxHeightActual |
double |
maxWet |
static double |
mediumWaterLower |
static double |
mediumWaterUpper |
double |
minHeat |
double |
minHeight |
double |
minHeightActual |
double |
minWet |
double[][] |
moistureData |
GWTRNG |
rng |
static double |
rockLower |
static double |
rockUpper |
static double |
sandLower |
static double |
sandUpper |
int |
seedA |
int |
seedB |
static double |
shallowWaterLower |
static double |
shallowWaterUpper |
static double |
snowLower |
static double |
snowUpper |
protected IntVLA |
startCacheX |
protected IntVLA |
startCacheY |
int |
startX |
int |
startY |
int |
usedHeight |
int |
usedWidth |
int |
width |
int |
zoom |
protected int |
zoomStartX |
protected int |
zoomStartY |
Modifier | Constructor and Description |
---|---|
protected |
WorldMapGenerator()
Constructs a WorldMapGenerator (this class is abstract, so you should typically call this from a subclass or as
part of an anonymous class that implements
regenerate(int, int, int, int, double, double, int, int) ). |
protected |
WorldMapGenerator(int mapWidth,
int mapHeight)
Constructs a WorldMapGenerator (this class is abstract, so you should typically call this from a subclass or as
part of an anonymous class that implements
regenerate(int, int, int, int, double, double, int, int) ). |
protected |
WorldMapGenerator(long initialSeed,
int mapWidth,
int mapHeight)
Constructs a WorldMapGenerator (this class is abstract, so you should typically call this from a subclass or as
part of an anonymous class that implements
regenerate(int, int, int, int, double, double, int, int) ). |
protected |
WorldMapGenerator(WorldMapGenerator other)
Used to implement most of the copy constructor for subclasses; this cannot copy Noise implementations and leaves
that up to the subclass, but will copy all non-static fields defined in WorldMapGenerator from other.
|
Modifier and Type | Method and Description |
---|---|
int |
codeHeight(double high) |
protected int |
decodeX(int coded) |
protected int |
decodeY(int coded) |
void |
generate()
Generates a world using a random RNG state and all parameters randomized.
|
void |
generate(double landMod,
double heatMod,
long state)
Generates a world using the specified RNG state as a long, with specific land and heat modifiers that affect
the land-water ratio and the average temperature, respectively.
|
void |
generate(long state)
Generates a world using the specified RNG state as a long.
|
double |
getCenterLongitude()
Gets the longitude line the map is centered on, which should usually be between 0 and 2 * PI.
|
Coord |
project(double latitude,
double longitude)
Given a latitude and longitude in radians (the conventional way of describing points on a globe), this gets the
(x,y) Coord on the map projection this generator uses that corresponds to the given lat-lon coordinates.
|
protected abstract void |
regenerate(int startX,
int startY,
int usedWidth,
int usedHeight,
double landMod,
double heatMod,
int stateA,
int stateB) |
protected static double |
removeExcess(double radians) |
void |
setCenterLongitude(double centerLongitude)
Sets the center longitude line to a longitude measured in radians, from 0 to 2 * PI.
|
int |
wrapX(int x,
int y) |
int |
wrapY(int x,
int y) |
void |
zoomIn()
Doubles the resolution of the map and halves the area it covers; the 2D arrays this uses keep their sizes.
|
void |
zoomIn(int zoomAmount,
int zoomCenterX,
int zoomCenterY)
Doubles the resolution of the map and halves the area it covers repeatedly, doubling
zoomAmount times;
the 2D arrays this uses keep their sizes. |
void |
zoomOut()
Halves the resolution of the map and doubles the area it covers; the 2D arrays this uses keep their sizes.
|
void |
zoomOut(int zoomAmount,
int zoomCenterX,
int zoomCenterY)
Halves the resolution of the map and doubles the area it covers repeatedly, halving
zoomAmount times; the
2D arrays this uses keep their sizes. |
public final int width
public final int height
public int seedA
public int seedB
public int cacheA
public int cacheB
public GWTRNG rng
public final double[][] heightData
public final double[][] heatData
public final double[][] moistureData
public final GreasedRegion landData
public final int[][] heightCodeData
public double landModifier
public double heatModifier
public double minHeight
public double maxHeight
public double minHeightActual
public double maxHeightActual
public double minHeat
public double maxHeat
public double minWet
public double maxWet
protected double centerLongitude
public int zoom
public int startX
public int startY
public int usedWidth
public int usedHeight
protected IntVLA startCacheX
protected IntVLA startCacheY
protected int zoomStartX
protected int zoomStartY
public static final FastNoise DEFAULT_NOISE
public static final double deepWaterLower
public static final double deepWaterUpper
public static final double mediumWaterLower
public static final double mediumWaterUpper
public static final double shallowWaterLower
public static final double shallowWaterUpper
public static final double coastalWaterLower
public static final double coastalWaterUpper
public static final double sandLower
public static final double sandUpper
public static final double grassLower
public static final double grassUpper
public static final double forestLower
public static final double forestUpper
public static final double rockLower
public static final double rockUpper
public static final double snowLower
public static final double snowUpper
protected WorldMapGenerator(WorldMapGenerator other)
other
- a WorldMapGenerator (subclass) to copy fields fromprotected WorldMapGenerator()
regenerate(int, int, int, int, double, double, int, int)
).
Always makes a 256x256 map. If you were using WorldMapGenerator(long, int, int)
, then
this would be the same as passing the parameters 0x1337BABE1337D00DL, 256, 256
.protected WorldMapGenerator(int mapWidth, int mapHeight)
regenerate(int, int, int, int, double, double, int, int)
).
Takes only the width/height of the map. The initial seed is set to the same large long
every time, and it's likely that you would set the seed when you call generate(long)
. The width and
height of the map cannot be changed after the fact, but you can zoom in.mapWidth
- the width of the map(s) to generate; cannot be changed latermapHeight
- the height of the map(s) to generate; cannot be changed laterprotected WorldMapGenerator(long initialSeed, int mapWidth, int mapHeight)
regenerate(int, int, int, int, double, double, int, int)
).
Takes an initial seed and the width/height of the map. The initialSeed
parameter may or may not be used, since you can specify the seed to use when you call generate(long)
.
The width and height of the map cannot be changed after the fact, but you can zoom in.initialSeed
- the seed for the GWTRNG this uses; this may also be set per-call to generatemapWidth
- the width of the map(s) to generate; cannot be changed latermapHeight
- the height of the map(s) to generate; cannot be changed laterpublic double getCenterLongitude()
public void setCenterLongitude(double centerLongitude)
centerLongitude
- the longitude to center the map projection on, from 0 to 2 * PI (can be any non-negative double).protected static double removeExcess(double radians)
public void generate()
zoomIn(int, int, int)
to double the resolution and center on the specified area, but the width
and height of the 2D arrays this changed, such as heightData
and moistureData
will be the same.public void generate(long state)
zoomIn(int, int, int)
to double the resolution and center on the specified area, but the width
and height of the 2D arrays this changed, such as heightData
and moistureData
will be the same.state
- the state to give this generator's RNG; if the same as the last call, this will reuse datapublic void generate(double landMod, double heatMod, long state)
zoomIn(int, int, int)
to double the resolution and center on the specified area, but the width
and height of the 2D arrays this changed, such as heightData
and moistureData
will be the same.landMod
- 1.0 is Earth-like, less than 1 is more-water, more than 1 is more-land; a random value will be used if this is negativeheatMod
- 1.125 is Earth-like, less than 1 is cooler, more than 1 is hotter; a random value will be used if this is negativestate
- the state to give this generator's RNG; if the same as the last call, this will reuse datapublic void zoomOut()
zoomIn(int, int, int)
or its overload.public void zoomOut(int zoomAmount, int zoomCenterX, int zoomCenterY)
zoomAmount
times; the
2D arrays this uses keep their sizes. This version of zoomOut allows you to specify where the zoom should be
centered, using the current coordinates (if the map size is 256x256, then coordinates should be between 0 and
255, and will refer to the currently used area and not necessarily the full world size).
zoomIn(int, int, int)
or its overload.zoomCenterX
- the center X position to zoom out from; if too close to an edge, this will stop moving before it would extend past an edgezoomCenterY
- the center Y position to zoom out from; if too close to an edge, this will stop moving before it would extend past an edgepublic void zoomIn()
public void zoomIn(int zoomAmount, int zoomCenterX, int zoomCenterY)
zoomAmount
times;
the 2D arrays this uses keep their sizes. This version of zoomIn allows you to specify where the zoom should be
centered, using the current coordinates (if the map size is 256x256, then coordinates should be between 0 and
255, and will refer to the currently used area and not necessarily the full world size).
zoomCenterX
- the center X position to zoom in to; if too close to an edge, this will stop moving before it would extend past an edgezoomCenterY
- the center Y position to zoom in to; if too close to an edge, this will stop moving before it would extend past an edgeprotected abstract void regenerate(int startX, int startY, int usedWidth, int usedHeight, double landMod, double heatMod, int stateA, int stateB)
public Coord project(double latitude, double longitude)
width
, and y between 0 and height
, both exclusive. Automatically wraps the Coord's values using
wrapX(int, int)
and wrapY(int, int)
.public int codeHeight(double high)
protected final int decodeX(int coded)
protected final int decodeY(int coded)
public int wrapX(int x, int y)
public int wrapY(int x, int y)
Copyright © Eben Howard 2012–2022. All rights reserved.