Class LocalMap
java.lang.Object
com.github.yellowstonegames.world.WorldMapGenerator
com.github.yellowstonegames.world.LocalMap
- Direct Known Subclasses:
MimicLocalMap
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. This also does not change heat levels at the
far north and south regions of the map, since it is meant for areas that are all about the same heat level.
Example map, showing lack of polar ice-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal com.github.yellowstonegames.grid.NoiseWrapperprotected static final floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatfinal com.github.yellowstonegames.grid.NoiseWrapperprotected static final floatprotected static final floatfinal com.github.yellowstonegames.grid.NoiseWrapperfinal com.github.yellowstonegames.grid.NoiseWrapperprotected static final floatprotected static final floatfinal com.github.yellowstonegames.grid.NoiseWrapperfinal float[][]final float[][]final float[][]Fields inherited from class WorldMapGenerator
cacheA, cacheB, centerLongitude, coastalWaterLower, coastalWaterUpper, deepWaterLower, deepWaterUpper, DEFAULT_NOISE, forestLower, forestUpper, grassLower, grassUpper, heatData, heatModifier, height, heightCodeData, heightData, landData, landModifier, maxHeat, maxHeight, maxWet, mediumWaterLower, mediumWaterUpper, minHeat, minHeight, 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
ConstructorsConstructorDescriptionLocalMap()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.LocalMap(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.Creates a new generator from the given serialized String, produced bystringSerialize(), but this also requires width and height that match the first two lines of the given String (inBase.BASE86).LocalMap(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.LocalMap(long initialSeed, int mapWidth, int mapHeight, float 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.LocalMap(long initialSeed, int mapWidth, int mapHeight, com.github.yellowstonegames.grid.INoise 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.LocalMap(long initialSeed, int mapWidth, int mapHeight, com.github.yellowstonegames.grid.INoise noiseGenerator, float 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.Copies the LocalMapotherto construct a new one that is exactly the same. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()static LocalMaprecreateFromString(String data) Creates a new instance of this class from a serialized String produced bystringSerialize().protected voidregenerate(int startX, int startY, int usedWidth, int usedHeight, float landMod, float heatMod, long stateA, long stateB) Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type withLocalMap(int, int, String)or (preferably)recreateFromString(String).toString()intwrapX(int x, int y) intwrapY(int x, int y) Methods inherited from class WorldMapGenerator
codeHeight, generate, generate, generate, getCenterLongitude, project, removeExcess, setCenterLongitude, zoomIn, zoomIn, zoomOut, zoomOut
-
Field Details
-
terrainFreq
protected static final float terrainFreq- See Also:
-
terrainLayeredFreq
protected static final float terrainLayeredFreq- See Also:
-
heatFreq
protected static final float heatFreq- See Also:
-
moistureFreq
protected static final float moistureFreq- See Also:
-
otherFreq
protected static final float otherFreq- See Also:
-
minHeat0
protected float minHeat0 -
maxHeat0
protected float maxHeat0 -
minHeat1
protected float minHeat1 -
maxHeat1
protected float maxHeat1 -
minWet0
protected float minWet0 -
maxWet0
protected float maxWet0 -
terrainRidged
public final com.github.yellowstonegames.grid.NoiseWrapper terrainRidged -
heat
public final com.github.yellowstonegames.grid.NoiseWrapper heat -
moisture
public final com.github.yellowstonegames.grid.NoiseWrapper moisture -
otherRidged
public final com.github.yellowstonegames.grid.NoiseWrapper otherRidged -
terrainBasic
public final com.github.yellowstonegames.grid.NoiseWrapper terrainBasic -
xPositions
public final float[][] xPositions -
yPositions
public final float[][] yPositions -
zPositions
public final float[][] zPositions
-
-
Constructor Details
-
LocalMap
public LocalMap()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 Noise as its noise generator, with 1f as the octave multiplier affecting detail. If you were usingLocalMap(long, int, int, INoise, float), then this would be the same as passing the parameters0x1337BABE1337D00DL, 256, 128, new Noise(DEFAULT_NOISE), 1f. -
LocalMap
public LocalMap(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. 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, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Uses Noise as its noise generator, with 1f 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
-
LocalMap
public LocalMap(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. Takes an initial seed and the width/height of the map. TheinitialSeedparameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Uses Noise as its noise generator, with 1f as the octave multiplier affecting detail.- Parameters:
initialSeed- the seed for the FlowRandom 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
-
LocalMap
public LocalMap(long initialSeed, int mapWidth, int mapHeight, float 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 and the width/height of the map. TheinitialSeedparameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Uses Noise as its noise generator, with the given octave multiplier affecting detail.- Parameters:
initialSeed- the seed for the FlowRandom 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.5f at the bare-minimum detail and 1f normal
-
LocalMap
public LocalMap(long initialSeed, int mapWidth, int mapHeight, com.github.yellowstonegames.grid.INoise 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. Takes an initial seed and the width/height of the map. TheinitialSeedparameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long, 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 1f as the octave multiplier affecting detail.- Parameters:
initialSeed- the seed for the FlowRandom 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, usuallyNoise
-
LocalMap
public LocalMap(long initialSeed, int mapWidth, int mapHeight, com.github.yellowstonegames.grid.INoise noiseGenerator, float 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 (aNoiseimplementation, which is usuallyNoise.instance, and a multiplier on how many octaves of noise to use, with 1f being normal (high) detail and higher multipliers producing even more detailed noise when zoomed-in). TheinitialSeedparameter may or may not be used, since you can specify the seed to use when you callWorldMapGenerator.generate(long, long). The width and height of the map cannot be changed after the fact, but you can zoom in. Noise 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 staticNoise.instancebecause it has no changing state between runs of the program). TheoctaveMultiplierparameter should probably be no lower than 0.5f, but can be arbitrarily high if you're willing to spend much more time on generating detail only noticeable at very high zoom; normally 1f is fine and may even be too high for maps that don't require zooming.- Parameters:
initialSeed- the seed for the FlowRandom 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, oftenNoise.instanceoctaveMultiplier- used to adjust the level of detail, with 0.5f at the bare-minimum detail and 1f normal
-
LocalMap
Copies the LocalMapotherto construct a new one that is exactly the same. References will only be shared to Noise classes.- Parameters:
other- a LocalMap to copy
-
LocalMap
Creates a new generator from the given serialized String, produced bystringSerialize(), but this also requires width and height that match the first two lines of the given String (inBase.BASE86). It is almost always easier to userecreateFromString(String)instead.- Parameters:
width- width of the map or maps to generate; must match the first line of the given String inBase.BASE86height- height of the map or maps to generate; must match the second line of the given String inBase.BASE86serialized- should have been produced bystringSerialize()
-
-
Method Details
-
stringSerialize
Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type withLocalMap(int, int, String)or (preferably)recreateFromString(String). UsesBase.BASE86to represent values very concisely, but not at all readably. The String this produces tends to be very long because it includes several 2D arrays and a Region as Strings.- Overrides:
stringSerializein classWorldMapGenerator- Returns:
- a String that stores the entire state of this generator
-
recreateFromString
Creates a new instance of this class from a serialized String produced bystringSerialize(). This can get the width and height from the String, which makes this probably preferable to using the constructorLocalMap(int, int, String). This stores the last-generated map in this WorldMapGenerator, where it can be used by other code like aWorldMapView.- Parameters:
data- the output ofstringSerialize()- Returns:
- the map that was serialized, as a new generator
-
wrapX
public int wrapX(int x, int y) - Overrides:
wrapXin classWorldMapGenerator
-
wrapY
public int wrapY(int x, int y) - Overrides:
wrapYin classWorldMapGenerator
-
regenerate
protected void regenerate(int startX, int startY, int usedWidth, int usedHeight, float landMod, float heatMod, long stateA, long stateB) - Specified by:
regeneratein classWorldMapGenerator
-
equals
-
hashCode
-
toString
-