From 47695f1f8c93f391e9fb98340ce247d4b2286c9d Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 18 Jan 2020 13:24:14 -0500 Subject: [PATCH] Added accurate planet generation --- core/assets/planets/colors.png | Bin 0 -> 10737 bytes core/src/mindustry/ClientLauncher.java | 5 +-- core/src/mindustry/graphics/PlanetMesh.java | 31 +++++---------- .../maps/planet/PlanetGenerator.java | 37 ++++++++++++++++++ core/src/mindustry/type/Planet.java | 16 ++++---- .../mindustry/ui/dialogs/DeployDialog.java | 6 +-- 6 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 core/assets/planets/colors.png create mode 100644 core/src/mindustry/maps/planet/PlanetGenerator.java diff --git a/core/assets/planets/colors.png b/core/assets/planets/colors.png new file mode 100644 index 0000000000000000000000000000000000000000..5efd5d38e06573a086fe551d14de54e984881fdf GIT binary patch literal 10737 zcmV zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3;sawNHSh5us}S^|IzyBydE?Lf=dcTm-4dgjT6 z$mwD+nU#sW<`@9u&VT&-b^pd!$vL@{Yb(7J&sXZH$HANCKVP4p!Ke57zAS$K7XEtN z{rp4Zkm=0NujPEt9~{rWK2X#5`26c}SJ(GC?R%l`AAVfWbZ6ace+QXbu0xlmGlZRf4fI2Q9jIESP_<@pC6*6xMCu+LRlX1P<5Au_PMn0(-p2~xm4BJ{^?i4~n;(7=_|2nE=O@4P5Q+E=DeN%9 z4d?w_VKKxMPptfmaYcK_n$_6jdPzz84mVauezrAowaA=tIQ|?7F1hBG zdmhC~D!G(Wi*RaGtEuK%YOSsII-0fAax1O2)_NN~b_2$;>!sJ;dhcU!(~$<(8k|2k zFypkDW}ao%*=C<(Q9diJyvnMpt-i*N+cps3cG-2e-S;@*P)aAAe9Eb(oqoop)~?-j z^DVdDcKaPav-ZvEU$gdS=Kkxfg>Tm4OO(#5zp}>RT7O(32u`wcM#f?aWV|W^0w?9n zw~$g)=9DwvqdBu28D&;-c2LI1U^*e@8-C{QSLXg@-W<{W-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M3{@~!|y+<-#ub@ZVb?h3pX~?3EfD$oF z00?MF2E=`(8V8q2QdB4QyqMJmuquu#04vfrW=(?gN=**70WAPF@Kt-( z%qVyK(+}?Mbq0U?7vE0eaO}#dSezdEqE&z^nKxg%{KnU=Zmupr*y}{0J=d(qVGstB z)DEc3^4^Dc{_Vd%_WWF9Ndf{u1yKM50w9>w-6k>@wwr%?0u~}5pe~|QV5uI5!%+bU z>&@ir*DhSyUTfB3QRyC~S?+#u>(NeUI29_=N!a7UNk2}rm;z1(;uv!hT*Ys_@#dMs z#sy{hvA)+ryS`il(1U(flF0SpLKGIclRWX1Q+O!xGYBAdx0}M+@J04-I z(o|qXP^{cx04=Bhlz>r{c3*hXtkihUrHXZ!O}YU9L4nA`pb`qZNizN&9T(VmOSr(N z%#Ek>JTf($BojmmDux6=HReFsi4$dg!sG-1!U`{Tf?%WOwdX#3LYk{zQN^f|GLm=z zQZS$hilPJp6N5^%lH>(pRgZWsP^zBEwR3rqLJMK}y*~(|mCgWGL}eIgx`*7s00000NkvXXu0mjfzVbyL literal 0 HcmV?d00001 diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java index d1819b3a8f..6c5909a798 100644 --- a/core/src/mindustry/ClientLauncher.java +++ b/core/src/mindustry/ClientLauncher.java @@ -90,10 +90,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform assets.load(mods); assets.load(schematics); - assets.loadRun("contentinit", ContentLoader.class, () -> { - content.init(); - content.load(); - }); + assets.loadRun("contentinit", ContentLoader.class, () -> content.init(), () -> content.load()); } @Override diff --git a/core/src/mindustry/graphics/PlanetMesh.java b/core/src/mindustry/graphics/PlanetMesh.java index fc2436c5a1..cd851149a1 100644 --- a/core/src/mindustry/graphics/PlanetMesh.java +++ b/core/src/mindustry/graphics/PlanetMesh.java @@ -3,12 +3,11 @@ package mindustry.graphics; import arc.graphics.*; import arc.graphics.VertexAttributes.*; import arc.graphics.gl.*; -import arc.math.*; import arc.math.geom.*; import arc.util.ArcAnnotate.*; import arc.util.*; -import arc.util.noise.*; import mindustry.graphics.PlanetGrid.*; +import mindustry.maps.planet.*; public class PlanetMesh{ private float[] floats = new float[3 + 3 + 1]; @@ -16,19 +15,12 @@ public class PlanetMesh{ private Mesh mesh; private PlanetGrid grid; - private float color; - private boolean lines; - private float radius; + private boolean lines = false; + private float radius = 1f, intensity = 0.2f; - private Simplex sim = new Simplex(); - private RidgedPerlin rid = new RidgedPerlin(2, 2); - private Color[] colors = {Color.royal, Color.royal, Color.royal, Color.tan, Color.valueOf("3f9a50"), Color.valueOf("3f9a50"), Color.gray, Color.white, Color.white}; - private Vec3 normal = new Vec3(); + private PlanetGenerator gen = new PlanetGenerator(); - public PlanetMesh(int divisions, float radius, boolean lines, Color color){ - this.radius = radius; - this.lines = lines; - this.color = color.toFloatBits(); + public PlanetMesh(int divisions){ this.grid = PlanetGrid.newGrid(divisions); int vertices = grid.tiles.length * 12 * (3 + 3 + 1); @@ -77,7 +69,7 @@ public class PlanetMesh{ } for(Corner corner : c){ - corner.v.setLength(radius + elevation(corner.bv)); + corner.v.setLength(radius + elevation(corner.bv)*intensity); } for(Corner corner : c){ @@ -115,20 +107,15 @@ public class PlanetMesh{ } private Vec3 normal(Vec3 v1, Vec3 v2, Vec3 v3){ - return normal.set(v2).sub(v1).crs(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z).nor(); + return Tmp.v32.set(v2).sub(v1).crs(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z).nor(); } private float elevation(Vec3 v){ - if(lines) return 0; - - Color c = color(v); - if(c == Color.royal) return 0.19f; - return ((float)sim.octaveNoise3D(8, 0.7, 1 / 2.0, v.x, v.y, v.z)) / 3f + (rid.getValue(v.x, v.y, v.z, 1f) + 1f) / 12f; + return gen.getHeight(v); } private Color color(Vec3 v){ - float f = ((float)sim.octaveNoise3D(6, 0.6, 1 / 2.0, v.x, v.y, v.z)) * 0.5f + 0.5f * ((rid.getValue(v.x, v.y, v.z, 1f) + 1f) / 2f); - return colors[Mathf.clamp((int)(f * colors.length), 0, colors.length - 1)]; + return gen.getColor(v, elevation(v)); } private void verts(Vec3 a, Vec3 b, Vec3 c, Vec3 normal, Color color){ diff --git a/core/src/mindustry/maps/planet/PlanetGenerator.java b/core/src/mindustry/maps/planet/PlanetGenerator.java new file mode 100644 index 0000000000..e1f97f9df3 --- /dev/null +++ b/core/src/mindustry/maps/planet/PlanetGenerator.java @@ -0,0 +1,37 @@ +package mindustry.maps.planet; + +import arc.graphics.*; +import arc.math.*; +import arc.math.geom.*; +import arc.util.*; +import arc.util.noise.*; + +public class PlanetGenerator{ + Pixmap pix = new Pixmap("planets/colors.png"); + Simplex noise = new Simplex(); + int waterLevel = 5; + float water = waterLevel / (float)(pix.getHeight()); + float scl = 5f; + + public float getHeight(Vec3 position){ + position = Tmp.v33.set(position).scl(scl); + + float height = Mathf.pow((float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y, position.z), 2.4f); + if(height <= water){ + return water; + } + return height; + } + + public Color getColor(Vec3 position, float height){ + position = Tmp.v33.set(position).scl(scl); + float rad = scl; + float temp = Mathf.clamp(Math.abs(position.y * 2f) / (rad)); + float tnoise = (float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y + 999f, position.z); + temp = Mathf.lerp(temp, tnoise, 0.5f); + height *= 1.2f; + height = Mathf.clamp(height); + + return Tmp.c1.set(pix.getPixel((int)(temp * (pix.getWidth()-1)), (int)((1f-height) * (pix.getHeight()-1)))); + } +} diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index eddcef84bb..a8cc63d491 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -2,23 +2,25 @@ package mindustry.type; import arc.scene.ui.layout.*; import arc.util.ArcAnnotate.*; +import arc.util.*; import mindustry.ctype.*; import mindustry.graphics.*; public class Planet extends UnlockableContent{ - /** Mesh used for rendering. */ - public @NonNull PlanetMesh mesh; + /** Mesh used for rendering. Created on load(). */ + public PlanetMesh mesh; /** Grid used for the sectors on the planet. */ public @NonNull PlanetGrid grid; - public Planet(String name, PlanetMesh mesh){ + public Planet(String name){ super(name); - this.mesh = mesh; } - //mods - Planet(String name){ - super(name); + @Override + public void load(){ + Time.mark(); + mesh = new PlanetMesh(6); + Log.info("Time to generate planet mesh: {0}", Time.elapsed()); } /** Planets cannot be viewed in the database dialog. */ diff --git a/core/src/mindustry/ui/dialogs/DeployDialog.java b/core/src/mindustry/ui/dialogs/DeployDialog.java index 812043d4d1..e2917b9798 100644 --- a/core/src/mindustry/ui/dialogs/DeployDialog.java +++ b/core/src/mindustry/ui/dialogs/DeployDialog.java @@ -123,7 +123,7 @@ public class DeployDialog extends FloatingDialog{ setFilter(TextureFilter.Linear); }}){{ float[] time = {0}; - setColor(Color.fromGray(0.3f)); + setColor(Color.gray(0.3f)); setScale(1.5f); update(() -> { setOrigin(Align.center); @@ -141,7 +141,7 @@ public class DeployDialog extends FloatingDialog{ Stack sub = new Stack(); if(slot.getZone() != null){ - sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.fromGray(0.1f)).grow())); + sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.gray(0.1f)).grow())); sub.add(new Table(f -> f.margin(4f).add(new Image(slot.getZone().preview).setScaling(Scaling.fit)).update(img -> { TextureRegionDrawable draw = (TextureRegionDrawable)img.getDrawable(); @@ -255,7 +255,7 @@ public class DeployDialog extends FloatingDialog{ } stack.setSize(Tmp.v1.x, Tmp.v1.y); - stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.fromGray(0.2f)).grow())); + stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.gray(0.2f)).grow())); stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center)); Button button = new Button(Styles.squaret);