|
@@ -35,6 +35,7 @@ package com.esotericsoftware.spine;
|
|
|
|
|
|
import com.esotericsoftware.spine.attachments.Attachment;
|
|
|
import com.esotericsoftware.spine.attachments.RegionAttachment;
|
|
|
+import com.esotericsoftware.spine.attachments.SkeletonAttachment;
|
|
|
|
|
|
import com.badlogic.gdx.graphics.GL11;
|
|
|
import com.badlogic.gdx.graphics.Texture;
|
|
@@ -67,18 +68,39 @@ public class SkeletonRenderer {
|
|
|
vertices = region.getWorldVertices();
|
|
|
triangles = quadTriangle;
|
|
|
texture = region.getRegion().getTexture();
|
|
|
- } else
|
|
|
- continue;
|
|
|
-
|
|
|
- if (slot.data.getAdditiveBlending() != additive) {
|
|
|
- additive = !additive;
|
|
|
- if (additive)
|
|
|
- batch.setBlendFunction(srcFunc, GL11.GL_ONE);
|
|
|
- else
|
|
|
- batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
- }
|
|
|
|
|
|
- batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
|
|
|
+ if (slot.data.getAdditiveBlending() != additive) {
|
|
|
+ additive = !additive;
|
|
|
+ if (additive)
|
|
|
+ batch.setBlendFunction(srcFunc, GL11.GL_ONE);
|
|
|
+ else
|
|
|
+ batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
+ }
|
|
|
+
|
|
|
+ batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
|
|
|
+ } else if (attachment instanceof SkeletonAttachment) {
|
|
|
+ Skeleton attachmentSkeleton = ((SkeletonAttachment)attachment).getSkeleton();
|
|
|
+ if (attachmentSkeleton == null) continue;
|
|
|
+ Bone bone = slot.getBone();
|
|
|
+ Bone rootBone = attachmentSkeleton.getRootBone();
|
|
|
+ float oldScaleX = rootBone.getScaleX();
|
|
|
+ float oldScaleY = rootBone.getScaleY();
|
|
|
+ float oldRotation = rootBone.getRotation();
|
|
|
+ attachmentSkeleton.setX(bone.getWorldX());
|
|
|
+ attachmentSkeleton.setY(bone.getWorldY());
|
|
|
+ rootBone.setScaleX(1 + bone.getWorldScaleX() - oldScaleX);
|
|
|
+ rootBone.setScaleY(1 + bone.getWorldScaleY() - oldScaleY);
|
|
|
+ rootBone.setRotation(oldRotation + bone.getWorldRotation());
|
|
|
+ attachmentSkeleton.updateWorldTransform();
|
|
|
+
|
|
|
+ draw(batch, attachmentSkeleton);
|
|
|
+
|
|
|
+ attachmentSkeleton.setX(0);
|
|
|
+ attachmentSkeleton.setY(0);
|
|
|
+ rootBone.setScaleX(oldScaleX);
|
|
|
+ rootBone.setScaleY(oldScaleY);
|
|
|
+ rootBone.setRotation(oldRotation);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -105,6 +127,28 @@ public class SkeletonRenderer {
|
|
|
batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
}
|
|
|
batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, 20);
|
|
|
+ } else if (attachment instanceof SkeletonAttachment) {
|
|
|
+ Skeleton attachmentSkeleton = ((SkeletonAttachment)attachment).getSkeleton();
|
|
|
+ if (attachmentSkeleton == null) continue;
|
|
|
+ Bone bone = slot.getBone();
|
|
|
+ Bone rootBone = attachmentSkeleton.getRootBone();
|
|
|
+ float oldScaleX = rootBone.getScaleX();
|
|
|
+ float oldScaleY = rootBone.getScaleY();
|
|
|
+ float oldRotation = rootBone.getRotation();
|
|
|
+ attachmentSkeleton.setX(bone.getWorldX());
|
|
|
+ attachmentSkeleton.setY(bone.getWorldY());
|
|
|
+ rootBone.setScaleX(1 + bone.getWorldScaleX() - oldScaleX);
|
|
|
+ rootBone.setScaleY(1 + bone.getWorldScaleY() - oldScaleY);
|
|
|
+ rootBone.setRotation(oldRotation + bone.getWorldRotation());
|
|
|
+ attachmentSkeleton.updateWorldTransform();
|
|
|
+
|
|
|
+ draw(batch, attachmentSkeleton);
|
|
|
+
|
|
|
+ attachmentSkeleton.setX(0);
|
|
|
+ attachmentSkeleton.setY(0);
|
|
|
+ rootBone.setScaleX(oldScaleX);
|
|
|
+ rootBone.setScaleY(oldScaleY);
|
|
|
+ rootBone.setRotation(oldRotation);
|
|
|
}
|
|
|
}
|
|
|
}
|