mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
rendering: tint textures green
This commit is contained in:
parent
01012582bf
commit
26acc93742
@ -86,7 +86,7 @@ class ChunkRenderer(private val connection: Connection, private val world: World
|
||||
}
|
||||
val worldPosition = Vec3(position.x + chunkLocation.x * ProtocolDefinition.SECTION_WIDTH_X, position.y + sectionHeight * ProtocolDefinition.SECTION_HEIGHT_Y, position.z + chunkLocation.z * ProtocolDefinition.SECTION_WIDTH_Z)
|
||||
|
||||
blockInfo.block.getBlockRenderer(BlockPosition(chunkLocation, sectionHeight, position)).render(blockInfo, worldPosition, arrayOf(blockBelow, blockAbove, blockNorth, blockSouth, blockWest, blockEast))
|
||||
blockInfo.block.getBlockRenderer(BlockPosition(chunkLocation, sectionHeight, position)).render(blockInfo, worldPosition, data, arrayOf(blockBelow, blockAbove, blockNorth, blockSouth, blockWest, blockEast))
|
||||
}
|
||||
return data.toFloatArray()
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ package de.bixilon.minosoft.gui.rendering.chunk.models.renderable
|
||||
import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.Directions
|
||||
import de.bixilon.minosoft.data.mappings.ModIdentifier
|
||||
import de.bixilon.minosoft.data.mappings.blocks.Block
|
||||
import de.bixilon.minosoft.data.mappings.versions.VersionMapping
|
||||
import de.bixilon.minosoft.data.world.BlockInfo
|
||||
import de.bixilon.minosoft.gui.rendering.textures.Texture
|
||||
import glm_.mat4x4.Mat4
|
||||
import glm_.vec3.Vec3
|
||||
@ -79,7 +79,7 @@ class BlockRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
fun render(position: Vec3, data: MutableList<Float>, neighbourBlocks: Array<Block?>) {
|
||||
fun render(blockInfo: BlockInfo, position: Vec3, data: MutableList<Float>, neighbourBlocks: Array<BlockInfo?>) {
|
||||
val modelMatrix = Mat4().translate(position)
|
||||
|
||||
for (direction in Directions.DIRECTIONS) {
|
||||
@ -87,10 +87,10 @@ class BlockRenderer {
|
||||
val cullFace = cullFaces.contains(direction)
|
||||
|
||||
var neighbourBlockFullFace = false
|
||||
neighbourBlocks[direction.ordinal]?.blockRenderers?.let { // ToDo: Improve this
|
||||
neighbourBlocks[direction.ordinal]?.block?.blockRenderers?.let { // ToDo: Improve this
|
||||
val testDirection = direction.inverse()
|
||||
for (model in it) {
|
||||
if (model.fullFaceDirections.contains(testDirection) && ! model.transparentFaces.contains(testDirection)) {
|
||||
if (model.fullFaceDirections.contains(testDirection) && !model.transparentFaces.contains(testDirection)) {
|
||||
neighbourBlockFullFace = true
|
||||
break
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.data.Axes
|
||||
import de.bixilon.minosoft.data.Directions
|
||||
import de.bixilon.minosoft.data.mappings.ModIdentifier
|
||||
import de.bixilon.minosoft.data.mappings.versions.VersionMapping
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.models.loading.BlockModelElement
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.models.loading.BlockModelFace
|
||||
import de.bixilon.minosoft.gui.rendering.textures.Texture
|
||||
@ -72,6 +73,12 @@ class ElementRenderer(element: BlockModelElement, rotation: Vec3, uvlock: Boolea
|
||||
data.add(texture.animationFrameTime.toFloat())
|
||||
data.add(texture.animations.toFloat())
|
||||
data.add(texture.heightFactor)
|
||||
|
||||
if (texture.tintIndex == 1) {
|
||||
data.add(Float.fromBits(RGBColor(0x10, 0xee, 0x10).color))
|
||||
} else {
|
||||
data.add(0f)
|
||||
}
|
||||
}
|
||||
|
||||
fun createQuad(drawPositions: Array<Vec3>, texturePositions: Array<Vec2?>) {
|
||||
@ -109,7 +116,7 @@ class ElementRenderer(element: BlockModelElement, rotation: Vec3, uvlock: Boolea
|
||||
}
|
||||
|
||||
private fun vec3InJsonObject(json: JsonObject): Vec3 {
|
||||
return Vec3(json["x"]?.asFloat?: 0, json["y"]?.asFloat?: 0, json["z"]?.asFloat?: 0)
|
||||
return Vec3(json["x"]?.asFloat ?: 0, json["y"]?.asFloat ?: 0, json["z"]?.asFloat ?: 0)
|
||||
}
|
||||
|
||||
val drawOrder = arrayOf(
|
||||
@ -119,7 +126,7 @@ class ElementRenderer(element: BlockModelElement, rotation: Vec3, uvlock: Boolea
|
||||
Pair(2, 3),
|
||||
Pair(1, 0),
|
||||
Pair(0, 1),
|
||||
)
|
||||
)
|
||||
|
||||
private fun Array<Vec3>.containsAllVectors(set: Set<Vec3>?, margin: Float): Boolean {
|
||||
for (position in set!!) {
|
||||
@ -129,7 +136,7 @@ class ElementRenderer(element: BlockModelElement, rotation: Vec3, uvlock: Boolea
|
||||
isIn = true
|
||||
}
|
||||
}
|
||||
if (! isIn) {
|
||||
if (!isIn) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ class Texture(
|
||||
var animations: Int = 0
|
||||
var animationFrameTime: Int = 0
|
||||
|
||||
var tintIndex = 0
|
||||
|
||||
fun load(assetsManager: AssetsManager) {
|
||||
if (loaded) {
|
||||
return
|
||||
@ -46,6 +48,10 @@ class Texture(
|
||||
"minecraft/textures/${name}.png"
|
||||
}
|
||||
|
||||
if (texturePath == "minecraft/textures/block/grass_block_top.png") {
|
||||
tintIndex = 1
|
||||
}
|
||||
|
||||
val decoder = PNGDecoder(assetsManager.readAssetAsStream(texturePath))
|
||||
buffer = BufferUtils.createByteBuffer(decoder.width * decoder.height * PNGDecoder.Format.RGBA.numComponents)
|
||||
decoder.decode(buffer, decoder.width * PNGDecoder.Format.RGBA.numComponents, PNGDecoder.Format.RGBA)
|
||||
|
Loading…
x
Reference in New Issue
Block a user