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