Package squidpony.squidgrid.mapping
Class WorldMapGenerator.SphereMap
java.lang.Object
squidpony.squidgrid.mapping.WorldMapGenerator
squidpony.squidgrid.mapping.WorldMapGenerator.SphereMap
- All Implemented Interfaces:
Serializable
- Enclosing class:
- WorldMapGenerator
public static class WorldMapGenerator.SphereMap extends WorldMapGenerator
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. This generator allows
choosing a Noise.Noise3D
, which is used for most of the generation. This is ideal for projecting onto a 3D
sphere, which could squash the poles to counteract the stretch this does. You might also want to produce an oval
map that more-accurately represents the changes in the diameter of a latitude line on a spherical world; you
should use WorldMapGenerator.EllipticalMap
or WorldMapGenerator.EllipticalHammerMap
for this.
WorldMapGenerator.HyperellipticalMap
is also a nice option because it can project onto a shape between a
rectangle (like this class) and an ellipse (like EllipticalMap), with all-round sides.
Example map.- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class squidpony.squidgrid.mapping.WorldMapGenerator
WorldMapGenerator.BiomeMapper, WorldMapGenerator.DetailedBiomeMapper, WorldMapGenerator.EllipticalHammerMap, WorldMapGenerator.EllipticalMap, WorldMapGenerator.HyperellipticalMap, WorldMapGenerator.LocalMap, WorldMapGenerator.LocalMimicMap, WorldMapGenerator.MimicMap, WorldMapGenerator.RotatingSpaceMap, WorldMapGenerator.RoundSideMap, WorldMapGenerator.SimpleBiomeMapper, WorldMapGenerator.SpaceViewMap, WorldMapGenerator.SphereMap, WorldMapGenerator.TilingMap
-
Field Summary
Fields Modifier and Type Field Description Noise.Noise3D
heat
protected static double
heatFreq
Noise.Noise3D
moisture
protected static double
moistureFreq
protected static double
otherFreq
Noise.Noise3D
otherRidged
Noise.Noise3D
terrain
protected static double
terrainFreq
Noise.Noise3D
terrainLayered
protected static double
terrainRidgedFreq
double[][]
xPositions
double[][]
yPositions
double[][]
zPositions
Fields inherited from class squidpony.squidgrid.mapping.WorldMapGenerator
cacheA, cacheB, centerLongitude, coastalWaterLower, coastalWaterUpper, deepWaterLower, deepWaterUpper, DEFAULT_NOISE, forestLower, forestUpper, grassLower, grassUpper, heatData, heatModifier, height, heightCodeData, heightData, landData, landModifier, maxHeat, maxHeight, maxHeightActual, maxWet, mediumWaterLower, mediumWaterUpper, minHeat, minHeight, minHeightActual, minWet, moistureData, rng, rockLower, rockUpper, sandLower, sandUpper, seedA, seedB, shallowWaterLower, shallowWaterUpper, snowLower, snowUpper, startCacheX, startCacheY, startX, startY, usedHeight, usedWidth, width, zoom, zoomStartX, zoomStartY
-
Constructor Summary
Constructors Constructor Description SphereMap()
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted.SphereMap(int mapWidth, int mapHeight)
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted.SphereMap(long initialSeed, int mapWidth, int mapHeight)
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted.SphereMap(long initialSeed, int mapWidth, int mapHeight, double octaveMultiplier)
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted.SphereMap(long initialSeed, int mapWidth, int mapHeight, Noise.Noise3D noiseGenerator)
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted.SphereMap(long initialSeed, int mapWidth, int mapHeight, Noise.Noise3D noiseGenerator, double octaveMultiplier)
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted.SphereMap(WorldMapGenerator.SphereMap other)
Copies the SphereMapother
to construct a new one that is exactly the same. -
Method Summary
Modifier and Type Method Description 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 void
regenerate(int startX, int startY, int usedWidth, int usedHeight, double landMod, double heatMod, int stateA, int stateB)
int
wrapY(int x, int y)
Methods inherited from class squidpony.squidgrid.mapping.WorldMapGenerator
codeHeight, decodeX, decodeY, generate, generate, generate, getCenterLongitude, removeExcess, setCenterLongitude, wrapX, zoomIn, zoomIn, zoomOut, zoomOut
-
Field Details
-
terrainFreq
- See Also:
- Constant Field Values
-
terrainRidgedFreq
- See Also:
- Constant Field Values
-
heatFreq
- See Also:
- Constant Field Values
-
moistureFreq
- See Also:
- Constant Field Values
-
otherFreq
- See Also:
- Constant Field Values
-
terrain
-
heat
-
moisture
-
otherRidged
-
terrainLayered
-
xPositions
-
yPositions
-
zPositions
-
-
Constructor Details
-
SphereMap
public SphereMap()Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted. Always makes a 256x128 map. Uses FastNoise as its noise generator, with 1.0 as the octave multiplier affecting detail. If you were usingSphereMap(long, int, int, Noise3D, double)
, then this would be the same as passing the parameters0x1337BABE1337D00DL, 256, 128, DEFAULT_NOISE, 1.0
. -
SphereMap
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted. 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 callWorldMapGenerator.generate(long)
. The width and height of the map cannot be changed after the fact, but you can zoom in. Uses FastNoise as its noise generator, with 1.0 as the octave multiplier affecting detail.- Parameters:
mapWidth
- the width of the map(s) to generate; cannot be changed latermapHeight
- the height of the map(s) to generate; cannot be changed later
-
SphereMap
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted. Takes an initial seed and the width/height of the map. TheinitialSeed
parameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long)
. The width and height of the map cannot be changed after the fact, but you can zoom in. Uses FastNoise as its noise generator, with 1.0 as the octave multiplier affecting detail.- Parameters:
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 later
-
SphereMap
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted. Takes an initial seed and the width/height of the map. TheinitialSeed
parameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long)
. The width and height of the map cannot be changed after the fact, but you can zoom in. Uses FastNoise as its noise generator, with the given octave multiplier affecting detail.- Parameters:
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 lateroctaveMultiplier
- used to adjust the level of detail, with 0.5 at the bare-minimum detail and 1.0 normal
-
SphereMap
Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted. Takes an initial seed and the width/height of the map. TheinitialSeed
parameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long)
. The width and height of the map cannot be changed after the fact, but you can zoom in. Uses the given noise generator, with 1.0 as the octave multiplier affecting detail.- Parameters:
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 laternoiseGenerator
- an instance of a noise generator capable of 3D noise, usuallyFastNoise
-
SphereMap
public SphereMap(long initialSeed, int mapWidth, int mapHeight, Noise.Noise3D noiseGenerator, double octaveMultiplier)Constructs a concrete WorldMapGenerator for a map that can be used to wrap a sphere (as with a texture on a 3D model), with seamless east-west wrapping, no north-south wrapping, and distortion that causes the poles to have significantly-exaggerated-in-size features while the equator is not distorted. Takes an initial seed, the width/height of the map, and parameters for noise generation (aNoise.Noise3D
implementation, which is usuallyFastNoise.instance
, and a multiplier on how many octaves of noise to use, with 1.0 being normal (high) detail and higher multipliers producing even more detailed noise when zoomed-in). TheinitialSeed
parameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long)
. The width and height of the map cannot be changed after the fact, but you can zoom in. FastNoise will be the fastest 3D generator to use fornoiseGenerator
, and the seed it's constructed with doesn't matter because this will change the seed several times at different scales of noise (it's fine to use the staticFastNoise.instance
because it has no changing state between runs of the program). TheoctaveMultiplier
parameter should probably be no lower than 0.5, but can be arbitrarily high if you're willing to spend much more time on generating detail only noticeable at very high zoom; normally 1.0 is fine and may even be too high for maps that don't require zooming.- Parameters:
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 laternoiseGenerator
- an instance of a noise generator capable of 3D noise, usuallyFastNoise.instance
octaveMultiplier
- used to adjust the level of detail, with 0.5 at the bare-minimum detail and 1.0 normal
-
SphereMap
Copies the SphereMapother
to construct a new one that is exactly the same. References will only be shared to Noise classes.- Parameters:
other
- a SphereMap to copy
-
-
Method Details
-
wrapY
- Overrides:
wrapY
in classWorldMapGenerator
-
project
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. If this generator does not represent a globe (if it is toroidal, for instance) or if there is no "good way" to calculate the projection for a given lat-lon coordinate, this returns null. This implementation never returns null. If this is a supported operation and the parameters are valid, this returns a Coord with x between 0 andWorldMapGenerator.width
, and y between 0 andWorldMapGenerator.height
, both exclusive. Automatically wraps the Coord's values usingWorldMapGenerator.wrapX(int, int)
andwrapY(int, int)
.- Overrides:
project
in classWorldMapGenerator
- Parameters:
latitude
- the latitude, fromMath.PI * -0.5
toMath.PI * 0.5
longitude
- the longitude, from0.0
toMath.PI * 2.0
- Returns:
- the point at the given latitude and longitude, as a Coord with x between 0 and
WorldMapGenerator.width
and y between 0 andWorldMapGenerator.height
, or null if unsupported
-
regenerate
protected void regenerate(int startX, int startY, int usedWidth, int usedHeight, double landMod, double heatMod, int stateA, int stateB)- Specified by:
regenerate
in classWorldMapGenerator
-