mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
new worldgen test wip
This commit is contained in:
@@ -169,9 +169,9 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
(this.hitbox.endX >= WorldCamera.x && this.hitbox.startX <= WorldCamera.xEnd))
|
||||
|
||||
val SIZE_SMALL = Point2i(CHUNK_W*66, CHUNK_H*60)
|
||||
val SIZE_NORMAL = Point2i(CHUNK_W*100, CHUNK_H*64)
|
||||
val SIZE_LARGE = Point2i(CHUNK_W*150, CHUNK_H*66)
|
||||
val SIZE_HUGE = Point2i(CHUNK_W*250, CHUNK_H*70)
|
||||
val SIZE_NORMAL = Point2i(CHUNK_W*100, CHUNK_H*60)
|
||||
val SIZE_LARGE = Point2i(CHUNK_W*150, CHUNK_H*60)
|
||||
val SIZE_HUGE = Point2i(CHUNK_W*250, CHUNK_H*60)
|
||||
val NEW_WORLD_SIZE = arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
|
||||
val WORLDPORTAL_NEW_WORLD_SIZE = arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ interface TerragenParams {
|
||||
}
|
||||
|
||||
data class TerragenParamsAlpha1(
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.0, 2.5),
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.0, 2.5, 11.0),
|
||||
|
||||
override val featureSize: Double = 333.0,
|
||||
override val lowlandScaleOffset: Double = -0.65, // linearly alters the height
|
||||
@@ -277,12 +277,10 @@ data class TerragenParamsAlpha1(
|
||||
override val caveBlockageSelectThre: Double = 1.40, // adjust cave closing-up strength. Lower = more closing
|
||||
|
||||
override val rockBandCutoffFreq: Double = 4.0,
|
||||
|
||||
|
||||
) : TerragenParams
|
||||
|
||||
data class TerragenParamsAlpha2(
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.5, 3.75),
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.5, 3.75, 11.0),
|
||||
|
||||
override val featureSize: Double = 333.0,
|
||||
override val lowlandScaleOffset: Double = -0.65, // linearly alters the height
|
||||
|
||||
@@ -21,9 +21,7 @@ import com.sudoplay.joise.module.*
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.concurrent.RunnableFun
|
||||
import net.torvald.terrarum.concurrent.ThreadExecutor
|
||||
import net.torvald.terrarum.concurrent.sliceEvenly
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.*
|
||||
import net.torvald.terrarum.worlddrawer.toRGBA
|
||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||
@@ -34,11 +32,14 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.Worldgen.YHEIGHT_DIVIS
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.Worldgen.YHEIGHT_MAGIC
|
||||
import java.io.PrintStream
|
||||
import java.util.Calendar
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
const val NOISEBOX_WIDTH = 1600
|
||||
const val NOISEBOX_HEIGHT = 2400
|
||||
const val NOISEBOX_WIDTH = 90 * 18
|
||||
const val NOISEBOX_HEIGHT = 90 * 26
|
||||
const val TWO_PI = Math.PI * 2
|
||||
|
||||
const val WORLDGEN_YOFF = 5400 - NOISEBOX_HEIGHT
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-07-23.
|
||||
*/
|
||||
@@ -204,28 +205,29 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
||||
worldgenDone = false
|
||||
|
||||
Thread {
|
||||
val runnables: List<RunnableFun> = (0 until testTex.width).sliceEvenly(genSlices).map { range ->
|
||||
{
|
||||
val callables = ArrayList<Callable<Unit>>()
|
||||
|
||||
for (cy in 0 until NOISEBOX_HEIGHT / 90) { for (cx in 0 until NOISEBOX_WIDTH / 90) {
|
||||
val localJoise = noiseMaker.getGenerator(seed, 0)
|
||||
for (x in range) {
|
||||
for (y in 0 until NOISEBOX_HEIGHT) {
|
||||
callables.add(Callable { for (x in cx * 90 until (cx + 1) * 90) {
|
||||
for (y in cy * 90 until (cy + 1) * 90) {
|
||||
val sampleTheta = (x.toDouble() / NOISEBOX_WIDTH) * TWO_PI
|
||||
val sampleX =
|
||||
sin(sampleTheta) * sampleOffset + sampleOffset // plus sampleOffset to make only
|
||||
val sampleZ =
|
||||
cos(sampleTheta) * sampleOffset + sampleOffset // positive points are to be sampled
|
||||
val sampleY = getSY(y) //+ 10000
|
||||
val sampleY = getSY(y) + WORLDGEN_YOFF
|
||||
|
||||
noiseMaker.draw(x, y, localJoise.mapIndexed { index, it ->
|
||||
it.get(sampleX, sampleY, sampleZ)
|
||||
noiseMaker.draw(x, y, localJoise.mapIndexed { index, joise ->
|
||||
joise.get(sampleX, sampleY, sampleZ)
|
||||
}, testTex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} })
|
||||
} }
|
||||
|
||||
|
||||
threadExecutor.renew()
|
||||
runnables.forEach {
|
||||
callables.forEach {
|
||||
threadExecutor.submit(it)
|
||||
}
|
||||
|
||||
@@ -350,9 +352,12 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker {
|
||||
Color(0.97f, 0.6f, 0.56f, 1f)
|
||||
)
|
||||
|
||||
private val groundDepthBlock = listOf(
|
||||
Block.AIR, Block.DIRT, Block.STONE, Block.STONE_SLATE
|
||||
private val groundDepthBlockWall = listOf(
|
||||
Block.AIR, Block.DIRT, Block.STONE, Block.STONE_SLATE, Block.STONE_SLATE
|
||||
)
|
||||
private val groundDepthBlockTERR = ArrayList(groundDepthBlockWall).also {
|
||||
it[it.lastIndex] = Block.AIR
|
||||
}
|
||||
|
||||
private fun Double.tiered(tiers: List<Double>): Int {
|
||||
tiers.reversed().forEachIndexed { index, it ->
|
||||
@@ -398,8 +403,8 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker {
|
||||
|
||||
val isMarble = false // noiseValue[13] > 0.5
|
||||
|
||||
val wallBlock = if (isMarble) Block.STONE_MARBLE else groundDepthBlock[terr]
|
||||
val terrBlock = if (cave == 0) Block.AIR else if (isMarble) Block.STONE_MARBLE else wallBlock
|
||||
val wallBlock = if (isMarble) Block.STONE_MARBLE else groundDepthBlockWall[terr]
|
||||
val terrBlock = if (cave == 0) Block.AIR else if (isMarble) Block.STONE_MARBLE else groundDepthBlockTERR[terr]
|
||||
|
||||
|
||||
outTex.drawPixel(x, y,
|
||||
|
||||
Reference in New Issue
Block a user