0
\$\begingroup\$

I've started to play with the Spine for libgdx runtime in Java.

But I can't seem to render without some sort triangular clipping.

enter image description here

The code is based on the Spine examples:

public class AnimalTest extends ApplicationAdapter {

   OrthographicCamera camera;
   PolygonSpriteBatch batch;
   SkeletonRenderer renderer;

   TextureAtlas atlas;
   Skeleton skeleton;
   AnimationState state;

   public void create () {

      camera = new OrthographicCamera();

      batch = new PolygonSpriteBatch();

      renderer = new SkeletonRenderer();

      atlas = new TextureAtlas(Gdx.files.internal("animals/Animals.atlas"));
      SkeletonJson json = new SkeletonJson(atlas); // This loads skeleton JSON data, which is stateless.

      SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("animals/Animals.json"));

      skeleton = new Skeleton(skeletonData); // Skeleton holds skeleton state (bone positions, slot attachments, etc).
      skeleton.setSkin("5");

      skeleton.setX(1000);
      skeleton.setY(-400);

      AnimationStateData stateData = new AnimationStateData(skeletonData); // Defines mixing (crossfading) between animations.

      state = new AnimationState(stateData); // Holds the animation state for a skeleton (current animation, time, etc).

      state.setAnimation(0, "idle", true);
   }

   public void render () {

      state.update(Gdx.graphics.getDeltaTime()); // Update the animation time.

      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

      state.apply(skeleton); // Poses skeleton using current animations. This sets the bones' local SRT.
      skeleton.updateWorldTransform(); // Uses the bones' local SRT to compute their world SRT.

      // Configure the camera, SpriteBatch, and SkeletonRendererDebug.
      camera.update();
      batch.setProjectionMatrix(camera.combined);

      batch.begin();
      renderer.draw(batch, skeleton); // Draw the skeleton images.
      batch.end();

   }

   public void resize (int width, int height) {
      camera.setToOrtho(false);
   }

   public void dispose () {
      atlas.dispose();
   }

}
\$\endgroup\$
  • \$\begingroup\$ Does the clipping shift depending on what sprite you're displaying, or how you position/orient/size the sprite on your screen, or other factors? \$\endgroup\$ – DMGregory Dec 19 '18 at 17:42
  • \$\begingroup\$ @DMGregory Found the issue and answered my own problem. Thanks for your response though! \$\endgroup\$ – Sander Versluys Dec 19 '18 at 22:17
1
\$\begingroup\$

Found the culprit to my own problem.

Apparently the default skin in the exported json from spine had an attachment with clipping. The renderer on iOS with Cocos2D ignored this for some reason so this never was an issue before.

"Clipper": {
            "Clipper": {
                "type": "clipping",
                "end": "Clipper",
                "vertexCount": 4,
                "vertices": [ -712, 1424, -712, 655.21, 1363.21, 1424, 1363.21, 655.21]
            }
        }
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.