port single_chest to smodel

This commit is contained in:
Moritz Zwerger 2023-10-15 21:56:01 +02:00
parent 860f79facd
commit 861cc33e68
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
7 changed files with 107 additions and 234 deletions

View File

@ -72,7 +72,7 @@
"length": 0.3,
"animators": [
{
"element": "head",
"transform": "base.head",
"keyframes": [
{
"type": "rotate",

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.chunk.entities.EntityRendererRegister
import de.bixilon.minosoft.gui.rendering.models.loader.ModelLoader
import de.bixilon.minosoft.gui.rendering.models.loader.SkeletalLoader.Companion.bbModel
import de.bixilon.minosoft.gui.rendering.models.loader.SkeletalLoader.Companion.sModel
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
import de.bixilon.minosoft.gui.rendering.util.VecUtil.toVec3
@ -42,7 +42,7 @@ class SingleChestRenderer(
) {
companion object {
val SINGLE_MODEL = minecraft("block/entities/single_chest").bbModel()
val SINGLE_MODEL = minecraft("block/entities/single_chest").sModel()
private val named = minecraft("chest")
fun register(loader: ModelLoader, name: ResourceLocation, texture: ResourceLocation) {

View File

@ -29,7 +29,7 @@ class SkeletalLoader(private val loader: ModelLoader) {
private val baked: MutableMap<ResourceLocation, BakedSkeletalModel> = HashMap()
fun load(latch: AbstractLatch?) {
val templates: MutableMap<ResourceLocation, SkeletalModel> = HashMap(this.registered.size, 0.0f)
val templates: MutableMap<ResourceLocation, SkeletalModel> = HashMap(this.registered.size, 0.1f)
for ((name, registered) in this.registered) {
val template = templates.getOrPut(registered.template) { loader.context.connection.assetsManager[registered.template].readJson() }
@ -71,5 +71,9 @@ class SkeletalLoader(private val loader: ModelLoader) {
fun ResourceLocation.bbModel(): ResourceLocation {
return this.extend(prefix = "models/", suffix = ".bbmodel")
}
fun ResourceLocation.sModel(): ResourceLocation {
return this.extend(prefix = "models/", suffix = ".smodel")
}
}
}

View File

@ -30,10 +30,6 @@ data class SkeletalRotation(
this._origin = (to - from) / 2.0f
}
operator fun plus(other: SkeletalRotation): SkeletalRotation {
return SkeletalRotation(this.value + other.value, _origin)
}
companion object {
val EMPTY = SkeletalRotation(Vec3.EMPTY, Vec3.EMPTY, false)
}

View File

@ -24,7 +24,7 @@ data class SkeletalTransform(
fun bake(id: AtomicInteger): BakedSkeletalTransform {
val usedId = id.getAndIncrement()
val pivot = pivot / 16
val pivot = pivot / 16.0f
val transforms: MutableMap<String, BakedSkeletalTransform> = mutableMapOf()

View File

@ -1,225 +0,0 @@
{
"meta": {
"format_version": "4.0",
"model_format": "free",
"box_uv": true
},
"geometry_name": "chest",
"visible_box": [1, 1, 0],
"resolution": {
"width": 64,
"height": 64
},
"elements": [
{
"name": "bottom",
"from": [-7, -10, -7],
"to": [7, 0, 7],
"rotation": [-180, 0, 0],
"uv_offset": [0, 19],
"faces": {
"north": {
"uv": [14, 33, 28, 43],
"texture": 0
},
"east": {
"uv": [0, 33, 14, 43],
"texture": 0
},
"south": {
"uv": [42, 33, 56, 43],
"texture": 0
},
"west": {
"uv": [28, 33, 42, 43],
"texture": 0
},
"up": {
"uv": [28, 33, 14, 19],
"texture": 0
},
"down": {
"uv": [42, 19, 28, 33],
"texture": 0
}
},
"uuid": "76801e5b-8a1b-0a5d-c258-beef5dbc79ee"
},
{
"name": "lid",
"from": [-7, -14, -7],
"to": [7, -9, 7],
"rotation": [-180, 0, 0],
"faces": {
"north": {
"uv": [14, 14, 28, 19],
"texture": 0
},
"east": {
"uv": [0, 14, 14, 19],
"texture": 0
},
"south": {
"uv": [42, 14, 56, 19],
"texture": 0
},
"west": {
"uv": [28, 14, 42, 19],
"texture": 0
},
"up": {
"uv": [28, 14, 14, 0],
"texture": 0
},
"down": {
"uv": [42, 0, 28, 14],
"texture": 0
}
},
"uuid": "01d53de6-eeef-3c77-dd07-6f6d52b0527b"
},
{
"name": "lock",
"from": [-1, -11, -8],
"to": [1, -7, -7],
"rotation": [0, 0, -180],
"faces": {
"north": {
"uv": [1, 1, 3, 5],
"texture": 0
},
"east": {
"uv": [0, 1, 1, 5],
"texture": 0
},
"south": {
"uv": [4, 1, 6, 5],
"texture": 0
},
"west": {
"uv": [3, 1, 4, 5],
"texture": 0
},
"up": {
"uv": [3, 1, 1, 0],
"texture": 0
},
"down": {
"uv": [5, 0, 3, 1],
"texture": 0
}
},
"uuid": "3cc1a7d6-4cf0-42bc-032f-1b3a602ca1f6"
}
],
"outliner": [
{
"name": "root",
"origin": [8, 8, 8],
"uuid": "17d8814a-c29f-abdc-4f4a-c9b07cd032df",
"children": [
"76801e5b-8a1b-0a5d-c258-beef5dbc79ee",
{
"name": "lid",
"origin": [0, 10, 7],
"uuid": "c9b45550-2e8b-af52-a981-4aedc81fb456",
"children": ["01d53de6-eeef-3c77-dd07-6f6d52b0527b", "3cc1a7d6-4cf0-42bc-032f-1b3a602ca1f6"]
}
]
}
],
"textures": [
{
"path": "entity/chest/normal",
"name": "normal",
"namespace": "minecraft",
"id": 0,
"render_mode": "normal",
"uuid": "9038a773-2512-f607-b2da-58c3649228ad"
}
],
"animations": [
{
"uuid": "d951b58f-d87c-519b-c3a7-22db3d46871c",
"name": "animation.chest.opening",
"loop": "hold",
"override": false,
"length": 0.3,
"animators": {
"c9b45550-2e8b-af52-a981-4aedc81fb456": {
"name": "lid",
"type": "bone",
"keyframes": [
{
"channel": "rotation",
"data_points": [
{
"x": 0,
"y": 0,
"z": 0
}
],
"uuid": "d595c66b-58da-743a-223e-baff1a2910f1",
"time": 0,
"interpolation": "sine"
},
{
"channel": "rotation",
"data_points": [
{
"x": -90,
"y": 0,
"z": 0
}
],
"uuid": "ac945fe7-65b4-1f09-dc05-782860c4aa7c",
"time": 0.3,
"interpolation": "sine"
}
]
}
}
},
{
"uuid": "581b97d7-b54c-456f-e91e-7b619572a530",
"name": "animation.chest.closing",
"loop": "hold",
"override": false,
"length": 0.5,
"animators": {
"c9b45550-2e8b-af52-a981-4aedc81fb456": {
"name": "lid",
"type": "bone",
"keyframes": [
{
"channel": "rotation",
"data_points": [
{
"x": -90,
"y": 0,
"z": 0
}
],
"uuid": "ac945fe7-65b4-1f09-dc05-782860c4aa7c",
"time": 0,
"interpolation": "sine"
},
{
"channel": "rotation",
"data_points": [
{
"x": 0,
"y": 0,
"z": 0
}
],
"uuid": "8ef02eb5-7b0c-462d-42ab-cce77b9a4497",
"time": 0.5,
"interpolation": "sine"
}
]
}
}
}
]
}

View File

@ -0,0 +1,98 @@
{
"elements": {
"body": {
"from": [-7, 0, -7],
"to": [7, 10, 7],
"texture": "minecraft:chest",
"faces": {
"down": {"uv": [42, 19, 28, 33]},
"up": {"uv": [28, 33, 14, 19]},
"north": {"uv": [14, 33, 28, 43]},
"south": {"uv": [42, 33, 56, 43]},
"west": {"uv": [28, 33, 42, 43]},
"east": {"uv": [0, 33, 14, 43]}
},
"children": {
"lid": {
"offset": [0, 10, 0],
"transform": "lid",
"from": [-7, 0, -7],
"to": [7, 5, 7],
"faces": {
"down": {"uv": [42, 0, 28, 14]},
"up": {"uv": [28, 14, 14, 0]},
"north": {"uv": [14, 14, 28, 19]},
"south": {"uv": [42, 14, 56, 19]},
"west": {"uv": [28, 14, 42, 19]},
"east": {"uv": [0, 14, 14, 19]}
},
"children": {
"lock": {
"offset": [0, 10, 0],
"from": [-7, 0, -7],
"to": [7, 5, 7],
"faces": {
"down": {"uv": [5, 0, 3, 1]},
"up": {"uv": [3, 1, 1, 0]},
"north": {"uv": [1, 1, 3, 5]},
"south": {"uv": [4, 1, 6, 5]},
"west": {"uv": [3, 1, 4, 5]},
"east": {"uv": [0, 1, 1, 5]}
}
}
}
}
}
}
},
"transforms": {
"lid": {
"pivot": [-8, 10, 0]
}
},
"textures": {
"minecraft:chest": {
"resolution": [64, 64]
}
},
"animations": {
"open": {
"loop": "hold",
"length": 0.3,
"animators": [
{
"transform": "base.lid",
"keyframes": [
{
"type": "rotate",
"interpolation": "sine",
"keyframes": {
"0.0": [0, 0, 0],
"0.3": [-90, 0, 0]
}
}
]
}
]
},
"close": {
"loop": "hold",
"length": 0.5,
"animators": [
{
"transform": "base.lid",
"keyframes": [
{
"type": "rotate",
"interpolation": "sine",
"keyframes": {
"0.0": [-90, 0, 0],
"0.5": [0, 0, 0]
}
}
]
}
]
}
}
}