diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BiHermiteStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BiHermiteStream.java new file mode 100644 index 000000000..8733abb36 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BiHermiteStream.java @@ -0,0 +1,89 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; +import com.volmit.iris.util.IrisInterpolation; + +public class BiHermiteStream extends BasicLayer implements ProceduralStream, Interpolator +{ + private final ProceduralStream stream; + private final int rx; + private final int ry; + private final double tension; + private final double bias; + + public BiHermiteStream(ProceduralStream stream, int rx, int ry, double tension, double bias) + { + this.stream = stream; + this.rx = rx; + this.ry = ry; + this.tension = tension; + this.bias = bias; + } + + public BiHermiteStream(ProceduralStream stream, int rx, int ry) + { + this(stream, rx, ry, 0.5, 0); + } + + public T interpolate(double x, double y) + { + int fx = (int) Math.floor(x / rx); + int fz = (int) Math.floor(y / ry); + int x0 = (int) Math.round((fx - 1) * rx); + int z0 = (int) Math.round((fz - 1) * ry); + int x1 = (int) Math.round(fx * rx); + int z1 = (int) Math.round(fz * ry); + int x2 = (int) Math.round((fx + 1) * rx); + int z2 = (int) Math.round((fz + 1) * ry); + int x3 = (int) Math.round((fx + 2) * rx); + int z3 = (int) Math.round((fz + 2) * ry); + double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x); + double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, y); + + //@builder + return stream.fromDouble(IrisInterpolation.bihermite( + stream.getDouble(x0, z0), + stream.getDouble(x0, z1), + stream.getDouble(x0, z2), + stream.getDouble(x0, z3), + stream.getDouble(x1, z0), + stream.getDouble(x1, z1), + stream.getDouble(x1, z2), + stream.getDouble(x1, z3), + stream.getDouble(x2, z0), + stream.getDouble(x2, z1), + stream.getDouble(x2, z2), + stream.getDouble(x2, z3), + stream.getDouble(x3, z0), + stream.getDouble(x3, z1), + stream.getDouble(x3, z2), + stream.getDouble(x3, z3), + px, pz, tension, bias)); + //@done + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + @Override + public T get(double x, double z) + { + return interpolate(x, z); + } + + @Override + public T get(double x, double y, double z) + { + return interpolate(x, z); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BicubicStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BicubicStream.java new file mode 100644 index 000000000..9194981ae --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BicubicStream.java @@ -0,0 +1,80 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; +import com.volmit.iris.util.IrisInterpolation; + +public class BicubicStream extends BasicLayer implements ProceduralStream, Interpolator +{ + private final ProceduralStream stream; + private final int rx; + private final int ry; + + public BicubicStream(ProceduralStream stream, int rx, int ry) + { + this.stream = stream; + this.rx = rx; + this.ry = ry; + } + + public T interpolate(double x, double y) + { + int fx = (int) Math.floor(x / rx); + int fz = (int) Math.floor(y / ry); + int x0 = (int) Math.round((fx - 1) * rx); + int z0 = (int) Math.round((fz - 1) * ry); + int x1 = (int) Math.round(fx * rx); + int z1 = (int) Math.round(fz * ry); + int x2 = (int) Math.round((fx + 1) * rx); + int z2 = (int) Math.round((fz + 1) * ry); + int x3 = (int) Math.round((fx + 2) * rx); + int z3 = (int) Math.round((fz + 2) * ry); + double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x); + double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, y); + + //@builder + return stream.fromDouble(IrisInterpolation.bicubic( + stream.getDouble(x0, z0), + stream.getDouble(x0, z1), + stream.getDouble(x0, z2), + stream.getDouble(x0, z3), + stream.getDouble(x1, z0), + stream.getDouble(x1, z1), + stream.getDouble(x1, z2), + stream.getDouble(x1, z3), + stream.getDouble(x2, z0), + stream.getDouble(x2, z1), + stream.getDouble(x2, z2), + stream.getDouble(x2, z3), + stream.getDouble(x3, z0), + stream.getDouble(x3, z1), + stream.getDouble(x3, z2), + stream.getDouble(x3, z3), + px, pz)); + //@done + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + @Override + public T get(double x, double z) + { + return interpolate(x, z); + } + + @Override + public T get(double x, double y, double z) + { + return interpolate(x, z); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BilinearStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BilinearStream.java new file mode 100644 index 000000000..7afde0fd8 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/BilinearStream.java @@ -0,0 +1,64 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; +import com.volmit.iris.util.IrisInterpolation; + +public class BilinearStream extends BasicLayer implements ProceduralStream, Interpolator +{ + private final ProceduralStream stream; + private final int rx; + private final int ry; + + public BilinearStream(ProceduralStream stream, int rx, int ry) + { + this.stream = stream; + this.rx = rx; + this.ry = ry; + } + + public T interpolate(double x, double y) + { + int fx = (int) Math.floor(x / rx); + int fz = (int) Math.floor(y / ry); + int x1 = (int) Math.round(fx * rx); + int z1 = (int) Math.round(fz * ry); + int x2 = (int) Math.round((fx + 1) * rx); + int z2 = (int) Math.round((fz + 1) * ry); + double px = IrisInterpolation.rangeScale(0, 1, x1, x2, x); + double pz = IrisInterpolation.rangeScale(0, 1, z1, z2, y); + + //@builder + return stream.fromDouble(IrisInterpolation.blerp( + stream.getDouble(x1, z1), + stream.getDouble(x2, z1), + stream.getDouble(x1, z2), + stream.getDouble(x2, z2), + px, pz)); + //@done + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + @Override + public T get(double x, double z) + { + return interpolate(x, z); + } + + @Override + public T get(double x, double y, double z) + { + return interpolate(x, z); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/CNGStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/CNGStream.java new file mode 100644 index 000000000..be9f78327 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/CNGStream.java @@ -0,0 +1,52 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; +import com.volmit.iris.noise.CNG; + +public class CNGStream extends BasicLayer implements ProceduralStream +{ + private final CNG cng; + + public CNGStream(CNG cng) + { + this.cng = cng; + } + + public CNGStream(CNG cng, double zoom, double offsetX, double offsetY, double offsetZ) + { + super(1337, zoom, offsetX, offsetY, offsetZ); + this.cng = cng; + } + + public CNGStream(CNG cng, double zoom) + { + super(1337, zoom); + this.cng = cng; + } + + @Override + public double toDouble(Double t) + { + return t; + } + + @Override + public Double fromDouble(double d) + { + return d; + } + + @Override + public Double get(double x, double z) + { + return cng.noise((x + getOffsetX()) / getZoom(), (z + getOffsetZ()) / getZoom()); + } + + @Override + public Double get(double x, double y, double z) + { + return cng.noise((x + getOffsetX()) / getZoom(), (y + getOffsetY()) / getZoom(), (z + getOffsetZ()) * getZoom()); + } + +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/CachedConversionStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/CachedConversionStream.java new file mode 100644 index 000000000..bacdac251 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/CachedConversionStream.java @@ -0,0 +1,46 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import java.util.function.Function; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; +import com.volmit.iris.util.KMap; + +public class CachedConversionStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final Function converter; + private final KMap cache; + + public CachedConversionStream(ProceduralStream stream, Function converter) + { + super(); + this.stream = stream; + this.converter = converter; + cache = new KMap<>(); + } + + @Override + public double toDouble(V t) + { + return 0; + } + + @Override + public V fromDouble(double d) + { + return null; + } + + @Override + public V get(double x, double z) + { + return cache.compute(stream.get(x, z), (k, v) -> v != null ? v : converter.apply(k)); + } + + @Override + public V get(double x, double y, double z) + { + return cache.compute(stream.get(x, y, z), (k, v) -> v != null ? v : converter.apply(k)); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ClampedStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ClampedStream.java new file mode 100644 index 000000000..65362e11a --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ClampedStream.java @@ -0,0 +1,49 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class ClampedStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final double min; + private final double max; + + public ClampedStream(ProceduralStream stream, double min, double max) + { + super(); + this.stream = stream; + this.min = min; + this.max = max; + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + private double clamp(double v) + { + return Math.max(Math.min(v, max), min); + } + + @Override + public T get(double x, double z) + { + return fromDouble(clamp(stream.getDouble(x, z))); + } + + @Override + public T get(double x, double y, double z) + { + return fromDouble(clamp(stream.getDouble(x, y, z))); + } + +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ConversionStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ConversionStream.java new file mode 100644 index 000000000..5afc9cec3 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ConversionStream.java @@ -0,0 +1,43 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import java.util.function.Function; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class ConversionStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final Function converter; + + public ConversionStream(ProceduralStream stream, Function converter) + { + super(); + this.stream = stream; + this.converter = converter; + } + + @Override + public double toDouble(V t) + { + return 0; + } + + @Override + public V fromDouble(double d) + { + return null; + } + + @Override + public V get(double x, double z) + { + return converter.apply(stream.get(x, z)); + } + + @Override + public V get(double x, double y, double z) + { + return converter.apply(stream.get(x, y, z)); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/FittedStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/FittedStream.java new file mode 100644 index 000000000..8292c03fe --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/FittedStream.java @@ -0,0 +1,58 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class FittedStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final double min; + private final double max; + private final double inMin; + private final double inMax; + + public FittedStream(ProceduralStream stream, double inMin, double inMax, double min, double max) + { + super(); + this.stream = stream; + this.inMin = inMin; + this.inMax = inMax; + this.min = min; + this.max = max; + } + + public FittedStream(ProceduralStream stream, double min, double max) + { + this(stream, 0, 1, min, max); + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + private double dlerp(double v) + { + return min + ((max - min) * ((v - inMin) / (inMax - inMin))); + } + + @Override + public T get(double x, double z) + { + return fromDouble(dlerp(stream.getDouble(x, z))); + } + + @Override + public T get(double x, double y, double z) + { + return fromDouble(dlerp(stream.getDouble(x, y, z))); + } + +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/Interpolated.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/Interpolated.java new file mode 100644 index 000000000..d9035559f --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/Interpolated.java @@ -0,0 +1,20 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public interface Interpolated +{ + public double toDouble(T t); + + public T fromDouble(double d); + + default InterpolatorFactory interpolate() + { + if(this instanceof ProceduralStream) + { + return new InterpolatorFactory((ProceduralStream) this); + } + + return null; + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/Interpolator.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/Interpolator.java new file mode 100644 index 000000000..ebb842b9b --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/Interpolator.java @@ -0,0 +1,17 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public interface Interpolator +{ + @SuppressWarnings("unchecked") + default InterpolatorFactory into() + { + if(this instanceof ProceduralStream) + { + return new InterpolatorFactory((ProceduralStream) this); + } + + return null; + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/InterpolatorFactory.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/InterpolatorFactory.java new file mode 100644 index 000000000..51ca295d3 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/InterpolatorFactory.java @@ -0,0 +1,73 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class InterpolatorFactory +{ + private final ProceduralStream stream; + + public InterpolatorFactory(ProceduralStream stream) + { + this.stream = stream; + } + + public BicubicStream bicubic(int rx, int ry) + { + return new BicubicStream<>(stream, rx, ry); + } + + public BicubicStream bicubic(int r) + { + return bicubic(r, r); + } + + public BilinearStream bilinear(int rx, int ry) + { + return new BilinearStream<>(stream, rx, ry); + } + + public BilinearStream bilinear(int r) + { + return bilinear(r, r); + } + + public StarcastStream starcast(int radius, int checks) + { + return new StarcastStream<>(stream, radius, checks); + } + + public StarcastStream starcast3(int radius) + { + return starcast(radius, 3); + } + + public StarcastStream starcast6(int radius) + { + return starcast(radius, 6); + } + + public StarcastStream starcast9(int radius) + { + return starcast(radius, 9); + } + + public BiHermiteStream bihermite(int rx, int ry, double tension, double bias) + { + return new BiHermiteStream<>(stream, rx, ry, tension, bias); + } + + public BiHermiteStream bihermite(int rx, int ry) + { + return new BiHermiteStream<>(stream, rx, ry); + } + + public BiHermiteStream bihermite(int r) + { + return bihermite(r, r); + } + + public BiHermiteStream bihermite(int r, double tension, double bias) + { + return bihermite(r, r, tension, bias); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/OffsetStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/OffsetStream.java new file mode 100644 index 000000000..484572f36 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/OffsetStream.java @@ -0,0 +1,46 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class OffsetStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final double ox; + private final double oy; + private final double oz; + + public OffsetStream(ProceduralStream stream, double x, double y, double z) + { + super(); + this.stream = stream; + this.ox = x; + this.oy = y; + this.oz = z; + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + @Override + public T get(double x, double z) + { + return stream.get(x + ox, z + oz); + } + + @Override + public T get(double x, double y, double z) + { + return stream.get(x + ox, y + oy, z + oz); + } + +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/RoundingStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/RoundingStream.java new file mode 100644 index 000000000..dc52887f9 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/RoundingStream.java @@ -0,0 +1,45 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class RoundingStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + + public RoundingStream(ProceduralStream stream) + { + super(); + this.stream = stream; + } + + @Override + public double toDouble(Integer t) + { + return t.doubleValue(); + } + + @Override + public Integer fromDouble(double d) + { + return (int) Math.round(d); + } + + private int round(double v) + { + return (int) Math.round(v); + } + + @Override + public Integer get(double x, double z) + { + return round(stream.getDouble(x, z)); + } + + @Override + public Integer get(double x, double y, double z) + { + return round(stream.getDouble(x, y, z)); + } + +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/SelectionStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/SelectionStream.java new file mode 100644 index 000000000..68da763d7 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/SelectionStream.java @@ -0,0 +1,50 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import java.util.List; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class SelectionStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final T[] options; + + public SelectionStream(ProceduralStream stream, T[] options) + { + super(); + this.stream = stream.fit(0, options.length - 1).round(); + this.options = options; + } + + @SuppressWarnings("unchecked") + public SelectionStream(ProceduralStream stream, List options) + { + this(stream, (T[]) options.toArray()); + } + + @Override + public double toDouble(T t) + { + throw new UnsupportedOperationException(); + } + + @Override + public T fromDouble(double d) + { + throw new UnsupportedOperationException(); + } + + @Override + public T get(double x, double z) + { + return options[stream.get(x, z)]; + } + + @Override + public T get(double x, double y, double z) + { + return options[stream.get(x, y, z)]; + } + +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/StarcastStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/StarcastStream.java new file mode 100644 index 000000000..3d64e0040 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/StarcastStream.java @@ -0,0 +1,59 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class StarcastStream extends BasicLayer implements ProceduralStream, Interpolator +{ + private ProceduralStream stream; + private int rad; + private int checks; + + public StarcastStream(ProceduralStream stream, int rad, int checks) + { + this.stream = stream; + this.rad = rad; + this.checks = checks; + } + + public T interpolate(double x, double y) + { + double m = (360 / checks); + double v = 0; + + for(int i = 0; i < 360; i += m) + { + double sin = Math.sin(Math.toRadians(i)); + double cos = Math.cos(Math.toRadians(i)); + double cx = x + ((rad * cos) - (rad * sin)); + double cz = y + ((rad * sin) + (rad * cos)); + v += stream.getDouble(cx, cz); + } + + return stream.fromDouble(v / checks); + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + @Override + public T get(double x, double z) + { + return interpolate(x, z); + } + + @Override + public T get(double x, double y, double z) + { + return interpolate(x, z); + } +} diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ZoomStream.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ZoomStream.java new file mode 100644 index 000000000..b1759e489 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/stream/ZoomStream.java @@ -0,0 +1,46 @@ +package com.volmit.iris.gen.v2.scaffold.stream; + +import com.volmit.iris.gen.v2.scaffold.layer.BasicLayer; +import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream; + +public class ZoomStream extends BasicLayer implements ProceduralStream +{ + private final ProceduralStream stream; + private final double ox; + private final double oy; + private final double oz; + + public ZoomStream(ProceduralStream stream, double x, double y, double z) + { + super(); + this.stream = stream; + this.ox = x; + this.oy = y; + this.oz = z; + } + + @Override + public double toDouble(T t) + { + return stream.toDouble(t); + } + + @Override + public T fromDouble(double d) + { + return stream.fromDouble(d); + } + + @Override + public T get(double x, double z) + { + return stream.get(x / ox, z / oz); + } + + @Override + public T get(double x, double y, double z) + { + return stream.get(x / ox, y / oy, z / oz); + } + +}