more parallax tests
which yield nothing lulmao
This commit is contained in:
parent
f65a247511
commit
aeb14c9a63
@ -52,6 +52,7 @@ fun main() {
|
|||||||
val ent = PlayerEntity(client.world!!)
|
val ent = PlayerEntity(client.world!!)
|
||||||
|
|
||||||
Starbound.onInitialize {
|
Starbound.onInitialize {
|
||||||
|
client.world!!.parallax = Starbound.parallaxAccess["barren"]
|
||||||
chunkA = client.world!!.computeIfAbsent(ChunkPos(0, 0)).chunk
|
chunkA = client.world!!.computeIfAbsent(ChunkPos(0, 0)).chunk
|
||||||
val chunkB = client.world!!.computeIfAbsent(ChunkPos(-1, 0)).chunk
|
val chunkB = client.world!!.computeIfAbsent(ChunkPos(-1, 0)).chunk
|
||||||
val chunkC = client.world!!.computeIfAbsent(ChunkPos(-2, 0)).chunk
|
val chunkC = client.world!!.computeIfAbsent(ChunkPos(-2, 0)).chunk
|
||||||
|
@ -39,12 +39,12 @@ object Starbound : IVFS {
|
|||||||
|
|
||||||
private val tiles = HashMap<String, TileDefinition>()
|
private val tiles = HashMap<String, TileDefinition>()
|
||||||
private val projectiles = HashMap<String, ConfiguredProjectile>()
|
private val projectiles = HashMap<String, ConfiguredProjectile>()
|
||||||
private val parallax = HashMap<String, Parallax>()
|
private val parallax = HashMap<String, ParallaxPrototype>()
|
||||||
private val functions = HashMap<String, JsonFunction>()
|
private val functions = HashMap<String, JsonFunction>()
|
||||||
|
|
||||||
val tilesAccess: Map<String, TileDefinition> = Collections.unmodifiableMap(tiles)
|
val tilesAccess: Map<String, TileDefinition> = Collections.unmodifiableMap(tiles)
|
||||||
val projectilesAccess: Map<String, ConfiguredProjectile> = Collections.unmodifiableMap(projectiles)
|
val projectilesAccess: Map<String, ConfiguredProjectile> = Collections.unmodifiableMap(projectiles)
|
||||||
val parallaxAccess: Map<String, Parallax> = Collections.unmodifiableMap(parallax)
|
val parallaxAccess: Map<String, ParallaxPrototype> = Collections.unmodifiableMap(parallax)
|
||||||
val functionsAccess: Map<String, JsonFunction> = Collections.unmodifiableMap(functions)
|
val functionsAccess: Map<String, JsonFunction> = Collections.unmodifiableMap(functions)
|
||||||
|
|
||||||
val gson: Gson = GsonBuilder()
|
val gson: Gson = GsonBuilder()
|
||||||
@ -66,7 +66,7 @@ object Starbound : IVFS {
|
|||||||
.also(ConfigurableProjectile::registerGson)
|
.also(ConfigurableProjectile::registerGson)
|
||||||
.also(SkyParameters::registerGson)
|
.also(SkyParameters::registerGson)
|
||||||
.also(DungeonWorldDef::registerGson)
|
.also(DungeonWorldDef::registerGson)
|
||||||
.also(Parallax::registerGson)
|
.also(ParallaxPrototype::registerGson)
|
||||||
.also(JsonFunction::registerGson)
|
.also(JsonFunction::registerGson)
|
||||||
|
|
||||||
.registerTypeAdapter(DamageType::class.java, CustomEnumTypeAdapter(DamageType.values()).nullSafe())
|
.registerTypeAdapter(DamageType::class.java, CustomEnumTypeAdapter(DamageType.values()).nullSafe())
|
||||||
@ -284,7 +284,7 @@ object Starbound : IVFS {
|
|||||||
try {
|
try {
|
||||||
callback("Loading $listedFile")
|
callback("Loading $listedFile")
|
||||||
|
|
||||||
val def = gson.fromJson(getReader(listedFile), Parallax::class.java)
|
val def = gson.fromJson(getReader(listedFile), ParallaxPrototype::class.java)
|
||||||
parallax[getPathFilename(listedFile).substringBefore('.')] = def
|
parallax[getPathFilename(listedFile).substringBefore('.')] = def
|
||||||
} catch(err: Throwable) {
|
} catch(err: Throwable) {
|
||||||
LOGGER.error("Loading parallax file $listedFile", err)
|
LOGGER.error("Loading parallax file $listedFile", err)
|
||||||
|
@ -4,7 +4,7 @@ import org.lwjgl.opengl.GL46.*
|
|||||||
import ru.dbotthepony.kstarbound.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.PIXELS_IN_STARBOUND_UNITf
|
||||||
import ru.dbotthepony.kstarbound.client.gl.VertexTransformers
|
import ru.dbotthepony.kstarbound.client.gl.VertexTransformers
|
||||||
import ru.dbotthepony.kstarbound.client.render.renderLayeredList
|
import ru.dbotthepony.kstarbound.client.render.renderLayeredList
|
||||||
import ru.dbotthepony.kstarbound.defs.Parallax
|
import ru.dbotthepony.kstarbound.defs.ParallaxPrototype
|
||||||
import ru.dbotthepony.kstarbound.math.encasingChunkPosAABB
|
import ru.dbotthepony.kstarbound.math.encasingChunkPosAABB
|
||||||
import ru.dbotthepony.kstarbound.world.*
|
import ru.dbotthepony.kstarbound.world.*
|
||||||
import ru.dbotthepony.kstarbound.world.entities.Entity
|
import ru.dbotthepony.kstarbound.world.entities.Entity
|
||||||
@ -46,7 +46,7 @@ class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World<ClientWo
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var parallax: Parallax? = null
|
var parallax: ParallaxPrototype? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Отрисовывает этот с обрезкой невидимой геометрии с точки зрения [size] в Starbound Units
|
* Отрисовывает этот с обрезкой невидимой геометрии с точки зрения [size] в Starbound Units
|
||||||
@ -75,7 +75,7 @@ class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World<ClientWo
|
|||||||
|
|
||||||
for (layer in parallax.layers) {
|
for (layer in parallax.layers) {
|
||||||
client.gl.matrixStack.push()
|
client.gl.matrixStack.push()
|
||||||
client.gl.matrixStack.translateWithMultiplication(x = layer.offset.x.toFloat() / PIXELS_IN_STARBOUND_UNITf, y = layer.offset.y.toFloat() / PIXELS_IN_STARBOUND_UNITf)
|
client.gl.matrixStack.translateWithMultiplication(x = layer.offset.x.toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f, y = layer.offset.y.toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f)
|
||||||
|
|
||||||
client.gl.shaderVertexTexture.transform.set(client.gl.matrixStack.last)
|
client.gl.shaderVertexTexture.transform.set(client.gl.matrixStack.last)
|
||||||
|
|
||||||
@ -88,16 +88,16 @@ class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World<ClientWo
|
|||||||
builder.begin()
|
builder.begin()
|
||||||
|
|
||||||
for (xPos in DoubleEdgeProgression()) {
|
for (xPos in DoubleEdgeProgression()) {
|
||||||
var x0 = xPos.toFloat() * texture.width / PIXELS_IN_STARBOUND_UNITf
|
var x0 = xPos.toFloat() * texture.width / PIXELS_IN_STARBOUND_UNITf / 16f
|
||||||
var x1 = (xPos + 1f) * texture.width / PIXELS_IN_STARBOUND_UNITf
|
var x1 = (xPos + 1f) * texture.width / PIXELS_IN_STARBOUND_UNITf / 16f
|
||||||
|
|
||||||
val diffx = layer.parallax.x * centre.x - centre.x
|
val diffx = layer.parallax.x * centre.x - centre.x
|
||||||
val diffy = (layer.parallax.y * (centre.y + 20.0) - centre.y - 20.0).toFloat() / PIXELS_IN_STARBOUND_UNITf
|
val diffy = (layer.parallax.y * (centre.y + 20.0) - centre.y - 20.0).toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f
|
||||||
|
|
||||||
x0 += diffx.toFloat() / PIXELS_IN_STARBOUND_UNITf
|
x0 += diffx.toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f
|
||||||
x1 += diffx.toFloat() / PIXELS_IN_STARBOUND_UNITf
|
x1 += diffx.toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f
|
||||||
|
|
||||||
builder.quadZ(x0, diffy, x1, diffy + texture.height.toFloat() / PIXELS_IN_STARBOUND_UNITf, 1f, VertexTransformers.uv(0f, 1f, 1f, 0f))
|
builder.quadZ(x0, diffy, x1, diffy + texture.height.toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f, 1f, VertexTransformers.uv(0f, 1f, 1f, 0f))
|
||||||
|
|
||||||
/*if (x1 < size.mins.x) {
|
/*if (x1 < size.mins.x) {
|
||||||
break
|
break
|
||||||
|
@ -117,7 +117,7 @@ class StarboundClient : AutoCloseable {
|
|||||||
GLFW.glfwMakeContextCurrent(window)
|
GLFW.glfwMakeContextCurrent(window)
|
||||||
|
|
||||||
// vsync
|
// vsync
|
||||||
GLFW.glfwSwapInterval(1)
|
GLFW.glfwSwapInterval(0)
|
||||||
|
|
||||||
GLFW.glfwShowWindow(window)
|
GLFW.glfwShowWindow(window)
|
||||||
putDebugLog("Initialized GLFW window")
|
putDebugLog("Initialized GLFW window")
|
||||||
|
@ -10,26 +10,26 @@ import ru.dbotthepony.kstarbound.io.KTypeAdapter
|
|||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
class Parallax {
|
class ParallaxPrototype {
|
||||||
var verticalOrigin = 0.0
|
var verticalOrigin = 0.0
|
||||||
|
|
||||||
var layers = Array(0) { ParallaxLayer() }
|
var layers = Array(0) { ParallaxPrototypeLayer() }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::Parallax,
|
val ADAPTER = KTypeAdapter(::ParallaxPrototype,
|
||||||
Parallax::verticalOrigin,
|
ParallaxPrototype::verticalOrigin,
|
||||||
Parallax::layers,
|
ParallaxPrototype::layers,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun registerGson(gsonBuilder: GsonBuilder) {
|
fun registerGson(gsonBuilder: GsonBuilder) {
|
||||||
gsonBuilder.registerTypeAdapter(Parallax::class.java, ADAPTER)
|
gsonBuilder.registerTypeAdapter(ParallaxPrototype::class.java, ADAPTER)
|
||||||
gsonBuilder.registerTypeAdapter(ParallaxLayer::class.java, ParallaxLayer.ADAPTER)
|
gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer::class.java, ParallaxPrototypeLayer.ADAPTER)
|
||||||
gsonBuilder.registerTypeAdapter(ParallaxLayer.Parallax::class.java, ParallaxLayer.LAYER_PARALLAX_ADAPTER)
|
gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer.Parallax::class.java, ParallaxPrototypeLayer.LAYER_PARALLAX_ADAPTER)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParallaxLayer {
|
class ParallaxPrototypeLayer {
|
||||||
class Parallax(val x: Double, val y: Double)
|
class Parallax(val x: Double, val y: Double)
|
||||||
|
|
||||||
var timeOfDayCorrelation: String? = null
|
var timeOfDayCorrelation: String? = null
|
||||||
@ -80,24 +80,24 @@ class ParallaxLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val ADAPTER = KTypeAdapter(::ParallaxLayer,
|
val ADAPTER = KTypeAdapter(::ParallaxPrototypeLayer,
|
||||||
ParallaxLayer::timeOfDayCorrelation,
|
ParallaxPrototypeLayer::timeOfDayCorrelation,
|
||||||
ParallaxLayer::offset,
|
ParallaxPrototypeLayer::offset,
|
||||||
ParallaxLayer::repeatY,
|
ParallaxPrototypeLayer::repeatY,
|
||||||
ParallaxLayer::lightMapped,
|
ParallaxPrototypeLayer::lightMapped,
|
||||||
ParallaxLayer::tileLimitTop,
|
ParallaxPrototypeLayer::tileLimitTop,
|
||||||
ParallaxLayer::parallax,
|
ParallaxPrototypeLayer::parallax,
|
||||||
ParallaxLayer::unlit,
|
ParallaxPrototypeLayer::unlit,
|
||||||
ParallaxLayer::nohueshift,
|
ParallaxPrototypeLayer::nohueshift,
|
||||||
ParallaxLayer::minSpeed,
|
ParallaxPrototypeLayer::minSpeed,
|
||||||
ParallaxLayer::maxSpeed,
|
ParallaxPrototypeLayer::maxSpeed,
|
||||||
ParallaxLayer::fadePercent,
|
ParallaxPrototypeLayer::fadePercent,
|
||||||
ParallaxLayer::kind,
|
ParallaxPrototypeLayer::kind,
|
||||||
ParallaxLayer::baseCount,
|
ParallaxPrototypeLayer::baseCount,
|
||||||
ParallaxLayer::noRandomOffset,
|
ParallaxPrototypeLayer::noRandomOffset,
|
||||||
ParallaxLayer::directives,
|
ParallaxPrototypeLayer::directives,
|
||||||
ParallaxLayer::frequency,
|
ParallaxPrototypeLayer::frequency,
|
||||||
ParallaxLayer::modCount,
|
ParallaxPrototypeLayer::modCount,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user