All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.ru.casperix.spine.json.component.AnimationJson.kt Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package ru.casperix.spine.json.component

import ru.casperix.math.vector.float32.Vector2f
import kotlinx.serialization.Serializable
import ru.casperix.spine.animation.*
import ru.casperix.spine.json.CurveSerializer

@Serializable(with = CurveSerializer::class)
interface Curve

@Serializable
object LinearCurve : Curve

@Serializable
object SteppedCurve : Curve

@Serializable
class BezierCurve(val v1:Vector2f, val v2:Vector2f) : Curve

@Serializable
class TupleBezierCurve(val first:BezierCurve, val second:BezierCurve) : Curve


@Serializable
class BoneTimelineJson(
    val rotate: List? = null,
    val translate: List? = null,
    val scale: List? = null,
    val shear: List? = null,
)

@Serializable
class SlotAttachment(override val time: Float = 0f, val name: String? = null) : KeyFrame

@Serializable
class SlotColor(override val time: Float = 0f, val color: String, val curve: Curve = LinearCurve) : KeyFrame

@Serializable
class SlotTwoColor(
    override val time: Float = 0f,
    val light: String,
    val dark: String,
    val curve: Curve = LinearCurve,
    val c2: Float,
    val c3: Float,
    val c4: Float,
) : KeyFrame

@Serializable
class SlotTimeline(
    val attachment: List? = null,
    val color: List? = null,
    val twoColor: List? = null,
)

@Serializable
class IKConstraintKeyFrame(
    override val time: Float = 0f,
    val mix: Float = 1f,
    val softness: Float = 0f,
    val bendPositive: Boolean = false,
    val compress: Boolean = false,
    val stretch: Boolean = false,
) : KeyFrame

typealias IKConstraintTimeline = List

@Serializable
class TransformKeyFrame(
    override val time: Float = 0f,
    val rotateMix: Float = 1f,
    val translateMix: Float = 1f,
    val scaleMix: Float = 1f,
    val schearMix: Float = 1f,
) : KeyFrame

typealias TransformConstraintTimeline = List

@Serializable
class PathPositionKeyFrame(
    override val time: Float = 0f,
    val position: Float = 1f,
) : KeyFrame

@Serializable
class PathSpacingKeyFrame(
    override val time: Float = 0f,
    val spacing: Float = 1f,
) : KeyFrame

@Serializable
class PathMixKeyFrame(
    override val time: Float = 0f,
    val rotateMix: Float = 1f,
    val translateMix: Float = 1f,
) : KeyFrame

@Serializable
class PathConstraintTimeline(
    val position:List? = null,
    val spacing:List? = null,
    val mix:List? = null,
)

@Serializable
class DeformKeyFrame(
    override val time: Float = 0f,
    val offset:Int = 0,
    val vertices: List,
    val curve:Curve = LinearCurve,
    val c2: Float = 0f,
    val c3: Float = 1f,
    val c4: Float = 1f,
) : KeyFrame

@Serializable
class EventKeyFrame(
    val name: String,
    /**
     * No default value in documentation.
     * But exist file without field.
     * version: 4.2.22.
     */
    override val time: Float = 0f,
    val int: Int? = null,
    val float: Float? = null,
    val string: String? = null,
    val volume: Float? = null,
    val balance: Float? = null,
) : KeyFrame

typealias EventTimeline = List

@Serializable
class DrawOrderInfo(
    val slot:String,
    val offset:Int,
)

@Serializable
class DrawOrderKeyFrame(
    override val time: Float = 0f,
    val offsets:List,
) : KeyFrame
typealias DrawOrderTimeline = List

@Serializable
class AnimationJson(
    val bones: Map? = null,
    val slots: Map? = null,
    val ik: Map? = null,
    val transform: Map? = null,
    val path: Map? = null,
    val deform: Map>>? = null,//skin->slot->mesh
    val events: EventTimeline? = null,
    val draworder: Map? = null,
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy