Last active
August 29, 2015 13:56
-
-
Save Tom-Ski/9263115 to your computer and use it in GitHub Desktop.
headbang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void draw (PolygonSpriteBatch batch, Skeleton skeleton) { | |
boolean premultipliedAlpha = this.premultipliedAlpha; | |
int srcFunc = premultipliedAlpha ? GL11.GL_ONE : GL11.GL_SRC_ALPHA; | |
batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA); | |
boolean additive = false; | |
float[] vertices; | |
short[] triangles; | |
Texture texture; | |
Array<Slot> drawOrder = skeleton.drawOrder; | |
for (int i = 0, n = drawOrder.size; i < n; i++) { | |
Slot slot = drawOrder.get(i); | |
Attachment attachment = slot.attachment; | |
if (attachment instanceof RegionAttachment) { | |
RegionAttachment region = (RegionAttachment)attachment; | |
region.updateWorldVertices(slot, premultipliedAlpha); | |
vertices = region.getWorldVertices(); | |
triangles = quadTriangle; | |
texture = region.getRegion().getTexture(); | |
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 MeshAttachment) { | |
MeshAttachment mesh = (MeshAttachment)attachment; | |
mesh.updateWorldVertices(slot, true); | |
vertices = mesh.getWorldVertices(); | |
triangles = mesh.getTriangles(); | |
texture = mesh.getRegion().getTexture(); | |
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; | |
attachmentSkeleton.getRootBone().setRotation(slot.getBone().getWorldRotation()); | |
attachmentSkeleton.setX(slot.getSkeleton().getX() + slot.getBone().worldX); | |
attachmentSkeleton.setY(slot.getSkeleton().getY() + slot.getBone().worldY); | |
attachmentSkeleton.updateWorldTransform(); | |
System.out.println("Imma steal your stuff"); | |
draw(batch, attachmentSkeleton); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment