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

commonMain.ru.casperix.spine.Attachment.kt Maven / Gradle / Ivy

The newest version!
package ru.casperix.spine

import ru.casperix.math.color.Color
import ru.casperix.math.Transform
import ru.casperix.spine.device.PixelMapRegion

interface Attachment {
    val name: String
}

class UnknownAttachment(override val name: String) : Attachment

class Sequence

interface HasTextureRegion {
    val color: Color
    val path: String?
    val region: PixelMapRegion
    val sequence: Sequence?
}

class RegionAttachment(
    override val name: String,
    override val color: Color,
    override val path: String?,
    override val sequence: Sequence?,
    override val region: PixelMapRegion,
    val x: Float,
    val y: Float,
    val scaleX: Float,
    val scaleY: Float,
    val rotation: Float,
    val width: Float,
    val height: Float,
    val offset: FloatArray,
    val uvs: FloatArray,
//    val regionHeight:Float,
//    val regionOffsetX:Float,
//    val regionOffsetY:Float,
//    val regionOriginalHeight:Float,
//    val regionOriginalWidth:Float,
//    val regionWidth:Float,
//    val rendererObject:Any,
) : Attachment, HasTextureRegion {
    val regionScaleX = width / region.attributes.bounds.dimension.x
    val regionScaleY = height / region.attributes.bounds.dimension.y

    val transform get() = Transform(x, y, rotation, scaleX * regionScaleX, scaleY * regionScaleY, 0f, 0f)
}

class BoundingBoxAttachment(
    val color: Color,
    name: String,
    bones: IntArray,
    id: Int,
    timelineAttachment: Attachment,
    vertices: FloatArray,
    worldVerticesLength: Int,
) : VertexAttachment(name, bones, id, timelineAttachment, vertices, worldVerticesLength) {

}

open class VertexAttachment(
    override val name: String,
    val bones: IntArray,
    val id: Int,
    val timelineAttachment: Attachment,
    val vertices: FloatArray,
    val worldVerticesLength: Int,
) : Attachment




© 2015 - 2024 Weber Informatics LLC | Privacy Policy