- update biome colours
- fix preview map legend info - added terrain-type display mode
This commit is contained in:
parent
9786d819b0
commit
f4e9e7efe3
@ -35,6 +35,7 @@ import com.terraforged.core.util.concurrent.ThreadPool;
|
||||
import com.terraforged.core.util.concurrent.cache.CacheEntry;
|
||||
import com.terraforged.core.world.GeneratorContext;
|
||||
import com.terraforged.core.world.WorldGeneratorFactory;
|
||||
import com.terraforged.core.world.heightmap.Levels;
|
||||
import com.terraforged.core.world.terrain.Terrain;
|
||||
import com.terraforged.core.world.terrain.Terrains;
|
||||
import com.terraforged.mod.util.nbt.NBTHelper;
|
||||
@ -109,6 +110,7 @@ public class Preview extends Button {
|
||||
RenderSystem.disableRescaleNormal();
|
||||
|
||||
updateLegend(mx, my);
|
||||
|
||||
renderLegend(labels, values, x, y + width, 10, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@ -130,6 +132,8 @@ public class Preview extends Button {
|
||||
try {
|
||||
region = task.get();
|
||||
render(region);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
} finally {
|
||||
task = null;
|
||||
}
|
||||
@ -143,8 +147,7 @@ public class Preview extends Button {
|
||||
}
|
||||
|
||||
RenderMode renderer = previewSettings.mode;
|
||||
Terrains terrains = Terrains.create(settings);
|
||||
GeneratorContext context = new GeneratorContext(terrains, settings);
|
||||
Levels levels = new Levels(settings.generator);
|
||||
|
||||
int stroke = 2;
|
||||
int width = region.getBlockSize().size;
|
||||
@ -164,8 +167,7 @@ public class Preview extends Button {
|
||||
if (x < stroke || z < stroke || x >= width - stroke || z >= width - stroke) {
|
||||
image.setPixelRGBA(x, z, Color.BLACK.getRGB());
|
||||
} else {
|
||||
Color color = renderer.color(cell, context);
|
||||
image.setPixelRGBA(x, z, RenderMode.rgba(color));
|
||||
image.setPixelRGBA(x, z, renderer.getColor(cell, levels));
|
||||
}
|
||||
|
||||
if (z == half) {
|
||||
@ -203,19 +205,21 @@ public class Preview extends Button {
|
||||
.size(FACTOR, 0)
|
||||
.build();
|
||||
|
||||
return renderer.queue(offsetX, offsetZ, 101 - previewSettings.zoom, true);
|
||||
return renderer.queue(offsetX, offsetZ, 101 - previewSettings.zoom, false);
|
||||
}
|
||||
|
||||
private void updateLegend(int mx ,int my) {
|
||||
if (region != null) {
|
||||
int left = this.x;
|
||||
int top = this.y;
|
||||
float size = this.width;
|
||||
int zoom = (101 - previewSettings.zoom);
|
||||
int width = Math.max(1, region.getBlockSize().size * zoom);
|
||||
int height = Math.max(1, region.getBlockSize().size * zoom);
|
||||
values[0] = width + "x" + height;
|
||||
|
||||
if (mx >= this.x && mx <= this.x + this.width && my >= this.y && my <= this.y + this.height) {
|
||||
float fx = (mx - this.x) / (float) this.width;
|
||||
float fz = (my - this.y) / (float) this.height;
|
||||
if (mx >= left && mx <= left + size && my >= top && my <= top + size) {
|
||||
float fx = (mx - left) / size;
|
||||
float fz = (my - top) / size;
|
||||
int ix = NoiseUtil.round(fx * region.getBlockSize().size);
|
||||
int iz = NoiseUtil.round(fz * region.getBlockSize().size);
|
||||
Cell<Terrain> cell = region.getCell(ix, iz);
|
||||
|
@ -92,7 +92,7 @@ public class PreviewPage extends BasePage {
|
||||
update();
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
public void update() {
|
||||
preview.update(settings, previewerSettings);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
package com.terraforged.mod.gui.preview;
|
||||
|
||||
import com.terraforged.core.cell.Cell;
|
||||
import com.terraforged.core.world.GeneratorContext;
|
||||
import com.terraforged.core.world.heightmap.Levels;
|
||||
import com.terraforged.core.world.terrain.Terrain;
|
||||
import me.dags.noise.util.NoiseUtil;
|
||||
@ -34,50 +33,77 @@ import me.dags.noise.util.NoiseUtil;
|
||||
import java.awt.*;
|
||||
|
||||
public enum RenderMode {
|
||||
BIOME_TYPE,
|
||||
TEMPERATURE,
|
||||
MOISTURE,
|
||||
BIOME_SHAPE,
|
||||
BIOME_TYPE {
|
||||
@Override
|
||||
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||
Color color = cell.biomeType.getColor();
|
||||
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
|
||||
return rgba(hsb[0], hsb[1], (hsb[2] * scale) + bias);
|
||||
}
|
||||
},
|
||||
TEMPERATURE {
|
||||
@Override
|
||||
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||
float saturation = 0.7F;
|
||||
float brightness = 0.8F;
|
||||
return rgba(step(1 - cell.temperature, 8) * 0.65F, saturation, brightness);
|
||||
}
|
||||
},
|
||||
MOISTURE {
|
||||
@Override
|
||||
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||
float saturation = 0.7F;
|
||||
float brightness = 0.8F;
|
||||
return rgba(step(cell.moisture, 8) * 0.65F, saturation, brightness);
|
||||
}
|
||||
},
|
||||
BIOME_SHAPE {
|
||||
@Override
|
||||
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||
float saturation = 0.7F;
|
||||
float brightness = 0.8F;
|
||||
return rgba(cell.biome, saturation, brightness);
|
||||
}
|
||||
},
|
||||
TERRAIN_TYPE {
|
||||
@Override
|
||||
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||
float saturation = 0.7F;
|
||||
float brightness = 0.8F;
|
||||
return rgba(cell.region, saturation, brightness);
|
||||
}
|
||||
},
|
||||
;
|
||||
|
||||
public Color color(Cell<Terrain> cell, GeneratorContext context) {
|
||||
float baseHeight = Levels.getSeaLevel(context.settings.generator);
|
||||
public int getColor(Cell<Terrain> cell, Levels levels) {
|
||||
float baseHeight = levels.water;
|
||||
if (cell.value < baseHeight) {
|
||||
return new Color(40, 140, 200);
|
||||
return rgba(40, 140, 200);
|
||||
}
|
||||
|
||||
float bands = 10F;
|
||||
float alpha = 0.2F;
|
||||
float elevation = (cell.value - baseHeight) / (1F - baseHeight);
|
||||
|
||||
int band = NoiseUtil.round(elevation * bands);
|
||||
float scale = 1F - alpha;
|
||||
float bias = alpha * (band / bands);
|
||||
|
||||
float saturation = 0.7F;
|
||||
float brightness = 0.8F;
|
||||
|
||||
switch (this) {
|
||||
case BIOME_SHAPE:
|
||||
return Color.getHSBColor(cell.biome, saturation, brightness);
|
||||
case BIOME_TYPE:
|
||||
Color color = cell.biomeType.getColor();
|
||||
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
|
||||
return Color.getHSBColor(hsb[0], hsb[1], (hsb[2] * scale) + bias);
|
||||
case MOISTURE:
|
||||
return Color.getHSBColor(step(cell.moisture, 8) * 0.65F, saturation, brightness);
|
||||
case TEMPERATURE:
|
||||
return Color.getHSBColor(step(1 - cell.temperature, 8) * 0.65F, saturation, brightness);
|
||||
default:
|
||||
return Color.black;
|
||||
}
|
||||
return getColor(cell, scale, bias);
|
||||
}
|
||||
|
||||
public abstract int getColor(Cell<Terrain> cell, float scale, float bias);
|
||||
|
||||
private static float step(float value, int steps) {
|
||||
return ((float) NoiseUtil.round(value * steps)) / steps;
|
||||
}
|
||||
|
||||
public static int rgba(Color color) {
|
||||
return color.getRed() + (color.getGreen() << 8) + (color.getBlue() << 16) + (255 << 24);
|
||||
public static int rgba(float h, float s, float b) {
|
||||
int argb = Color.HSBtoRGB(h, s, b);
|
||||
int red = (argb >> 16) & 0xFF;
|
||||
int green = (argb >> 8) & 0xFF;
|
||||
int blue = argb & 0xFF;
|
||||
return rgba(red, green, blue);
|
||||
}
|
||||
|
||||
public static int rgba(int r, int g, int b) {
|
||||
return r + (g << 8) + (b << 16) + (255 << 24);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
#TerraForged BiomeType Hex Colors (do not include hash/pound character)
|
||||
#BiomeType Hex Colors (do not include hash/pound character)
|
||||
#Fri Jan 10 23:15:10 GMT 2020
|
||||
ALPINE=4b7835
|
||||
TAIGA=4b7835
|
||||
TEMPERATE_RAINFOREST=3c602b
|
||||
TUNDRA=f7fafc
|
||||
TROPICAL_RAINFOREST=4aa73a
|
||||
SAVANNA=389a38
|
||||
GRASSLAND=429545
|
||||
TEMPERATE_FOREST=456938
|
||||
STEPPE=c3aa61
|
||||
DESERT=e5d98f
|
||||
COLD_STEPPE=a7a374
|
||||
ALPINE=eff2ed
|
||||
TAIGA=4d733b
|
||||
TEMPERATE_RAINFOREST=528c35
|
||||
TUNDRA=d7dbc8
|
||||
TROPICAL_RAINFOREST=347d3f
|
||||
SAVANNA=88ad3e
|
||||
GRASSLAND=4bb34f
|
||||
TEMPERATE_FOREST=5d9948
|
||||
STEPPE=e0cb89
|
||||
DESERT=e6db9c
|
||||
COLD_STEPPE=c2bb84
|
Loading…
Reference in New Issue
Block a user