mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
rendering: fix some problems regarding logs not being displayed correctly
This commit is contained in:
parent
c39ad18715
commit
fda95f1d6e
@ -19,14 +19,5 @@ enum class Axes {
|
||||
|
||||
companion object {
|
||||
val AXES = values()
|
||||
|
||||
fun byName(name: String): Axes {
|
||||
for (axis in values()) {
|
||||
if (axis.name == name.toUpperCase()) {
|
||||
return axis
|
||||
}
|
||||
}
|
||||
throw IllegalArgumentException("Unexpected value: $name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ open class BlockModel(val parent: BlockModel? = null, json: JsonObject) {
|
||||
|
||||
open fun render(position: InChunkSectionLocation, data: MutableList<Float>, neighbourBlocks: Array<Block?>) {
|
||||
val modelMatrix = Mat4().translate(Vec3(position.x, position.y, position.z))
|
||||
.rotate(rotation.x, Vec3(-1, 0, 0))
|
||||
.rotate(rotation.y, Vec3(0, -1, 0))
|
||||
.rotate(rotation.z, Vec3(0, 0, -1))
|
||||
.rotate(rotation.y, Vec3(0, -1, 0))
|
||||
.rotate(rotation.x, Vec3(-1, 0, 0))
|
||||
// ToDo: this should be made easier/more efficient
|
||||
|
||||
for (direction in Directions.DIRECTIONS) {
|
||||
|
@ -82,7 +82,7 @@ open class BlockModelElement(data: JsonObject) {
|
||||
)
|
||||
data["rotation"]?.let {
|
||||
val rotation = it.asJsonObject
|
||||
rotate(Axes.byName(rotation["axis"].asString), glm.radians(rotation["angle"].asDouble), jsonArrayToVec3(rotation["origin"].asJsonArray))
|
||||
rotate(Axes.valueOf(rotation["axis"].asString.toUpperCase()), glm.radians(rotation["angle"].asDouble), jsonArrayToVec3(rotation["origin"].asJsonArray))
|
||||
}
|
||||
for ((i, position) in positions.withIndex()) {
|
||||
positions[i] = BlockModel.transformPosition(position)
|
||||
@ -123,13 +123,12 @@ open class BlockModelElement(data: JsonObject) {
|
||||
if (rotation == Vec3(0, 0, 0)) {
|
||||
return direction
|
||||
}
|
||||
var rotatedDirectionVector = rotateVector(direction.directionVector, rotation.x.toDouble(), Axes.X)
|
||||
var rotatedDirectionVector = rotateVector(direction.directionVector, rotation.z.toDouble(), Axes.Z)
|
||||
rotatedDirectionVector = rotateVector(rotatedDirectionVector, rotation.y.toDouble(), Axes.Y)
|
||||
return Directions.byDirection(rotateVector(rotatedDirectionVector, rotation.z.toDouble(), Axes.Z))
|
||||
return Directions.byDirection(rotateVector(rotatedDirectionVector, rotation.x.toDouble(), Axes.X))
|
||||
}
|
||||
val realDirection = getRotatedDirection()
|
||||
val positionTemplate = FACE_POSITION_MAP_TEMPLATE[realDirection.ordinal]
|
||||
val drawPositions = arrayOf(positions[positionTemplate[0]], positions[positionTemplate[1]], positions[positionTemplate[2]], positions[positionTemplate[3]])
|
||||
|
||||
val face = faces[realDirection] ?: return // Not our face
|
||||
val texture = textureMapping[face.textureName] ?: TextureArray.DEBUG_TEXTURE
|
||||
@ -137,6 +136,8 @@ open class BlockModelElement(data: JsonObject) {
|
||||
return
|
||||
}
|
||||
|
||||
val drawPositions = arrayOf(positions[positionTemplate[0]], positions[positionTemplate[1]], positions[positionTemplate[2]], positions[positionTemplate[3]])
|
||||
|
||||
fun addToData(vec3: Vec3, textureCoordinates: Vec2) {
|
||||
val input = Vec4(vec3, 1.0f)
|
||||
val output = modelMatrix * input
|
||||
@ -180,6 +181,6 @@ open class BlockModelElement(data: JsonObject) {
|
||||
return Vec3(array[0].asFloat, array[1].asFloat, array[2].asFloat)
|
||||
}
|
||||
|
||||
val FACE_POSITION_MAP_TEMPLATE = arrayOf(intArrayOf(2, 3, 1, 0), intArrayOf(4, 5, 7, 6), intArrayOf(1, 5, 4, 0), intArrayOf(2, 6, 7, 3), intArrayOf(6, 2, 0, 4), intArrayOf(5, 1, 3, 7))
|
||||
val FACE_POSITION_MAP_TEMPLATE = arrayOf(intArrayOf(0, 2, 3, 1), intArrayOf(6, 4, 5, 7), intArrayOf(1, 5, 4, 0), intArrayOf(2, 6, 7, 3), intArrayOf(6, 2, 0, 4), intArrayOf(5, 1, 3, 7))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user