mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
spriteassembler: oob bodyparts will clip, as they should be
...to hide unwanted bodyparts in the skeleton
This commit is contained in:
@@ -7,7 +7,9 @@ import net.torvald.terrarum.linearSearch
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembles the single frame of the animation, outputs Java AWT image.
|
* Assembles the single frame of the animation, outputs GDX Pixmap.
|
||||||
|
*
|
||||||
|
* The entire rendering is done by using pixmap. That is, no GPU access.
|
||||||
*
|
*
|
||||||
* Created by minjaesong on 2019-01-06.
|
* Created by minjaesong on 2019-01-06.
|
||||||
*/
|
*/
|
||||||
@@ -55,6 +57,8 @@ object AssembleSheetPixmap {
|
|||||||
AppLoader.printdbg(this, "Frame to draw: $frameName (R$animRow C$animFrame)")
|
AppLoader.printdbg(this, "Frame to draw: $frameName (R$animRow C$animFrame)")
|
||||||
|
|
||||||
drawFrame(animRow, animFrame, canvas, bodyparts, transformList, assembleConfig)
|
drawFrame(animRow, animFrame, canvas, bodyparts, transformList, assembleConfig)
|
||||||
|
|
||||||
|
bodyparts.forEach { it?.dispose() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawFrame(row: Int, column: Int,
|
private fun drawFrame(row: Int, column: Int,
|
||||||
@@ -63,20 +67,25 @@ object AssembleSheetPixmap {
|
|||||||
transformList: List<Pair<String, ADPropertyObject.Vector2i>>,
|
transformList: List<Pair<String, ADPropertyObject.Vector2i>>,
|
||||||
assembleConfig: AssembleConfig
|
assembleConfig: AssembleConfig
|
||||||
) {
|
) {
|
||||||
|
val tmpFrame = Pixmap(assembleConfig.fw, assembleConfig.fh, Pixmap.Format.RGBA8888)
|
||||||
|
|
||||||
bodyparts.forEachIndexed { index, image ->
|
bodyparts.forEachIndexed { index, image ->
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
val imgCentre = AssembleFrameBase.getCentreOf(image)
|
val imgCentre = AssembleFrameBase.getCentreOf(image)
|
||||||
val drawPos = transformList[index].second.invertY() + assembleConfig.origin - imgCentre
|
val drawPos = transformList[index].second.invertY() + assembleConfig.origin - imgCentre
|
||||||
|
|
||||||
canvas.drawPixmap(
|
tmpFrame.drawPixmap(image, drawPos.x, drawPos.y)
|
||||||
image,
|
|
||||||
(column - 1) * assembleConfig.fw + drawPos.x,
|
|
||||||
(row - 1) * assembleConfig.fh + drawPos.y
|
|
||||||
)
|
|
||||||
|
|
||||||
image.dispose()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canvas.drawPixmap(
|
||||||
|
tmpFrame,
|
||||||
|
(column - 1) * assembleConfig.fw,
|
||||||
|
(row - 1) * assembleConfig.fh
|
||||||
|
)
|
||||||
|
|
||||||
|
tmpFrame.dispose()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user