deckpich

Hello, I've been looking for several months to generate a JSON export of a Spine project in GIF Animation,
> in total backend on Python.
(On a server, having no graphic display, so "total backend")

I inquired about "frontend with a display" Runtimes (such as Pygame and others...), if I could use it as help to generate the Atlas & JSON then convert the displayed file into a gif.
Unfortunately, without success.

Do you have any information that could help me with this problem, please? (and especially if it's possible or not :upsidedown: )
Thank you for your attention.
deckpich
  • Сообщения: 2

Nate

It's definitely possible.

Python could run Spine to do the export with the CLI. Doesn't get much easier than that.
Export - Spine User Guide: Command line

Otherwise, you'll need to render your skeleton to a buffer instead of the screen, then write the buffer as an image file. If your game toolkit uses OpenGL, this is done by rendering to a frame buffer object (FBO) instead of to the screen. Searching for FBO might help. Other game toolkits may be able to render directly to a buffer in memory.

Once you have the image data, you need to write it to a file. You might start by writing a single frame as a PNG or BMP. How you write an image file depends on the libraries you use.

To write a GIF you'll need to pose your skeleton with an animation, render a frame to a buffer, write that buffer to the GIF, increment the animation time, pose the skeleton at the new time, render to a buffer, etc until you've rendered all the frames to the GIF. Alternatively you could write PNG files and assemble them into a GIF using a tool like gifski or imagemagick.

BonePlotting is a simple Java app that shows how to pose the skeleton for each frame. It doesn't render to a buffer or write images files though.

I'm afraid I'm not a Python guy, so I can't give any recommendations for how to do what you need. I could help more if you wanted to use libgdx. :)
Аватара пользователя
Nate

Nate
  • Сообщения: 10740

deckpich

Nate писал(а):It's definitely possible.

Python could run Spine to do the export with the CLI. Doesn't get much easier than that.
Export - Spine User Guide: Command line
[...]
Hello,
Let me restart this discussion.
After much thought, testing, the idea that @Nate proposed with Libgdx seemed to be very interesting.

So I tested the implementation of this GIF generation system in "Backend Java" with Libgdx.
However, I am stuck on rendering a json file. :upsidedown:

Additionally, Libgdx fails to launch on a server without a screen / gui. (Debian server)
So I turned to a HeadlessApplication which seems to be suitable for running without display.
But to sum up, "graphics settings" doesn't seem to be enabled with this.
[Error]:
Exception in thread "HeadlessApplication" java.lang.NullPointerException: Cannot invoke "com.badlogic.gdx.graphics.GL20.glGenTexture ()" because "com.badlogic.gdx.Gdx.gl" is null

[Lines]:
batch = new TwoColorPolygonBatch ();
renderer = new SkeletonRenderer ();
Do you have any additional information that could help this, please?
Thank you for your attention and for your support!

> This is no longer related to the title of the post, do I have to recreate a new post maybe?
deckpich
  • Сообщения: 2

Nate

Continuing in this thread is fine, regardless of the thread title.

libgdx uses OpenGL for rendering, so cannot run on a headless server. Or more precisely, libgdx can run on a headless server but then you can't use OpenGL for rendering.

When Spine is used to do command line exports, it can do JSON, binary, and texture packing on a headless server, but not image or video export. For those it uses libgdx and OpenGL, so you have the same problem as trying to use libgdx directly.

You would need to either install what is needed so Spine or libgdx can use OpenGL, or use a different game toolkit that can render images on a headless server. Unfortunately, I'm not sure what game toolkit that might be. You might be able to use browser based rendering, but even then I'm not sure it'll work headless and it seems like a complex solution.
Аватара пользователя
Nate

Nate
  • Сообщения: 10740


Вернуться в Runtimes