• Editor
  • Script for export

Related Discussions
...

Hello.
I have a character of 50 skins and 4 animations.
For the library in the game I need to save different combinations of skins on the characters, there may be hundreds.
The result must be in gif format.
Prompt whether it is real to write a script which will choose skins which I will tell and will save the character in gif?

Spine can export all skins or one skin or the currently visible skins. We don't have a way to choose multiple skins to export, but we'll consider this new feature. I'm afraid for now you'd need to choose the skins in Spine and then do the export in the UI.

An alternative would be to write your own tool that configures the visible skins using the Spine Runtimes, then writes an image (eg a PNG) for each frame in an animation. You could then process the PNGs into GIF or other formats.

Thank you for your quick response, you are cool!

How do you look at me writing a script that will leave the right set of skins in the json file.
And then I just save it all in a loop through the CLI?


oh, can I somehow open json with atlas?

Hi, I've tried many ways.
Tried through Spine Web Player and MediaRecorder, I get poor quality.
Then I tried canvas.toDataURL, I lost a lot of frames and instead of 160 I managed to save about 50.

Now I'm trying through spine-libgdx, I managed to draw my character, but I don't understand how to save a video or a picture. I'm not a Java specialist, but I understand js and python well. Could you tell me in which direction to move, or give examples?

Thank you for your time!

I personally prefer Java and libgdx, which is what Spine is written in/with.

We provide an example that gets you close:
FboTest
That renders a skeleton to a frame buffer object (FBO). You can then get the pixels and write a PNG file.

You'll need to pose your skeleton for each from throughout the animation. This example is related:
BonePlotting
That poses the skeleton at regular intervals. It doesn't render it, it just writes out bone positions, so you'll need to render to an FBO and write that to a PNG for each frame.

I've created PngExportTest for you, which writes animation frames to an FBO then to PNG files:
PngExportTest

You'll likely have more to do for your tool. You can run through the animation without rendering, calling Skeleton getBounds each frame to determine the maximal bounds across all frames, then create an FBO and pixmap of the right size and run through the animation again to export the PNGs. I suggest using gifski to assemble PNGs into a GIF.

4 dana kasnije

:bigeyed: :bigeyed: :bigeyed:
Thank you for the detailed answer.
I have tried and I have success.
Thank you for your time


Hi, you helped me and I was able to get the result.
Now I have a problem, I don't want to render the animation on a remote server, but I'm getting an error

[LWJGL] GLFW_PLATFORM_ERROR error
        Description : X11: The DISPLAY environment variable is missing
        Stacktrace  :
                org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:830)
                com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.initializeGlfw(Lwjgl3Application.java:84)
                com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:91)
                com.ccs.game.PngExportTest.main(PngExportTest.java:180)
Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Unable to initialize GLFW
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.initializeGlfw(Lwjgl3Application.java:85)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:91)
        at com.ccs.game.PngExportTest.main(PngExportTest.java:180)

Maybe you solved such a problem?
I think it's through a headless server 😐
Do you think there are any solutions to this problem?

Your are using libGDX to generate your PNGs. That requires OpenGL drivers to be present on the machine. You could try your luck with headless MESA.

So I was able to run inside the docker container

RUN apt-get install -y mesa-utils libegl1-mesa xvfb

export DISPLAY=:99.0
Xvfb :99 -screen 0 640x480x24 &

Thx you