Class RadialNoiseWrapper

java.lang.Object
com.github.yellowstonegames.grid.NoiseWrapper
com.github.yellowstonegames.grid.RadialNoiseWrapper
All Implemented Interfaces:
com.github.yellowstonegames.core.ISerializersNeeded, INoise, Externalizable, Serializable

public class RadialNoiseWrapper extends NoiseWrapper implements com.github.yellowstonegames.core.ISerializersNeeded
A NoiseWrapper that makes its output radially symmetric around a given center point. The center point is typically given in the constructor, and can be set later with setCenter(float, float). There are 5 divisions by default, but this can be changed to any positive int with setDivisions(int). If the number of divisions is even, you can make every other division a mirror image with setMirror(boolean).
See Also:
  • Field Details

    • centerX

      public float centerX
      The center of the noise regarding radial symmetry; the x-coordinate.
    • centerY

      public float centerY
      The center of the noise regarding radial symmetry; the y-coordinate.
    • divisions

      public int divisions
      How many times the noise should repeat in one loop around the center.
    • mirror

      public boolean mirror
      If divisions is an even number and this is true, this will flip the noise for odd-numbered divisions, making division 1 a mirror image of division 0, division 3 a mirror image of division 2, and so on.
  • Constructor Details

    • RadialNoiseWrapper

      public RadialNoiseWrapper()
    • RadialNoiseWrapper

      public RadialNoiseWrapper(INoise toWrap, float centerX, float centerY)
    • RadialNoiseWrapper

      public RadialNoiseWrapper(INoise toWrap, float frequency, int mode, int octaves, float centerX, float centerY)
    • RadialNoiseWrapper

      public RadialNoiseWrapper(INoise toWrap, long seed, float frequency, int mode, int octaves, float centerX, float centerY)
    • RadialNoiseWrapper

      public RadialNoiseWrapper(INoise toWrap, long seed, float frequency, int mode, int octaves, boolean fractalSpiral, float centerX, float centerY)
    • RadialNoiseWrapper

      public RadialNoiseWrapper(RadialNoiseWrapper other)
  • Method Details

    • getCenterX

      public float getCenterX()
    • setCenterX

      public RadialNoiseWrapper setCenterX(float centerX)
    • getCenterY

      public float getCenterY()
    • setCenterY

      public RadialNoiseWrapper setCenterY(float centerY)
    • setCenter

      public RadialNoiseWrapper setCenter(float centerX, float centerY)
    • getDivisions

      public int getDivisions()
    • setDivisions

      public RadialNoiseWrapper setDivisions(int divisions)
    • isMirror

      public boolean isMirror()
    • setMirror

      public RadialNoiseWrapper setMirror(boolean mirror)
    • getMinDimension

      public int getMinDimension()
      Description copied from interface: INoise
      Gets the minimum dimension supported by this generator, such as 2 for a generator that only is defined for flat surfaces, or 3 for one that is only defined for 3D or higher-dimensional spaces.
      Specified by:
      getMinDimension in interface INoise
      Overrides:
      getMinDimension in class NoiseWrapper
      Returns:
      the minimum supported dimension, from 2 to 7 inclusive
    • getMaxDimension

      public int getMaxDimension()
      Description copied from interface: INoise
      Gets the maximum dimension supported by this generator, such as 2 for a generator that only is defined for flat surfaces, or 7 for one that is defined up to the highest dimension this interface knows about (7D).
      Specified by:
      getMaxDimension in interface INoise
      Overrides:
      getMaxDimension in class NoiseWrapper
      Returns:
      the maximum supported dimension, from 2 to 7 inclusive
    • getTag

      public String getTag()
      Description copied from interface: INoise
      Returns a typically-four-character String constant that should uniquely identify this INoise as well as possible. If a duplicate tag is already registered and INoise.Serializer.register(INoise) attempts to register the same tag again, a message is printed to System.err. The default implementation returns the String (NO), which is essentially an invalid tag, meant to indicate that this was not fully implemented. Implementing this is required for any usage of Serializer.
      Specified by:
      getTag in interface INoise
      Overrides:
      getTag in class NoiseWrapper
      Returns:
      a short String constant that identifies this INoise type
    • stringSerialize

      public String stringSerialize()
      Description copied from interface: INoise
      Produces a String that describes everything needed to recreate this INoise in full. This String can be read back in by INoise.stringDeserialize(String) to reassign the described state to another INoise. The syntax here should always start and end with the ` character, which is used by INoise.stringDeserialize(String) to identify the portion of a String that can be read back. The ` character should not be otherwise used unless to serialize another INoise that this uses.
      If you use Base to produce String representations for numeric fields in an INoise, Base.BASE10 is strongly recommended; in most cases, you can just use string concatenation with the fields separated by the tilde character, "~". For printing a float field with Base to a StringBuilder sb, use Base.BASE10.appendGeneral(sb, field).
      The default implementation throws an UnsupportedOperationException only. INoise classes do not have to implement any serialization methods, but they aren't serializable by the methods in this class or in INoise.Serializer unless they do implement this, INoise.getTag(), INoise.stringDeserialize(String), and INoise.copy().
      Specified by:
      stringSerialize in interface INoise
      Overrides:
      stringSerialize in class NoiseWrapper
      Returns:
      a String that describes this INoise for serialization
    • stringDeserialize

      public RadialNoiseWrapper stringDeserialize(String data)
      Description copied from interface: INoise
      Given a serialized String produced by INoise.stringSerialize(), reassigns this INoise to have the described state from the given String. The serialized String must have been produced by the same class as this object is.
      Any class that implements INoise.stringSerialize() should also implement this method in a compatible way. Using base-10 is expected for most uses. Using Base.BASE10.readFloat(data, start, end) may be useful to parse only the part of data between start and end.
      The default implementation throws an UnsupportedOperationException only. INoise classes do not have to implement any serialization methods, but they aren't serializable by the methods in this class or in INoise.Serializer unless they do implement this, INoise.getTag(), INoise.stringSerialize(), and INoise.copy().
      Specified by:
      stringDeserialize in interface INoise
      Overrides:
      stringDeserialize in class NoiseWrapper
      Parameters:
      data - a serialized String, typically produced by INoise.stringSerialize()
      Returns:
      this INoise, after being modified (if possible)
    • copy

      public RadialNoiseWrapper copy()
      Description copied from interface: INoise
      Creates a copy of this INoise, which should be a deep copy for any mutable state but can be shallow for immutable types such as functions. This almost always just calls a copy constructor.
      The default implementation throws an UnsupportedOperationException only. Implementors are strongly encouraged to implement this in general, and that is required to use an INoise class with INoise.Serializer.
      Specified by:
      copy in interface INoise
      Overrides:
      copy in class NoiseWrapper
      Returns:
      a copy of this INoise
    • getNoise

      public float getNoise(float x, float y)
      Description copied from interface: INoise
      Gets 2D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class NoiseWrapper
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      Returns:
      a noise value between -1.0f and 1.0f, both inclusive
    • getNoise

      public float getNoise(float x, float y, float z)
      Description copied from interface: INoise
      Gets 3D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class NoiseWrapper
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      z - z position; can be any finite float
      Returns:
      a noise value between -1.0f and 1.0f, both inclusive
    • getNoiseWithSeed

      public float getNoiseWithSeed(float x, float y, long seed)
      Description copied from interface: INoise
      Gets 2D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen with INoise.hasEfficientSetSeed().
      Specified by:
      getNoiseWithSeed in interface INoise
      Overrides:
      getNoiseWithSeed in class NoiseWrapper
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      seed - can be any long
      Returns:
      a noise value between -1.0f and 1.0f, both inclusive
    • getNoiseWithSeed

      public float getNoiseWithSeed(float x, float y, float z, long seed)
      Description copied from interface: INoise
      Gets 3D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen with INoise.hasEfficientSetSeed().
      Specified by:
      getNoiseWithSeed in interface INoise
      Overrides:
      getNoiseWithSeed in class NoiseWrapper
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      z - z position; can be any finite float
      seed - can be any long
      Returns:
      a noise value between -1.0f and 1.0f, both inclusive
    • getSerializersNeeded

      public List<Class<?>> getSerializersNeeded()
      Specified by:
      getSerializersNeeded in interface com.github.yellowstonegames.core.ISerializersNeeded
      Overrides:
      getSerializersNeeded in class NoiseWrapper