Class DetailedWorldMapView

java.lang.Object
com.github.yellowstonegames.world.DetailedWorldMapView
All Implemented Interfaces:
WorldMapView

public class DetailedWorldMapView extends Object implements WorldMapView
Takes a WorldMapGenerator, such as a LocalMap, RotatingGlobeMap, or StretchWorldMap, and wraps it so that you can call generate() on this to coordinate calls to WorldMapGenerator.generate() and BiomeMapper.DetailedBiomeMapper.makeBiomes(WorldMapGenerator). For extra convenience, you can get a possible interpretation of how the generated world would look by calling show(), which returns a 2D array of ints as RGBA8888 colors.
  • Field Details

    • width

      protected int width
    • height

      protected int height
    • colorMap

      protected int[][] colorMap
    • colorMapOklab

      protected int[][] colorMapOklab
    • world

      protected WorldMapGenerator world
    • biomeMapper

      protected BiomeMapper.DetailedBiomeMapper biomeMapper
    • biomeColorTable

      public final int[] biomeColorTable
    • biomeDarkColorTable

      public final int[] biomeDarkColorTable
  • Constructor Details

    • DetailedWorldMapView

      public DetailedWorldMapView()
    • DetailedWorldMapView

      public DetailedWorldMapView(WorldMapGenerator worldMapGenerator)
    • DetailedWorldMapView

      public DetailedWorldMapView(long seed, int width, int height)
  • Method Details

    • getWidth

      public int getWidth()
      Specified by:
      getWidth in interface WorldMapView
    • getHeight

      public int getHeight()
      Specified by:
      getHeight in interface WorldMapView
    • getColorMap

      public int[][] getColorMap()
      Specified by:
      getColorMap in interface WorldMapView
    • setColorMap

      public void setColorMap(int[][] colorMap)
    • getColorMapOklab

      public int[][] getColorMapOklab()
      Specified by:
      getColorMapOklab in interface WorldMapView
    • setColorMapOklab

      public void setColorMapOklab(int[][] colorMapOklab)
    • getBiomeMapper

      public BiomeMapper.DetailedBiomeMapper getBiomeMapper()
      Specified by:
      getBiomeMapper in interface WorldMapView
    • setBiomeMapper

      public void setBiomeMapper(BiomeMapper biomeMapper)
      Specified by:
      setBiomeMapper in interface WorldMapView
    • getWorld

      public WorldMapGenerator getWorld()
      Specified by:
      getWorld in interface WorldMapView
    • setWorld

      public void setWorld(WorldMapGenerator world)
      Specified by:
      setWorld in interface WorldMapView
    • initialize

      public void initialize()
      Specified by:
      initialize in interface WorldMapView
    • 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.
      Specified by:
      initialize in interface WorldMapView
      Parameters:
      hue - hue rotation; 0.0 and 1.0 are no rotation, and 0.5 is maximum rotation
      saturation - added to the saturation of a biome color; usually close to 0.0, always between -1 and 1
      brightness - added to the lightness of a biome color; often close to 0.0, always between -1 and 1
      contrast - multiplies the darkening factor for the dark sections of biomes; typically very close to 1
    • alter

      public void alter()
      Uses the current colors in biomeColorTable to partly-randomize themselves, and also incorporates three random floats from the FlowRandom stored in getWorld(). 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 to initialize(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 call initialize() (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.
      Specified by:
      alter in interface WorldMapView
    • match

      public void match(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 from DescriptiveColor, may be produced by DescriptiveColor.describeOklab(String), or might be made manually, in advanced cases, with DescriptiveColor.limitToGamut(int, int, int) and specifying the L, A, and B channels.
      Specified by:
      match in interface WorldMapView
      Parameters:
      similarColors - an array or vararg of packed int Oklab colors with at least one element
    • 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 from DescriptiveColor, may be produced by DescriptiveColor.describeOklab(String), or might be made manually, in advanced cases, with DescriptiveColor.limitToGamut(int, int, int) and specifying the L, A, and B channels.
      Specified by:
      match in interface WorldMapView
      Parameters:
      seed - any long; used to determine how colors are matched to biomes
      similarColors - an array or vararg of packed int Oklab colors with at least one element
    • generate

      public void generate()
      Specified by:
      generate in interface WorldMapView
    • generate

      public void generate(float landMod, float heatMod)
      Specified by:
      generate in interface WorldMapView
    • generate

      public void generate(long seedA, long seedB, float landMod, float heatMod)
      Specified by:
      generate in interface WorldMapView
    • show

      public int[][] show()
      After calling generate(), you can call this to assign values to getColorMap() and getColorMapOklab(). This method returns the RGBA colorMap, but it assigns to colorMapOklab at the same time, so you can use the Oklab colors with methods like DescriptiveColor.lighten(int, float) and DescriptiveColor.lerpColors(int, int, float).
      Specified by:
      show in interface WorldMapView
      Returns:
      the RGBA8888 colorMap
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object