From 1671d6bd9f21557037de85d78dab28ed08da3e35 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Thu, 24 Apr 2014 17:30:19 +0200 Subject: [PATCH] Organization. --- .../spine/SkeletonBinary.java | 2 +- .../esotericsoftware/spine/SkeletonJson.java | 2 +- .../spine/SkeletonRenderer.java | 4 +- .../spine/attachments/MeshAttachment.java | 62 +++++++-------- .../attachments/SkinnedMeshAttachment.java | 76 +++++++++---------- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java index c4a25fbd5..5ac73d980 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java @@ -258,7 +258,7 @@ public class SkeletonBinary { weights.add(input.readFloat()); } } - mesh.setMesh(bones.toArray(), weights.toArray(), uvs, triangles); + mesh.setMesh(bones.toArray(), weights.toArray(), triangles, uvs); Color.rgba8888ToColor(mesh.getColor(), input.readInt()); if (nonessential) { diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java index 95c60a2ae..acafaed67 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java @@ -239,7 +239,7 @@ public class SkeletonJson { i += 4; } } - mesh.setMesh(bones.toArray(), weights.toArray(), uvs, triangles); + mesh.setMesh(bones.toArray(), weights.toArray(), triangles, uvs); if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2); if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray()); diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java index 65101dd30..d74124c43 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java @@ -43,7 +43,7 @@ import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; import com.badlogic.gdx.utils.Array; public class SkeletonRenderer { - static private final short[] quadTriangle = {0, 1, 2, 2, 3, 0}; + static private final short[] quadTriangles = {0, 1, 2, 2, 3, 0}; private boolean premultipliedAlpha; @@ -65,7 +65,7 @@ public class SkeletonRenderer { RegionAttachment region = (RegionAttachment)attachment; region.updateWorldVertices(slot, premultipliedAlpha); vertices = region.getWorldVertices(); - triangles = quadTriangle; + triangles = quadTriangles; texture = region.getRegion().getTexture(); if (slot.data.getAdditiveBlending() != additive) { diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java index 44a3f4bb2..25bb162e9 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java @@ -50,9 +50,9 @@ public class MeshAttachment extends Attachment { private final Color color = new Color(1, 1, 1, 1); // Nonessential. + private int hullLength; private int[] edges; private float width, height; - private int hullLength; public MeshAttachment (String name) { super(name); @@ -68,6 +68,36 @@ public class MeshAttachment extends Attachment { return region; } + public void setMesh (float[] vertices, short[] triangles, float[] uvs) { + this.vertices = vertices; + this.triangles = triangles; + + int worldVerticesLength = vertices.length / 2 * 5; + if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength]; + + float u, v, width, height; + if (region == null) { + u = v = 0; + width = height = 1; + } else { + u = region.getU(); + v = region.getV(); + width = region.getU2() - u; + height = region.getV2() - v; + } + if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) { + for (int i = 0, w = 3, n = vertices.length; i < n; i += 2, w += 5) { + worldVertices[w] = u + uvs[i + 1] * width; + worldVertices[w + 1] = v + height - uvs[i] * height; + } + } else { + for (int i = 0, w = 3, n = vertices.length; i < n; i += 2, w += 5) { + worldVertices[w] = u + uvs[i] * width; + worldVertices[w + 1] = v + uvs[i + 1] * height; + } + } + } + public void updateWorldVertices (Slot slot, boolean premultipliedAlpha) { Skeleton skeleton = slot.getSkeleton(); Color skeletonColor = skeleton.getColor(); @@ -152,34 +182,4 @@ public class MeshAttachment extends Attachment { public void setHeight (float height) { this.height = height; } - - public void setMesh (float[] vertices, short[] triangles, float[] uvs) { - this.vertices = vertices; - this.triangles = triangles; - - int worldVerticesLength = vertices.length / 2 * 5; - if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength]; - - float u, v, w, h; - if (region == null) { - u = v = 0; - w = h = 1; - } else { - u = region.getU(); - v = region.getV(); - w = region.getU2() - u; - h = region.getV2() - v; - } - if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) { - for (int i = 0, ii = 3, n = vertices.length; i < n; i += 2, ii += 5) { - worldVertices[ii] = u + uvs[i + 1] * w; - worldVertices[ii + 1] = v + h - uvs[i] * h; - } - } else { - for (int i = 0, ii = 3, n = vertices.length; i < n; i += 2, ii += 5) { - worldVertices[ii] = u + uvs[i] * w; - worldVertices[ii + 1] = v + uvs[i + 1] * h; - } - } - } } diff --git a/spine-libgdx/src/com/esotericsoftware/spine/attachments/SkinnedMeshAttachment.java b/spine-libgdx/src/com/esotericsoftware/spine/attachments/SkinnedMeshAttachment.java index d6db44864..a8ab4500e 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/attachments/SkinnedMeshAttachment.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/attachments/SkinnedMeshAttachment.java @@ -69,6 +69,44 @@ public class SkinnedMeshAttachment extends Attachment { return region; } + /** @param bones For each vertex, the number of bones affecting the vertex followed by that many bone indices. Ie: count, + * boneIndex, ... + * @param weights For each bone affecting the vertex, the vertex position in the bone's coordinate system and the weight for + * the bone's influence. Ie: x, y, weight, ... + * @param uvs For each vertex, a texure coordinate pair. Ie: u, v, ... + * @param triangles Vertex number triplets which describe the mesh's triangulation. */ + public void setMesh (int[] bones, float[] weights, short[] triangles, float[] uvs) { + this.bones = bones; + this.weights = weights; + this.triangles = triangles; + + int uvsLength = uvs.length; + int worldVerticesLength = uvsLength / 2 * 5; + if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength]; + + float u, v, w, h; + if (region == null) { + u = v = 0; + w = h = 1; + } else { + u = region.getU(); + v = region.getV(); + w = region.getU2() - u; + h = region.getV2() - v; + } + if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) { + for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) { + worldVertices[ii] = u + uvs[i + 1] * w; + worldVertices[ii + 1] = v + h - uvs[i] * h; + } + } else { + for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) { + worldVertices[ii] = u + uvs[i] * w; + worldVertices[ii + 1] = v + uvs[i + 1] * h; + } + } + } + public void updateWorldVertices (Slot slot, boolean premultipliedAlpha) { Skeleton skeleton = slot.getSkeleton(); Color skeletonColor = skeleton.getColor(); @@ -180,42 +218,4 @@ public class SkinnedMeshAttachment extends Attachment { public void setHeight (float height) { this.height = height; } - - /** @param bones For each vertex, the number of bones affecting the vertex followed by that many bone indices. Ie: count, - * boneIndex, ... - * @param weights For each bone affecting the vertex, the vertex position in the bone's coordinate system and the weight for - * the bone's influence. Ie: x, y, weight, ... - * @param uvs For each vertex, a texure coordinate pair. Ie: u, v, ... - * @param triangles Vertex number triplets which describe the mesh's triangulation. */ - public void setMesh (int[] bones, float[] weights, float[] uvs, short[] triangles) { - this.bones = bones; - this.weights = weights; - this.triangles = triangles; - - int uvsLength = uvs.length; - int worldVerticesLength = uvsLength / 2 * 5; - if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength]; - - float u, v, w, h; - if (region == null) { - u = v = 0; - w = h = 1; - } else { - u = region.getU(); - v = region.getV(); - w = region.getU2() - u; - h = region.getV2() - v; - } - if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) { - for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) { - worldVertices[ii] = u + uvs[i + 1] * w; - worldVertices[ii + 1] = v + h - uvs[i] * h; - } - } else { - for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) { - worldVertices[ii] = u + uvs[i] * w; - worldVertices[ii + 1] = v + uvs[i + 1] * h; - } - } - } }