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!!)
|
||||
|
||||
Starbound.onInitialize {
|
||||
client.world!!.parallax = Starbound.parallaxAccess["barren"]
|
||||
chunkA = client.world!!.computeIfAbsent(ChunkPos(0, 0)).chunk
|
||||
val chunkB = client.world!!.computeIfAbsent(ChunkPos(-1, 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 projectiles = HashMap<String, ConfiguredProjectile>()
|
||||
private val parallax = HashMap<String, Parallax>()
|
||||
private val parallax = HashMap<String, ParallaxPrototype>()
|
||||
private val functions = HashMap<String, JsonFunction>()
|
||||
|
||||
val tilesAccess: Map<String, TileDefinition> = Collections.unmodifiableMap(tiles)
|
||||
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 gson: Gson = GsonBuilder()
|
||||
@ -66,7 +66,7 @@ object Starbound : IVFS {
|
||||
.also(ConfigurableProjectile::registerGson)
|
||||
.also(SkyParameters::registerGson)
|
||||
.also(DungeonWorldDef::registerGson)
|
||||
.also(Parallax::registerGson)
|
||||
.also(ParallaxPrototype::registerGson)
|
||||
.also(JsonFunction::registerGson)
|
||||
|
||||
.registerTypeAdapter(DamageType::class.java, CustomEnumTypeAdapter(DamageType.values()).nullSafe())
|
||||
@ -284,7 +284,7 @@ object Starbound : IVFS {
|
||||
try {
|
||||
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
|
||||
} catch(err: Throwable) {
|
||||
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.client.gl.VertexTransformers
|
||||
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.world.*
|
||||
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
|
||||
@ -75,7 +75,7 @@ class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World<ClientWo
|
||||
|
||||
for (layer in parallax.layers) {
|
||||
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)
|
||||
|
||||
@ -88,16 +88,16 @@ class ClientWorld(val client: StarboundClient, seed: Long = 0L) : World<ClientWo
|
||||
builder.begin()
|
||||
|
||||
for (xPos in DoubleEdgeProgression()) {
|
||||
var x0 = xPos.toFloat() * texture.width / PIXELS_IN_STARBOUND_UNITf
|
||||
var x1 = (xPos + 1f) * 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 / 16f
|
||||
|
||||
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
|
||||
x1 += diffx.toFloat() / PIXELS_IN_STARBOUND_UNITf
|
||||
x0 += diffx.toFloat() / PIXELS_IN_STARBOUND_UNITf / 16f
|
||||
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) {
|
||||
break
|
||||
|
@ -117,7 +117,7 @@ class StarboundClient : AutoCloseable {
|
||||
GLFW.glfwMakeContextCurrent(window)
|
||||
|
||||
// vsync
|
||||
GLFW.glfwSwapInterval(1)
|
||||
GLFW.glfwSwapInterval(0)
|
||||
|
||||
GLFW.glfwShowWindow(window)
|
||||
putDebugLog("Initialized GLFW window")
|
||||
|
@ -10,26 +10,26 @@ import ru.dbotthepony.kstarbound.io.KTypeAdapter
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class Parallax {
|
||||
class ParallaxPrototype {
|
||||
var verticalOrigin = 0.0
|
||||
|
||||
var layers = Array(0) { ParallaxLayer() }
|
||||
var layers = Array(0) { ParallaxPrototypeLayer() }
|
||||
|
||||
companion object {
|
||||
val ADAPTER = KTypeAdapter(::Parallax,
|
||||
Parallax::verticalOrigin,
|
||||
Parallax::layers,
|
||||
val ADAPTER = KTypeAdapter(::ParallaxPrototype,
|
||||
ParallaxPrototype::verticalOrigin,
|
||||
ParallaxPrototype::layers,
|
||||
)
|
||||
|
||||
fun registerGson(gsonBuilder: GsonBuilder) {
|
||||
gsonBuilder.registerTypeAdapter(Parallax::class.java, ADAPTER)
|
||||
gsonBuilder.registerTypeAdapter(ParallaxLayer::class.java, ParallaxLayer.ADAPTER)
|
||||
gsonBuilder.registerTypeAdapter(ParallaxLayer.Parallax::class.java, ParallaxLayer.LAYER_PARALLAX_ADAPTER)
|
||||
gsonBuilder.registerTypeAdapter(ParallaxPrototype::class.java, ADAPTER)
|
||||
gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer::class.java, ParallaxPrototypeLayer.ADAPTER)
|
||||
gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer.Parallax::class.java, ParallaxPrototypeLayer.LAYER_PARALLAX_ADAPTER)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ParallaxLayer {
|
||||
class ParallaxPrototypeLayer {
|
||||
class Parallax(val x: Double, val y: Double)
|
||||
|
||||
var timeOfDayCorrelation: String? = null
|
||||
@ -80,24 +80,24 @@ class ParallaxLayer {
|
||||
}
|
||||
}
|
||||
|
||||
val ADAPTER = KTypeAdapter(::ParallaxLayer,
|
||||
ParallaxLayer::timeOfDayCorrelation,
|
||||
ParallaxLayer::offset,
|
||||
ParallaxLayer::repeatY,
|
||||
ParallaxLayer::lightMapped,
|
||||
ParallaxLayer::tileLimitTop,
|
||||
ParallaxLayer::parallax,
|
||||
ParallaxLayer::unlit,
|
||||
ParallaxLayer::nohueshift,
|
||||
ParallaxLayer::minSpeed,
|
||||
ParallaxLayer::maxSpeed,
|
||||
ParallaxLayer::fadePercent,
|
||||
ParallaxLayer::kind,
|
||||
ParallaxLayer::baseCount,
|
||||
ParallaxLayer::noRandomOffset,
|
||||
ParallaxLayer::directives,
|
||||
ParallaxLayer::frequency,
|
||||
ParallaxLayer::modCount,
|
||||
val ADAPTER = KTypeAdapter(::ParallaxPrototypeLayer,
|
||||
ParallaxPrototypeLayer::timeOfDayCorrelation,
|
||||
ParallaxPrototypeLayer::offset,
|
||||
ParallaxPrototypeLayer::repeatY,
|
||||
ParallaxPrototypeLayer::lightMapped,
|
||||
ParallaxPrototypeLayer::tileLimitTop,
|
||||
ParallaxPrototypeLayer::parallax,
|
||||
ParallaxPrototypeLayer::unlit,
|
||||
ParallaxPrototypeLayer::nohueshift,
|
||||
ParallaxPrototypeLayer::minSpeed,
|
||||
ParallaxPrototypeLayer::maxSpeed,
|
||||
ParallaxPrototypeLayer::fadePercent,
|
||||
ParallaxPrototypeLayer::kind,
|
||||
ParallaxPrototypeLayer::baseCount,
|
||||
ParallaxPrototypeLayer::noRandomOffset,
|
||||
ParallaxPrototypeLayer::directives,
|
||||
ParallaxPrototypeLayer::frequency,
|
||||
ParallaxPrototypeLayer::modCount,
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user