mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
skeletal: move loop to individual keyframes
This commit is contained in:
parent
98e73ee90e
commit
cd694c50ff
@ -70,10 +70,10 @@
|
||||
"open": [
|
||||
{
|
||||
"transform": "head",
|
||||
"loop": "hold",
|
||||
"keyframes": [
|
||||
{
|
||||
"type": "rotate",
|
||||
"loop": "hold",
|
||||
"interpolation": "sine",
|
||||
"data": {
|
||||
"0.0": [0, 0, 0],
|
||||
|
@ -18,8 +18,21 @@ import de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.AbstractAnimat
|
||||
class KeyframeAnimation(
|
||||
val animators: Array<KeyframeAnimator>,
|
||||
) : AbstractAnimation {
|
||||
private var time = 0.0f
|
||||
|
||||
|
||||
override fun draw(delta: Float): Boolean {
|
||||
TODO("Not yet implemented")
|
||||
time += delta
|
||||
var stop = true
|
||||
|
||||
for (animator in this.animators) {
|
||||
if (!animator.draw(this.time)) {
|
||||
stop = false
|
||||
}
|
||||
}
|
||||
if (stop) return true
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,15 @@
|
||||
package de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.keyframe
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.instance.TransformInstance
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.AnimationLoops
|
||||
|
||||
class KeyframeAnimator(
|
||||
val transform: TransformInstance,
|
||||
val loop: AnimationLoops,
|
||||
val keyframes: Array<KeyframeInstance>,
|
||||
)
|
||||
) {
|
||||
|
||||
fun draw(time: Float): Boolean {
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ class AnimationManager(val instance: SkeletalInstance) {
|
||||
|
||||
fun draw() {
|
||||
val nanos = nanos()
|
||||
val delta = nanos - lastDraw
|
||||
val delta = if (lastDraw < 0) 0L else nanos - lastDraw
|
||||
this.lastDraw = nanos
|
||||
draw(delta / 1000.0f)
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SkeletalInstance(
|
||||
|
||||
fun update(position: Vec3i, direction: Directions) {
|
||||
val position = Vec3(position - context.camera.offset.offset)
|
||||
position.x -= 0.5f; position.z -= 0.5f // models origin is the center of block origin
|
||||
position.x += 0.5f; position.z += 0.5f // models origin is the center of block origin
|
||||
update(position, direction.rotation)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.key
|
||||
|
||||
data class SkeletalAnimator(
|
||||
val transform: String,
|
||||
val loop: AnimationLoops,
|
||||
val keyframes: List<SkeletalKeyframe>,
|
||||
) {
|
||||
private val split = transform.split(".", "/").toTypedArray()
|
||||
@ -46,6 +45,6 @@ data class SkeletalAnimator(
|
||||
instances[index] = keyframe.instance()
|
||||
}
|
||||
|
||||
return KeyframeAnimator(transform, loop, instances.cast())
|
||||
return KeyframeAnimator(transform, instances.cast())
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.ke
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.keyframe.KeyframeInstance
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.AnimationLoops
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.types.RotateKeyframe
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.types.ScaleKeyframe
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.types.TintKeyframe
|
||||
@ -31,6 +32,7 @@ import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.key
|
||||
|
||||
interface SkeletalKeyframe {
|
||||
val type: String
|
||||
val loop: AnimationLoops
|
||||
|
||||
fun instance(): KeyframeInstance
|
||||
}
|
||||
|
@ -15,12 +15,14 @@ package de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.ke
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.keyframe.KeyframeInstance
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.AnimationLoops
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.KeyframeInterpolation
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.SkeletalKeyframe
|
||||
import java.util.*
|
||||
|
||||
data class RotateKeyframe(
|
||||
val interpolation: KeyframeInterpolation = KeyframeInterpolation.NONE,
|
||||
override val loop: AnimationLoops,
|
||||
val data: TreeMap<Float, Vec3>,
|
||||
) : SkeletalKeyframe {
|
||||
override val type get() = TYPE
|
||||
|
@ -15,12 +15,14 @@ package de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.ke
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.keyframe.KeyframeInstance
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.AnimationLoops
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.KeyframeInterpolation
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.SkeletalKeyframe
|
||||
import java.util.*
|
||||
|
||||
data class ScaleKeyframe(
|
||||
val interpolation: KeyframeInterpolation = KeyframeInterpolation.NONE,
|
||||
override val loop: AnimationLoops,
|
||||
val data: TreeMap<Float, Vec3>,
|
||||
) : SkeletalKeyframe {
|
||||
override val type get() = TYPE
|
||||
|
@ -15,12 +15,14 @@ package de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.ke
|
||||
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.keyframe.KeyframeInstance
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.AnimationLoops
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.KeyframeInterpolation
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.SkeletalKeyframe
|
||||
import java.util.*
|
||||
|
||||
data class TintKeyframe(
|
||||
val interpolation: KeyframeInterpolation = KeyframeInterpolation.NONE,
|
||||
override val loop: AnimationLoops,
|
||||
val channel: ColorChannel = ColorChannel.RGB,
|
||||
val data: TreeMap<Float, RGBColor>,
|
||||
) : SkeletalKeyframe {
|
||||
|
@ -15,12 +15,14 @@ package de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.ke
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.animation.keyframe.KeyframeInstance
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.AnimationLoops
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.KeyframeInterpolation
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.model.animations.animators.keyframes.SkeletalKeyframe
|
||||
import java.util.*
|
||||
|
||||
data class TranslateKeyframe(
|
||||
val interpolation: KeyframeInterpolation = KeyframeInterpolation.NONE,
|
||||
override val loop: AnimationLoops,
|
||||
val data: TreeMap<Float, Vec3>,
|
||||
) : SkeletalKeyframe {
|
||||
override val type get() = TYPE
|
||||
|
@ -59,11 +59,11 @@
|
||||
"open": [
|
||||
{
|
||||
"transform": "lid",
|
||||
"loop": "hold",
|
||||
"length": 0.3,
|
||||
"keyframes": [
|
||||
{
|
||||
"type": "rotate",
|
||||
"loop": "hold",
|
||||
"interpolation": "sine",
|
||||
"data": {
|
||||
"0.0": [0, 0, 0],
|
||||
@ -76,11 +76,11 @@
|
||||
"close": [
|
||||
{
|
||||
"transform": "lid",
|
||||
"loop": "hold",
|
||||
"length": 0.5,
|
||||
"keyframes": [
|
||||
{
|
||||
"type": "rotate",
|
||||
"loop": "hold",
|
||||
"interpolation": "sine",
|
||||
"data": {
|
||||
"0.0": [-90, 0, 0],
|
||||
|
Loading…
x
Reference in New Issue
Block a user