mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
cavegen renewed (WIP)
Former-commit-id: c29114d50d7d86ef903aa2215b5603a01547999a Former-commit-id: 1099816bc5fd8998cbd538a855c9986bc6b1b983
This commit is contained in:
@@ -90,12 +90,6 @@ Magical/Surreal: Use 24 Bits
|
||||
* Base mass: 60 kg
|
||||
|
||||
|
||||
## Custom pattern making ##
|
||||
|
||||
- Players can create their own décors (hang on wall), dresses.
|
||||
- Two looms (216 colour mode, 4096 colour mode)
|
||||
|
||||
|
||||
## Food/Potion dose ##
|
||||
|
||||
Scale ^ 3 ^ (3/4) == (ThisWgt / TargetWgt) ^ (3/4)
|
||||
|
||||
19
src/com/torvald/terrarum/MISC_FEATURES.md
Normal file
19
src/com/torvald/terrarum/MISC_FEATURES.md
Normal file
@@ -0,0 +1,19 @@
|
||||
## Gadgets ##
|
||||
|
||||
### Looms for custom pattern ###
|
||||
|
||||
- Players can create their own décors (hang on wall), dresses.
|
||||
- Two looms (216 colour mode, 4096 colour mode)
|
||||
|
||||
|
||||
### Music making ###
|
||||
|
||||
- Automated glockenspiel thingy
|
||||
- Single tile can hold 48 notes, single track
|
||||
- Work like Modtracker, incl. physical arrangements
|
||||
|
||||
Arrangements in the map
|
||||
Time →→→→
|
||||
voice 1 → # # # # # # #
|
||||
voice 2 → # # # # # # #
|
||||
↑ played simultaneously along the X-axis
|
||||
@@ -1,7 +1,7 @@
|
||||
## Format ##
|
||||
|
||||
* Save meta
|
||||
- Binary (for more security)
|
||||
- GZip'd binary (for more security)
|
||||
- Filename : world (with no extension)
|
||||
|
||||
|Type |Mnemonic |Description |
|
||||
@@ -11,10 +11,10 @@
|
||||
|Byte |NULL |String terminator |
|
||||
|Byte[8] |terraseed |Terrain seed |
|
||||
|Byte[8] |rogueseed |Randomiser seed |
|
||||
|Byte[32] |hash1 |SHA-256 hash of worldinfo1 being stored|
|
||||
|Byte[32] |hash2 |SHA-256 hash of worldinfo2 being stored|
|
||||
|Byte[32] |hash3 |SHA-256 hash of worldinfo3 being stored|
|
||||
|Byte[32] |hash4 |SHA-256 hash of worldinfo4 being stored|
|
||||
|Byte[32] |hash1 |SHA-256 hash of worldinfo1 being stored (when not zipped)|
|
||||
|Byte[32] |hash2 |SHA-256 hash of worldinfo2 being stored (when not zipped)|
|
||||
|Byte[32] |hash3 |SHA-256 hash of worldinfo3 being stored (when not zipped)|
|
||||
|Byte[32] |hash4 |SHA-256 hash of worldinfo4 being stored (when not zipped)|
|
||||
|
||||
Endianness: Big
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
|
||||
* Prop data
|
||||
- GZip'd CSV
|
||||
- Filename : worldinfo2 -- tileprop.csv
|
||||
worldinfo3 -- itemprop.csv
|
||||
worldinfo4 -- materialprop.csv
|
||||
(with no extension)
|
||||
- Filename : (with no extension)
|
||||
worldinfo2 -- tileprop
|
||||
worldinfo3 -- itemprop
|
||||
worldinfo4 -- materialprop
|
||||
|
||||
|
||||
* Human-readable
|
||||
@@ -39,8 +39,7 @@
|
||||
|
||||
|
||||
## How it works ##
|
||||
* If hash discrepancy has detected, (hash of csv in save dir != stored hash || hash of TEMD != stored hash)
|
||||
printout "Save file corrupted. Continue?" with prompt "Yes/No"
|
||||
* If hash discrepancy has detected, (hash of csv in save dir != stored hash || hash of TEMD != stored hash), printout "Save file corrupted. Continue?" with prompt "Yes/No"
|
||||
|
||||
Directory:
|
||||
|
||||
@@ -48,10 +47,10 @@ Directory:
|
||||
--- 2a93bc5fd...f823 Actor/Faction/etc. data
|
||||
--- 423bdc838...93bd Actor/Faction/etc. data
|
||||
--- Items_list.txt Human-readable
|
||||
--- Materials_list.txt Human-redable
|
||||
--- Materials_list.txt Human-readable
|
||||
--- Tiles_list.txt Human-readable
|
||||
--- world save meta (binary)
|
||||
--- worldinfo1 TEMD (binary)
|
||||
--- worldinfo2 tileprop
|
||||
--- worldinfo3 itemprop
|
||||
--- worldinfo4 materialprop
|
||||
--- world save meta (binary, GZip)
|
||||
--- worldinfo1 TEMD (binary, GZip)
|
||||
--- worldinfo2 tileprop (GZip)
|
||||
--- worldinfo3 itemprop (GZip)
|
||||
--- worldinfo4 materialprop (GZip)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.torvald.terrarum.console
|
||||
import com.torvald.colourutil.Col4096
|
||||
import com.torvald.RasterWriter
|
||||
import com.torvald.terrarum.Terrarum
|
||||
import com.torvald.terrarum.tileproperties.TileNameCode
|
||||
|
||||
import java.io.*
|
||||
import java.util.HashMap
|
||||
@@ -15,7 +16,7 @@ class ExportMap : ConsoleCommand {
|
||||
//private var mapData: ByteArray? = null
|
||||
// private var mapDataPointer = 0
|
||||
|
||||
private val colorTable = HashMap<Byte, Col4096>()
|
||||
private val colorTable = HashMap<Int, Col4096>()
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
@@ -24,8 +25,8 @@ class ExportMap : ConsoleCommand {
|
||||
var mapData = ByteArray(Terrarum.game.map.width * Terrarum.game.map.height * 3)
|
||||
var mapDataPointer = 0
|
||||
|
||||
for (tile in Terrarum.game.map.layerTerrain) {
|
||||
val colArray = (colorTable as Map<Byte, Col4096>)
|
||||
for (tile in Terrarum.game.map.terrainIterator()) {
|
||||
val colArray = (colorTable as Map<Int, Col4096>)
|
||||
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
|
||||
|
||||
for (i in 0..2) {
|
||||
@@ -71,222 +72,45 @@ class ExportMap : ConsoleCommand {
|
||||
}
|
||||
|
||||
private fun buildColorTable() {
|
||||
colorTable.put(AIR, Col4096(0xCEF))
|
||||
colorTable.put(STONE, Col4096(0x887))
|
||||
colorTable.put(DIRT, Col4096(0x763))
|
||||
colorTable.put(GRASS, Col4096(0x251))
|
||||
colorTable.put(TileNameCode.AIR, Col4096(0xCEF))
|
||||
colorTable.put(TileNameCode.STONE, Col4096(0x888))
|
||||
colorTable.put(TileNameCode.DIRT, Col4096(0x753))
|
||||
colorTable.put(TileNameCode.GRASS, Col4096(0x472))
|
||||
|
||||
colorTable.put(COPPER, Col4096(0x6A8))
|
||||
colorTable.put(IRON, Col4096(0xC75))
|
||||
colorTable.put(GOLD, Col4096(0xCB6))
|
||||
colorTable.put(ILMENITE, Col4096(0x8AB))
|
||||
colorTable.put(AURICHALCUM, Col4096(0xD92))
|
||||
colorTable.put(SILVER, Col4096(0xDDD))
|
||||
colorTable.put(TileNameCode.ORE_COPPER, Col4096(0x6A8))
|
||||
colorTable.put(TileNameCode.ORE_IRON, Col4096(0xC75))
|
||||
colorTable.put(TileNameCode.ORE_GOLD, Col4096(0xA87))
|
||||
colorTable.put(TileNameCode.ORE_ILMENITE, Col4096(0x8AB))
|
||||
colorTable.put(TileNameCode.ORE_AURICHALCUM, Col4096(0xD92))
|
||||
colorTable.put(TileNameCode.ORE_SILVER, Col4096(0xDDD))
|
||||
|
||||
colorTable.put(DIAMOND, Col4096(0x9CE))
|
||||
colorTable.put(RUBY, Col4096(0xB10))
|
||||
colorTable.put(EMERALD, Col4096(0x0B1))
|
||||
colorTable.put(SAPPHIRE, Col4096(0x01B))
|
||||
colorTable.put(TOPAZ, Col4096(0xC70))
|
||||
colorTable.put(AMETHYST, Col4096(0x70C))
|
||||
colorTable.put(TileNameCode.RAW_DIAMOND, Col4096(0x2BF))
|
||||
colorTable.put(TileNameCode.RAW_RUBY, Col4096(0xB10))
|
||||
colorTable.put(TileNameCode.RAW_EMERALD, Col4096(0x0B1))
|
||||
colorTable.put(TileNameCode.RAW_SAPPHIRE, Col4096(0x01B))
|
||||
colorTable.put(TileNameCode.RAW_TOPAZ, Col4096(0xC70))
|
||||
colorTable.put(TileNameCode.RAW_AMETHYST, Col4096(0x70C))
|
||||
|
||||
colorTable.put(WATER, Col4096(0x038))
|
||||
colorTable.put(LAVA, Col4096(0xF50))
|
||||
colorTable.put(TileNameCode.WATER, Col4096(0x038))
|
||||
colorTable.put(TileNameCode.LAVA, Col4096(0xF50))
|
||||
|
||||
colorTable.put(SAND, Col4096(0xDCA))
|
||||
colorTable.put(GRAVEL, Col4096(0x664))
|
||||
colorTable.put(TileNameCode.SAND, Col4096(0xDDB))
|
||||
colorTable.put(TileNameCode.SAND_WHITE, Col4096(0xFFD))
|
||||
colorTable.put(TileNameCode.SAND_RED, Col4096(0xA32))
|
||||
colorTable.put(TileNameCode.SAND_DESERT, Col4096(0xEDB))
|
||||
colorTable.put(TileNameCode.SAND_BLACK, Col4096(0x444))
|
||||
colorTable.put(TileNameCode.SAND_GREEN, Col4096(0x9A6))
|
||||
|
||||
colorTable.put(ICE_NATURAL, Col4096(0x9AB))
|
||||
colorTable.put(ICE_MAGICAL, Col4096(0x7AC))
|
||||
colorTable.put(ICE_FRAGILE, Col4096(0x6AF))
|
||||
colorTable.put(SNOW, Col4096(0xCDE))
|
||||
colorTable.put(TileNameCode.GRAVEL, Col4096(0x664))
|
||||
colorTable.put(TileNameCode.GRAVEL_GREY, Col4096(0x999))
|
||||
|
||||
colorTable.put(TileNameCode.ICE_NATURAL, Col4096(0x9AB))
|
||||
colorTable.put(TileNameCode.ICE_MAGICAL, Col4096(0x7AC))
|
||||
colorTable.put(TileNameCode.ICE_FRAGILE, Col4096(0x6AF))
|
||||
colorTable.put(TileNameCode.SNOW, Col4096(0xCDE))
|
||||
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val AIR: Byte = 0
|
||||
|
||||
private val STONE: Byte = 1
|
||||
private val DIRT: Byte = 2
|
||||
private val GRASS: Byte = 3
|
||||
|
||||
private val SAND: Byte = 13
|
||||
private val GRAVEL: Byte = 14
|
||||
|
||||
private val COPPER: Byte = 15
|
||||
private val IRON: Byte = 16
|
||||
private val GOLD: Byte = 17
|
||||
private val SILVER: Byte = 18
|
||||
private val ILMENITE: Byte = 19
|
||||
private val AURICHALCUM: Byte = 20
|
||||
|
||||
private val DIAMOND: Byte = 25
|
||||
private val RUBY: Byte = 21
|
||||
private val EMERALD: Byte = 22
|
||||
private val SAPPHIRE: Byte = 23
|
||||
private val TOPAZ: Byte = 24
|
||||
private val AMETHYST: Byte = 26
|
||||
|
||||
private val SNOW: Byte = 27
|
||||
private val ICE_FRAGILE: Byte = 28
|
||||
private val ICE_NATURAL: Byte = 29
|
||||
private val ICE_MAGICAL: Byte = 30
|
||||
|
||||
private val WATER = 239.toByte()
|
||||
private val LAVA = 255.toByte()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
package com.torvald.terrarum.console;
|
||||
|
||||
import com.torvald.colourutil.Col4096;
|
||||
import com.torvald.RasterWriter;
|
||||
import com.torvald.terrarum.terrarum;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-17.
|
||||
*/
|
||||
public class ExportMap implements console {
|
||||
|
||||
private byte[] mapData;
|
||||
private int mapDataPointer = 0;
|
||||
|
||||
private static final byte AIR = 0;
|
||||
|
||||
private static final byte STONE = 1;
|
||||
private static final byte DIRT = 2;
|
||||
private static final byte GRASS = 3;
|
||||
|
||||
private static final byte SAND = 13;
|
||||
private static final byte GRAVEL = 14;
|
||||
|
||||
private static final byte COPPER = 15;
|
||||
private static final byte IRON = 16;
|
||||
private static final byte GOLD = 17;
|
||||
private static final byte SILVER = 18;
|
||||
private static final byte ILMENITE = 19;
|
||||
private static final byte AURICHALCUM = 20;
|
||||
|
||||
private static final byte DIAMOND = 25;
|
||||
private static final byte RUBY = 21;
|
||||
private static final byte EMERALD = 22;
|
||||
private static final byte SAPPHIRE = 23;
|
||||
private static final byte TOPAZ = 24;
|
||||
private static final byte AMETHYST = 26;
|
||||
|
||||
private static final byte SNOW = 27;
|
||||
private static final byte ICE_FRAGILE = 28;
|
||||
private static final byte ICE_NATURAL = 29;
|
||||
private static final byte ICE_MAGICAL = 30;
|
||||
|
||||
private static final byte WATER = (byte) 239;
|
||||
private static final byte LAVA = (byte) 255;
|
||||
|
||||
private Hashtable<Byte, Col4096> colorTable = new Hashtable<>();
|
||||
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
if (args.length == 2) {
|
||||
buildColorTable();
|
||||
|
||||
mapData = new byte[terrarum.game.map.getWidth() * terrarum.game.map.getHeight() * 3];
|
||||
|
||||
for (byte tile : terrarum.game.map.getLayerTerrain()) {
|
||||
byte[] colArray = colorTable.getOrDefault(tile, new Col4096(0xFFF))
|
||||
.toByteArray();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
mapData[mapDataPointer + i] = colArray[i];
|
||||
}
|
||||
|
||||
mapDataPointer += 3;
|
||||
}
|
||||
|
||||
String dir = terrarum.defaultDir + "/Exports/";
|
||||
File dirAsFile = new File(dir);
|
||||
if (!dirAsFile.exists()) {
|
||||
dirAsFile.mkdir();
|
||||
}
|
||||
|
||||
try {
|
||||
RasterWriter.INSTANCE.writePNG_RGB(
|
||||
terrarum.game.map.getWidth()
|
||||
, terrarum.game.map.getHeight()
|
||||
, mapData
|
||||
, dir + args[1] + ".png"
|
||||
);
|
||||
new Echo().execute("ExportMap: exported to " + args[1] + ".png");
|
||||
|
||||
} catch (IOException e) {
|
||||
new Echo().execute("ExportMap: IOException raised.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mapData = null;
|
||||
mapDataPointer = 0;
|
||||
|
||||
// Free up some memory
|
||||
System.gc();
|
||||
}
|
||||
else{
|
||||
printUsage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printUsage() {
|
||||
Echo echo = new Echo();
|
||||
echo.execute("Usage: export <name>");
|
||||
echo.execute("Exports current map into visible image.");
|
||||
echo.execute("The image can be found at %adddata%/terrarum/Exports");
|
||||
}
|
||||
|
||||
private void buildColorTable() {
|
||||
colorTable.put(AIR, new Col4096(0xCEF));
|
||||
colorTable.put(STONE, new Col4096(0x887));
|
||||
colorTable.put(DIRT, new Col4096(0x763));
|
||||
colorTable.put(GRASS, new Col4096(0x251));
|
||||
|
||||
colorTable.put(COPPER, new Col4096(0x6A8));
|
||||
colorTable.put(IRON, new Col4096(0xC75));
|
||||
colorTable.put(GOLD, new Col4096(0xCB6));
|
||||
colorTable.put(ILMENITE, new Col4096(0x8AB));
|
||||
colorTable.put(AURICHALCUM, new Col4096(0xD92));
|
||||
colorTable.put(SILVER, new Col4096(0xDDD));
|
||||
|
||||
colorTable.put(DIAMOND, new Col4096(0x9CE));
|
||||
colorTable.put(RUBY, new Col4096(0xB10));
|
||||
colorTable.put(EMERALD, new Col4096(0x0B1));
|
||||
colorTable.put(SAPPHIRE, new Col4096(0x01B));
|
||||
colorTable.put(TOPAZ, new Col4096(0xC70));
|
||||
colorTable.put(AMETHYST, new Col4096(0x70C));
|
||||
|
||||
colorTable.put(WATER, new Col4096(0x038));
|
||||
colorTable.put(LAVA, new Col4096(0xF50));
|
||||
|
||||
colorTable.put(SAND, new Col4096(0xDCA));
|
||||
colorTable.put(GRAVEL, new Col4096(0x664));
|
||||
|
||||
colorTable.put(ICE_NATURAL, new Col4096(0x9AB));
|
||||
colorTable.put(ICE_MAGICAL, new Col4096(0x7AC));
|
||||
colorTable.put(ICE_FRAGILE, new Col4096(0x6AF));
|
||||
colorTable.put(SNOW, new Col4096(0xCDE));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -10,16 +10,10 @@ class Help : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
if (args.size == 1) {
|
||||
for (i in 1..6) echo.execute(Lang["HELP_OTF_TEXT_$i"])
|
||||
for (i in 1..6) echo.execute(Lang["HELP_OTF_MAIN_$i"])
|
||||
}
|
||||
else if (args[1].toLowerCase() == "slow") {
|
||||
if (Terrarum.game.screenZoom < 1)
|
||||
echo.execute(Lang["HELP_OTF_SLOW_IF_ZOOM"])
|
||||
|
||||
if (Terrarum.game.debugWindow.isVisible)
|
||||
echo.execute(Lang["HELP_OTF_SLOW_IF_F3"])
|
||||
|
||||
for (i in 1..1) echo.execute(Lang["HELP_OTF_SLOW_$i"])
|
||||
for (i in 1..4) echo.execute(Lang["HELP_OTF_SLOW_$i"])
|
||||
}
|
||||
else {
|
||||
for (i in 1..6) echo.execute(Lang["HELP_OTF_MAIN_$i"])
|
||||
|
||||
8
src/com/torvald/terrarum/mapgenerator/NoiseFilter.kt
Normal file
8
src/com/torvald/terrarum/mapgenerator/NoiseFilter.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.torvald.terrarum.mapgenerator
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-31.
|
||||
*/
|
||||
interface NoiseFilter {
|
||||
fun getGrad(func_argX: Int, start: Float, end: Float): Float
|
||||
}
|
||||
46
src/com/torvald/terrarum/mapgenerator/NoiseFilterCubic.kt
Normal file
46
src/com/torvald/terrarum/mapgenerator/NoiseFilterCubic.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.torvald.terrarum.mapgenerator
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
|
||||
/**
|
||||
* Double Quadratic polynomial
|
||||
* (16/9) * (start-end)/height^2 * (x-height)^2 + end
|
||||
* 16/9: terrain is formed from 1/4 of height.
|
||||
* 1 - (1/4) = 3/4, reverse it and square it.
|
||||
* That makes 16/9.
|
||||
|
||||
* Shape:
|
||||
|
||||
* cavity -
|
||||
* small
|
||||
* -
|
||||
* -
|
||||
* --
|
||||
* ----
|
||||
* cavity --------
|
||||
* large ----------------
|
||||
|
||||
* @param func_argX
|
||||
* *
|
||||
* @param start
|
||||
* *
|
||||
* @param end
|
||||
* *
|
||||
* @return
|
||||
* Created by minjaesong on 16-03-31.
|
||||
*/
|
||||
object NoiseFilterCubic : NoiseFilter {
|
||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||
val graph_gradient = -FastMath.pow(FastMath.pow((1 - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat(), 3f), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
||||
(start - end) / FastMath.pow(MapGenerator.HEIGHT.toFloat(), 3f) *
|
||||
FastMath.pow((func_argX - MapGenerator.HEIGHT).toFloat(), 3f) + end
|
||||
|
||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||
return start
|
||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
||||
return end
|
||||
} else {
|
||||
return graph_gradient
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.torvald.terrarum.mapgenerator
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
|
||||
/**
|
||||
* Quadratic polynomial
|
||||
* -(16/9) * (start-end)/height^2 * (x - 0.25 * height)^2 + start
|
||||
* 16/9: terrain is formed from 1/4 of height.
|
||||
* 1 - (1/4) = 3/4, reverse it and square it.
|
||||
* That makes 16/9.
|
||||
|
||||
* Shape:
|
||||
|
||||
* cavity _
|
||||
* small
|
||||
* _
|
||||
* _
|
||||
* __
|
||||
* ____
|
||||
* cavity ________
|
||||
* large ________________
|
||||
|
||||
* @param func_argX
|
||||
* *
|
||||
* @param start
|
||||
* *
|
||||
* @param end
|
||||
* *
|
||||
* @return
|
||||
* Created by minjaesong on 16-03-31.
|
||||
*/
|
||||
object NoiseFilterMinusQuadratic : NoiseFilter {
|
||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||
val graph_gradient = -FastMath.pow(FastMath.sqr((1 - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
||||
(start - end) / FastMath.sqr(MapGenerator.HEIGHT.toFloat()) *
|
||||
FastMath.sqr((func_argX - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
|
||||
|
||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||
return start
|
||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
||||
return end
|
||||
} else {
|
||||
return graph_gradient
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.torvald.terrarum.mapgenerator
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
|
||||
/**
|
||||
* Quadratic polynomial
|
||||
* (16/9) * (start-end)/height^2 * (x-height)^2 + end
|
||||
* 16/9: terrain is formed from 1/4 of height.
|
||||
* 1 - (1/4) = 3/4, reverse it and square it.
|
||||
* That makes 16/9.
|
||||
|
||||
* Shape:
|
||||
|
||||
* cavity -
|
||||
* small
|
||||
* -
|
||||
* -
|
||||
* --
|
||||
* ----
|
||||
* cavity --------
|
||||
* large ----------------
|
||||
|
||||
* @param func_argX
|
||||
* *
|
||||
* @param start
|
||||
* *
|
||||
* @param end
|
||||
* *
|
||||
* @return
|
||||
*
|
||||
* Created by minjaesong on 16-03-31.
|
||||
*/
|
||||
object NoiseFilterQuadratic : NoiseFilter {
|
||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||
val graph_gradient = FastMath.pow(FastMath.sqr((1 - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()), -1f) * // 1/4 -> 3/4 -> 9/16 -> 16/9
|
||||
(start - end) / FastMath.sqr(MapGenerator.HEIGHT.toFloat()) *
|
||||
FastMath.sqr((func_argX - MapGenerator.HEIGHT).toFloat()) + end
|
||||
|
||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||
return start
|
||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
||||
return end
|
||||
} else {
|
||||
return graph_gradient
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/com/torvald/terrarum/mapgenerator/NoiseFilterSqrt.kt
Normal file
20
src/com/torvald/terrarum/mapgenerator/NoiseFilterSqrt.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.torvald.terrarum.mapgenerator
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-31.
|
||||
*/
|
||||
object NoiseFilterSqrt : NoiseFilter {
|
||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||
val graph_gradient = (end - start) / FastMath.sqrt((MapGenerator.HEIGHT - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) * FastMath.sqrt((func_argX - MapGenerator.TERRAIN_AVERAGE_HEIGHT).toFloat()) + start
|
||||
|
||||
if (func_argX < MapGenerator.TERRAIN_AVERAGE_HEIGHT) {
|
||||
return start
|
||||
} else if (func_argX >= MapGenerator.HEIGHT) {
|
||||
return end
|
||||
} else {
|
||||
return graph_gradient
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/com/torvald/terrarum/mapgenerator/NoiseFilterUniform.kt
Normal file
10
src/com/torvald/terrarum/mapgenerator/NoiseFilterUniform.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.torvald.terrarum.mapgenerator
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-31.
|
||||
*/
|
||||
object NoiseFilterUniform : NoiseFilter {
|
||||
override fun getGrad(func_argX: Int, start: Float, end: Float): Float {
|
||||
return 1f
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class ConsoleWindow : UICanvas, UITypable {
|
||||
// text and cursor
|
||||
g.color = Color.white
|
||||
g.drawString(input, 1f + drawOffX, drawOffY)
|
||||
g.fillRect(inputDrawWidth.toFloat() + drawOffX, drawOffY, 2f, inputDrawHeight.toFloat())
|
||||
g.fillRect(inputDrawWidth.toFloat() + drawOffX + 1, drawOffY, 2f, inputDrawHeight.toFloat())
|
||||
|
||||
// messages
|
||||
for (i in 0..MESSAGES_DISPLAY_COUNT - 1) {
|
||||
|
||||
@@ -116,6 +116,6 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
||||
companion object {
|
||||
// private int messagesShowingIndex = 0;
|
||||
val MESSAGES_DISPLAY = 2
|
||||
val OPEN_CLOSE_TIME = 200
|
||||
val OPEN_CLOSE_TIME = 160
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user