Class DiagonalWorldMap
java.lang.Object
com.github.yellowstonegames.world.WorldMapGenerator
com.github.yellowstonegames.world.DiagonalWorldMap
A concrete implementation of
WorldMapGenerator that is like StretchWorldMap but rotates the world so
the South Pole is in the lower-left corner (0,0), the North Pole is in the upper right corner (near (width,height)),
and wrapping transposes rather than wraps.-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal floatfinal floatfinal com.github.yellowstonegames.grid.NoiseWrapperprotected static final floatfinal 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
ConstructorsConstructorDescriptionAlways makes a 256x256 map.DiagonalWorldMap(int mapSize) DiagonalWorldMap(int mapSize, String serialized) 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).DiagonalWorldMap(long initialSeed, int mapSize) DiagonalWorldMap(long initialSeed, int mapSize, float octaveMultiplier) DiagonalWorldMap(long initialSeed, int mapSize, com.github.yellowstonegames.grid.INoise noiseGenerator) DiagonalWorldMap(long initialSeed, int mapSize, com.github.yellowstonegames.grid.INoise noiseGenerator, float octaveMultiplier) DiagonalWorldMap(DiagonalWorldMap other) Copies the DiagonalWorldMapotherto construct a new one that is exactly the same. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()com.github.yellowstonegames.grid.Coordproject(float latitude, float 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.static DiagonalWorldMaprecreateFromString(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 withDiagonalWorldMap(int, String)or (preferably)recreateFromString(String).toString()intwrapX(int x, int y) intwrapY(int x, int y) voidzoomIn(int zoomAmount, int zoomCenterX, int zoomCenterY) Floats the resolution of the map and halves the area it covers repeatedly, doublingzoomAmounttimes; the 2D arrays this uses keep their sizes.voidzoomOut(int zoomAmount, int zoomCenterX, int zoomCenterY) Halves the resolution of the map and floats the area it covers repeatedly, halvingzoomAmounttimes; the 2D arrays this uses keep their sizes.Methods inherited from class WorldMapGenerator
codeHeight, generate, generate, generate, getCenterLongitude, removeExcess, setCenterLongitude, zoomIn, 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 -
alpha
public final float alpha- See Also:
-
kappa
public final float kappa- See Also:
-
epsilon
public final float epsilon
-
-
Constructor Details
-
DiagonalWorldMap
public DiagonalWorldMap()Always makes a 256x256 map. Uses Noise as its noise generator, with 1f as the octave multiplier affecting detail. If you were usingDiagonalWorldMap(long, int, INoise, float), then this would be the same as passing the parameters0x1337BABE1337D00DL, 256, 256, new Noise(DEFAULT_NOISE), 1f. -
DiagonalWorldMap
public DiagonalWorldMap(int mapSize) - Parameters:
mapSize- the width and height of the map(s) to generate; cannot be changed later
-
DiagonalWorldMap
public DiagonalWorldMap(long initialSeed, int mapSize) - Parameters:
initialSeed- the seed for the FlowRandom this uses; this may also be set per-call to generatemapSize- the width and height of the map(s) to generate; cannot be changed later
-
DiagonalWorldMap
public DiagonalWorldMap(long initialSeed, int mapSize, float octaveMultiplier) - Parameters:
initialSeed- the seed for the FlowRandom this uses; this may also be set per-call to generatemapSize- the width and 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
-
DiagonalWorldMap
public DiagonalWorldMap(long initialSeed, int mapSize, com.github.yellowstonegames.grid.INoise noiseGenerator) - Parameters:
initialSeed- the seed for the FlowRandom this uses; this may also be set per-call to generatemapSize- the width and height of the map(s) to generate; cannot be changed laternoiseGenerator- an instance of a noise generator capable of 3D noise, usuallyNoise
-
DiagonalWorldMap
public DiagonalWorldMap(long initialSeed, int mapSize, com.github.yellowstonegames.grid.INoise noiseGenerator, float octaveMultiplier) - Parameters:
initialSeed- the seed for the FlowRandom this uses; this may also be set per-call to generatemapSize- the width and height of the map(s) to generate; cannot be changed laternoiseGenerator- an instance of a noise generator capable of 3D noise, usuallyNoise.instanceoctaveMultiplier- used to adjust the level of detail, with 0.5f at the bare-minimum detail and 1f normal
-
DiagonalWorldMap
Copies the DiagonalWorldMapotherto construct a new one that is exactly the same. References will only be shared to Noise classes.- Parameters:
other- a DiagonalWorldMap to copy
-
DiagonalWorldMap
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:
mapSize- width and height of the map or maps to generate; must match the first 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 withDiagonalWorldMap(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 constructorDiagonalWorldMap(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
-
zoomIn
public void zoomIn(int zoomAmount, int zoomCenterX, int zoomCenterY) Description copied from class:WorldMapGeneratorFloats the resolution of the map and halves the area it covers repeatedly, doublingzoomAmounttimes; 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).
Although there is no technical restriction on maximum zoom, zooming in more than 5 times (64x scale or greater) will make the map appear somewhat less realistic due to rounded shapes appearing more bubble-like and less like a normal landscape.- Overrides:
zoomInin classWorldMapGenerator- Parameters:
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 edge
-
zoomOut
public void zoomOut(int zoomAmount, int zoomCenterX, int zoomCenterY) Description copied from class:WorldMapGeneratorHalves the resolution of the map and floats the area it covers repeatedly, halvingzoomAmounttimes; 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).
Only has an effect if you have previously zoomed in usingWorldMapGenerator.zoomIn(int, int, int)or its overload.- Overrides:
zoomOutin classWorldMapGenerator- Parameters:
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 edge
-
project
public com.github.yellowstonegames.grid.Coord project(float latitude, float 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. 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 usingwrapX(int, int)andwrapY(int, int).- Overrides:
projectin classWorldMapGenerator- Parameters:
latitude- the latitude, from-TrigTools.HALF_PItoTrigTools.HALF_PIlongitude- the longitude, from0ftoTrigTools.PI2- Returns:
- the point at the given latitude and longitude, as a Coord with x between 0 and
WorldMapGenerator.widthand y between 0 andWorldMapGenerator.height, or null if unsupported
-
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
-