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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface INoise
INoise.Serializer -
Field Summary
FieldsModifier and TypeFieldDescriptionfloatThe center of the noise regarding radial symmetry; the x-coordinate.floatThe center of the noise regarding radial symmetry; the y-coordinate.intHow many times the noise should repeat in one loop around the center.booleanIfdivisionsis 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.Fields inherited from class NoiseWrapper
BILLOW, DOMAIN_WARP, EXO, FBM, fractalSpiral, frequency, mode, octaves, RIDGED_MULTI, wrapped -
Constructor Summary
ConstructorsConstructorDescriptionRadialNoiseWrapper(INoise toWrap, float centerX, float centerY) RadialNoiseWrapper(INoise toWrap, float frequency, int mode, int octaves, float centerX, float centerY) RadialNoiseWrapper(INoise toWrap, long seed, float frequency, int mode, int octaves, boolean fractalSpiral, float centerX, float centerY) RadialNoiseWrapper(INoise toWrap, long seed, float frequency, int mode, int octaves, float centerX, float centerY) -
Method Summary
Modifier and TypeMethodDescriptioncopy()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.floatfloatintintGets 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).intGets 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.floatgetNoise(float x, float y) Gets 2D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z) Gets 3D noise with a default or pre-set seed.floatgetNoiseWithSeed(float x, float y, float z, long seed) Gets 3D noise with a specific seed.floatgetNoiseWithSeed(float x, float y, long seed) Gets 2D noise with a specific seed.getTag()Returns a typically-four-character String constant that should uniquely identify this INoise as well as possible.booleanisMirror()setCenter(float centerX, float centerY) setCenterX(float centerX) setCenterY(float centerY) setDivisions(int divisions) setMirror(boolean mirror) stringDeserialize(String data) Given a serialized String produced byINoise.stringSerialize(), reassigns this INoise to have the described state from the given String.Produces a String that describes everything needed to recreate this INoise in full.Methods inherited from class NoiseWrapper
billow, billow, billow, billow, billow, equals, exo, exo, exo, exo, exo, fbm, fbm, fbm, fbm, fbm, getFractalOctaves, getFractalType, getFrequency, getMode, getNoise, getNoise, getNoise, getNoiseWithSeed, getNoiseWithSeed, getNoiseWithSeed, getOctaves, getSeed, getWrapped, hasEfficientSetSeed, hashCode, isFractalSpiral, ridged, ridged, ridged, ridged, ridged, setFractalOctaves, setFractalSpiral, setFractalType, setFrequency, setMode, setOctaves, setSeed, setWrapped, toString, warp, warp, warp, warp, warpMethods inherited from interface INoise
getNoise, getNoiseWithSeed, readExternal, writeExternal
-
Field Details
-
centerX
public float centerXThe center of the noise regarding radial symmetry; the x-coordinate. -
centerY
public float centerYThe center of the noise regarding radial symmetry; the y-coordinate. -
divisions
public int divisionsHow many times the noise should repeat in one loop around the center. -
mirror
public boolean mirrorIfdivisionsis 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
-
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
-
-
Method Details
-
getCenterX
public float getCenterX() -
setCenterX
-
getCenterY
public float getCenterY() -
setCenterY
-
setCenter
-
getDivisions
public int getDivisions() -
setDivisions
-
isMirror
public boolean isMirror() -
setMirror
-
getMinDimension
public int getMinDimension()Description copied from interface:INoiseGets 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:
getMinDimensionin interfaceINoise- Overrides:
getMinDimensionin classNoiseWrapper- Returns:
- the minimum supported dimension, from 2 to 7 inclusive
-
getMaxDimension
public int getMaxDimension()Description copied from interface:INoiseGets 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:
getMaxDimensionin interfaceINoise- Overrides:
getMaxDimensionin classNoiseWrapper- Returns:
- the maximum supported dimension, from 2 to 7 inclusive
-
getTag
Description copied from interface:INoiseReturns a typically-four-character String constant that should uniquely identify this INoise as well as possible. If a duplicate tag is already registered andINoise.Serializer.register(INoise)attempts to register the same tag again, a message is printed toSystem.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:
getTagin interfaceINoise- Overrides:
getTagin classNoiseWrapper- Returns:
- a short String constant that identifies this INoise type
-
stringSerialize
Description copied from interface:INoiseProduces a String that describes everything needed to recreate this INoise in full. This String can be read back in byINoise.stringDeserialize(String)to reassign the described state to another INoise. The syntax here should always start and end with the`character, which is used byINoise.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 useBaseto produce String representations for numeric fields in an INoise,Base.BASE10is strongly recommended; in most cases, you can just use string concatenation with the fields separated by the tilde character,"~". For printing a floatfieldwith Base to a StringBuildersb, useBase.BASE10.appendGeneral(sb, field).
The default implementation throws anUnsupportedOperationExceptiononly. INoise classes do not have to implement any serialization methods, but they aren't serializable by the methods in this class or inINoise.Serializerunless they do implement this,INoise.getTag(),INoise.stringDeserialize(String), andINoise.copy().- Specified by:
stringSerializein interfaceINoise- Overrides:
stringSerializein classNoiseWrapper- Returns:
- a String that describes this INoise for serialization
-
stringDeserialize
Description copied from interface:INoiseGiven a serialized String produced byINoise.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 implementsINoise.stringSerialize()should also implement this method in a compatible way. Using base-10 is expected for most uses. UsingBase.BASE10.readFloat(data, start, end)may be useful to parse only the part of data between start and end.
The default implementation throws anUnsupportedOperationExceptiononly. INoise classes do not have to implement any serialization methods, but they aren't serializable by the methods in this class or inINoise.Serializerunless they do implement this,INoise.getTag(),INoise.stringSerialize(), andINoise.copy().- Specified by:
stringDeserializein interfaceINoise- Overrides:
stringDeserializein classNoiseWrapper- Parameters:
data- a serialized String, typically produced byINoise.stringSerialize()- Returns:
- this INoise, after being modified (if possible)
-
copy
Description copied from interface:INoiseCreates 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 anUnsupportedOperationExceptiononly. Implementors are strongly encouraged to implement this in general, and that is required to use an INoise class withINoise.Serializer.- Specified by:
copyin interfaceINoise- Overrides:
copyin classNoiseWrapper- Returns:
- a copy of this INoise
-
getNoise
public float getNoise(float x, float y) Description copied from interface:INoiseGets 2D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classNoiseWrapper- Parameters:
x- x position; can be any finite floaty- 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:INoiseGets 3D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classNoiseWrapper- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- 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:INoiseGets 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 withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Overrides:
getNoiseWithSeedin classNoiseWrapper- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatseed- 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:INoiseGets 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 withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Overrides:
getNoiseWithSeedin classNoiseWrapper- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatseed- can be any long- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getSerializersNeeded
- Specified by:
getSerializersNeededin interfacecom.github.yellowstonegames.core.ISerializersNeeded- Overrides:
getSerializersNeededin classNoiseWrapper
-