Class BiomeMapper.BlendedBiomeMapper
java.lang.Object
com.github.yellowstonegames.world.BiomeMapper.BlendedBiomeMapper
- All Implemented Interfaces:
BiomeMapper
- Enclosing interface:
BiomeMapper
A very-smoothly-blending BiomeMapper. Unlike the more-complicated usage of
This is often used via
BiomeMapper.DetailedBiomeMapper, this does
not have fine-grained access to which two biomes are mixed at any given point. The reason for this is partly that
more than two biomes can affect any given point, and partly that just accessing a mixed color may be much easier.
After you call makeBiomes(WorldMapGenerator), the colorDataOklab and colorDataRgba
fields will be usable, and will match points on the WorldMapGenerator's latest map with colors appropriate for a
biome at that point. Calling makeBiomes() also assigns to biomeCodeData, though this only stores small
int values here (between 0 and 65, inclusive) that correspond to indices into Biome.TABLE.
This is often used via
BlendedWorldMapView.-
Nested Class Summary
Nested classes/interfaces inherited from interface BiomeMapper
BiomeMapper.BlendedBiomeMapper, BiomeMapper.DetailedBiomeMapper, BiomeMapper.SimpleBiomeMapper, BiomeMapper.UnrealisticBiomeMapper -
Field Summary
FieldsModifier and TypeFieldDescriptionint[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static final floatstatic final floatstatic final floatint[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.int[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.final int[]The colors for each biome, with each as a packed oklab int.floatstatic final floatstatic final floatstatic final floatstatic final float[]static final float[]int[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static final float[]static final float[]int[][]The heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest.static final floatstatic final floatstatic final floatstatic final floatstatic final floatstatic final float -
Constructor Summary
ConstructorsConstructorDescriptionSimple constructor; pretty much does nothing.BlendedBiomeMapper(String serialized) Creates a new generator from the given serialized String, produced bystringSerialize(). -
Method Summary
Modifier and TypeMethodDescriptionvoidalter(com.github.tommyettinger.random.EnhancedRandom rng) Uses the current colors incolorTableto partly-randomize themselves, and also incorporates three random floats from the givenrng.booleanintgetBiomeCode(int x, int y) Gets the biome code for the dominant biome at a given x,y position.int[][]com.github.yellowstonegames.place.Biome[]Gets a String array where biome codes can be used as indices to look up a name for the biome they refer to.intgetHeatCode(int x, int y) Gets a heat code for a given x,y point on a map, usually as an int between 0 and 5 inclusive.int[][]intgetMoistureCode(int x, int y) Gets a moisture code for a given x,y point on a map, usually as an int between 0 and 5 inclusive.int[][]inthashCode()voidvoidinitialize(float hue, float saturation, float brightness, float contrast) Initializes the color tables this uses for all biomes, but allows rotating all hues and adjusting brightness/saturation/contrast to produce maps of non-Earth-like planets.voidinitialize(com.github.yellowstonegames.place.Biome[] alternateBiomeTable) voidmakeBiomes(WorldMapGenerator world) Analyzes the last world produced by the given WorldMapGenerator and uses all of its generated information to assign biome codes for each cell (along with heat and moisture codes).voidmatch(long seed, int... similarColors) Initializes the colors to use in some combination for all biomes, without regard for what the biome really is.recreateFromString(String data) Creates a new instance of this class from a serialized String produced bystringSerialize().voidsetColorTable(int[] oklabColors) Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type withBlendedBiomeMapper(String)orrecreateFromString(String).toString()
-
Field Details
-
heatCodeData
public int[][] heatCodeDataThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
moistureCodeData
public int[][] moistureCodeDataThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
biomeCodeData
public int[][] biomeCodeDataThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
colorDataOklab
public int[][] colorDataOklabThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
colorDataRgba
public int[][] colorDataRgbaThe heat codes for the analyzed map, from 0 to 5 inclusive, with 0 coldest and 5 hottest. -
colorTable
public final int[] colorTableThe colors for each biome, with each as a packed oklab int. Always has 66 items, corresponding to the biomes inBiome.TABLEin order. -
contrast
public float contrast -
coldestValueUpper
public static final float coldestValueUpper- See Also:
-
colderValueUpper
public static final float colderValueUpper- See Also:
-
coldValueUpper
public static final float coldValueUpper- See Also:
-
warmValueUpper
public static final float warmValueUpper- See Also:
-
warmerValueUpper
public static final float warmerValueUpper- See Also:
-
warmestValueUpper
public static final float warmestValueUpper- See Also:
-
driestValueUpper
public static final float driestValueUpper- See Also:
-
drierValueUpper
public static final float drierValueUpper- See Also:
-
dryValueUpper
public static final float dryValueUpper- See Also:
-
wetValueUpper
public static final float wetValueUpper- See Also:
-
wetterValueUpper
public static final float wetterValueUpper- See Also:
-
wettestValueUpper
public static final float wettestValueUpper- See Also:
-
HEAT_UPPER
public static final float[] HEAT_UPPER -
MOISTURE_UPPER
public static final float[] MOISTURE_UPPER -
HEAT_MID
public static final float[] HEAT_MID -
MOISTURE_MID
public static final float[] MOISTURE_MID
-
-
Constructor Details
-
BlendedBiomeMapper
public BlendedBiomeMapper()Simple constructor; pretty much does nothing. Make sure to callmakeBiomes(WorldMapGenerator)before using fields likebiomeCodeData. -
BlendedBiomeMapper
Creates a new generator from the given serialized String, produced bystringSerialize().- Parameters:
serialized- should have been produced bystringSerialize()
-
-
Method Details
-
getHeatCodeData
public int[][] getHeatCodeData()- Specified by:
getHeatCodeDatain interfaceBiomeMapper
-
getMoistureCodeData
public int[][] getMoistureCodeData()- Specified by:
getMoistureCodeDatain interfaceBiomeMapper
-
getBiomeCodeData
public int[][] getBiomeCodeData()- Specified by:
getBiomeCodeDatain interfaceBiomeMapper
-
stringSerialize
Serializes this generator's entire state to a String; it can be read back when creating a new instance of this type withBlendedBiomeMapper(String)orrecreateFromString(String). UsesBase.BASE86to represent values very concisely, but not at all readably. The String this produces tends to be very long because it includes some 2D arrays as Strings.- Specified by:
stringSerializein interfaceBiomeMapper- 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 is here for compatibility with other classes that use String serialization, but you can just useBlendedBiomeMapper(String)instead.- Parameters:
data- the output ofstringSerialize()- Returns:
- the map that was serialized, as a new generator
-
setColorTable
public void setColorTable(int[] oklabColors) -
initialize
public void initialize() -
initialize
public void initialize(com.github.yellowstonegames.place.Biome[] alternateBiomeTable) -
initialize
public void initialize(float hue, float saturation, float brightness, float contrast) Initializes the color tables this uses for all biomes, but allows rotating all hues and adjusting brightness/saturation/contrast to produce maps of non-Earth-like planets.- Parameters:
hue- hue rotation; 0.0 and 1.0 are no rotation, and 0.5 is maximum rotationsaturation- added to the saturation of a biome color; usually close to 0.0, always between -1 and 1brightness- added to the lightness of a biome color; often close to 0.0, always between -1 and 1contrast- multiplied with the soft shading that applies to all land biomes
-
alter
public void alter(com.github.tommyettinger.random.EnhancedRandom rng) Uses the current colors incolorTableto partly-randomize themselves, and also incorporates three random floats from the givenrng. This should map similar colors in the input color table, like varieties of dark green forest, into similar output colors. It will not change color 60 (empty space), but will change everything else. Typically, colors like white ice will still map to white, and different shades of ocean blue will become different shades of some color (which could still be some sort of blue). This can be a useful alternative toinitialize(float, float, float, float), because that method hue-rotates all colors by the same amount, while this method adjusts each input hue differently and based on their original value. You may want to callinitialize()(either with no arguments or with four) before each call to this, because changes this makes to the color table would be read back the second time this is called without reinitialization.- Parameters:
rng- any non-null EnhancedRandom
-
match
public void match(long seed, int... similarColors) Initializes the colors to use in some combination for all biomes, without regard for what the biome really is. There should be at least one packed int Oklab color given in similarColors, but there can be many of them. This type of color can be any of the color constants fromDescriptiveColor, may be produced byDescriptiveColor.describeOklab(String), or might be made manually, in advanced cases, withDescriptiveColor.limitToGamut(int, int, int)and specifying the L, A, and B channels.- Parameters:
similarColors- an array or vararg of packed int Oklab colors with at least one element
-
getBiomeCode
public int getBiomeCode(int x, int y) Gets the biome code for the dominant biome at a given x,y position.- Specified by:
getBiomeCodein interfaceBiomeMapper- Parameters:
x- the x-coordinate on the mapy- the y-coordinate on the map- Returns:
- the biome code for the dominant biome part at the given location
-
getHeatCode
public int getHeatCode(int x, int y) Description copied from interface:BiomeMapperGets a heat code for a given x,y point on a map, usually as an int between 0 and 5 inclusive. Some implementations may use more or less detail for heat codes, but 0 is always the coldest code used, and the highest value this can return for a given implementation refers to the hottest code used.- Specified by:
getHeatCodein interfaceBiomeMapper- Parameters:
x- the x-coordinate on the mapy- the y-coordinate on the map- Returns:
- an int that can be used to categorize how hot an area is, with 0 as coldest
-
getMoistureCode
public int getMoistureCode(int x, int y) Description copied from interface:BiomeMapperGets a moisture code for a given x,y point on a map, usually as an int between 0 and 5 inclusive. Some implementations may use more or less detail for moisture codes, but 0 is always the driest code used, and the highest value this can return for a given implementation refers to the wettest code used. Some implementations may allow seasonal change in moisture, e.g. monsoon seasons, to be modeled differently from average precipitation in an area, but the default assumption is that this describes the average amount of moisture (rain, humidity, and possibly snow/hail or other precipitation) that an area receives annually.- Specified by:
getMoistureCodein interfaceBiomeMapper- Parameters:
x- the x-coordinate on the mapy- the y-coordinate on the map- Returns:
- an int that can be used to categorize how much moisture an area tends to receive, with 0 as driest
-
getBiomeTable
public com.github.yellowstonegames.place.Biome[] getBiomeTable()Gets a String array where biome codes can be used as indices to look up a name for the biome they refer to. This table uses 6 levels of heat and 6 levels of moisture, and tracks rivers, coastlines, lakes, and oceans as potentially different types of terrain. Biome codes can be obtained withgetBiomeCode(int, int). This method returns a direct reference toBiome.TABLE, so modifying the returned array is discouraged (you should implementBiomeMapperusing this class as a basis if you want to change its size).
Like withBiomeMapper.SimpleBiomeMapper, you can use a biome code directly from biomeCodeData as an index into this.- Specified by:
getBiomeTablein interfaceBiomeMapper- Returns:
- a direct reference to
Biome.TABLE, a Biome array with 66 items
-
makeBiomes
Analyzes the last world produced by the given WorldMapGenerator and uses all of its generated information to assign biome codes for each cell (along with heat and moisture codes). After calling this, biome codes can be taken frombiomeCodeDataand (packed Oklab int) colors fromcolorDataOklab.- Specified by:
makeBiomesin interfaceBiomeMapper- Parameters:
world- a WorldMapGenerator that should have generated at least one map; it may be at any zoom
-
equals
- Specified by:
equalsin interfaceBiomeMapper- Overrides:
equalsin classObject
-
toString
-
hashCode
-