Hi,
I have a strange problem experimenting with Meshes. I had an existent animation, so to make it more fluid I changed two attachments to Meshes, which are in a SkinAttachment (Skeleton "palmerascenario", bone2, hoja2bone2 slot and bone4, hojapalmera slot, Skin name is "olaplaya", animation is "olaAnimation").
Everything's fine in the editor, I export it to Json and try to load it... and crashes.
Exception in thread "LWJGL Application" java.lang.ClassCastException: com.esotericsoftware.spine.attachments.RegionAttachment cannot be cast to com.esotericsoftware.spine.attachments.MeshAttachment
at com.esotericsoftware.spine.SkeletonJson.readAnimation(SkeletonJson.java:318)
at com.esotericsoftware.spine.SkeletonJson.readSkeletonData(SkeletonJson.java:156)
at com.pamba.JsonLoadMeshTest.create(JsonLoadMeshTest.java:27)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
I debugged a little, for some reason it tries to load the FFD Timeline with the skin "arbol", but for that skin I don't have any Mesh, only for the skin "olaplaya", so when it tries to get the Attachment and cast it to Mesh, it fails.
for (JsonValue meshMap = slotMap.child; meshMap != null; meshMap = meshMap.next) {
FfdTimeline timeline = new FfdTimeline(meshMap.size);
MeshAttachment mesh = (MeshAttachment)skin.getAttachment(slotIndex, meshMap.name);
Below is a copy-paste example, also I attach the project file and atlas file (without the png, but of course you can put a blank png).
Note: I'm using latest ligbdx, and libgdx spine runtime.
package com.test;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.esotericsoftware.spine.AnimationState;
import com.esotericsoftware.spine.Skeleton;
import com.esotericsoftware.spine.SkeletonData;
import com.esotericsoftware.spine.SkeletonJson;
public class JsonLoadMeshTest extends ApplicationAdapter {
TextureAtlas atlas;
Skeleton skeleton;
AnimationState state;
public void create () {
atlas = new TextureAtlas(Gdx.files.internal("data/pack.txt"));
SkeletonJson json = new SkeletonJson(atlas);
SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("data/palmerascenario.json"));
}
public void render () {
state.update(Gdx.graphics.getDeltaTime()); // Update the animation time.
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
public void resize (int width, int height) {
}
public void dispose () {
atlas.dispose();
}
public static void main (String[] args) throws Exception {
new LwjglApplication(new JsonLoadMeshTest());
}
}
Thanks in advance.