Browse Source

Merge branch 'master' of github.com:EsotericSoftware/spine-runtimes into Trompo-JS-AtlasAttachmentLoader

Dario Segura 10 years ago
parent
commit
145aed328e

+ 1 - 1
spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/Box2DExample.java

@@ -211,7 +211,7 @@ public class Box2DExample extends ApplicationAdapter {
 		// Next we create the 50 box bodies using the PolygonShape we just
 		// Next we create the 50 box bodies using the PolygonShape we just
 		// defined. This process is similar to the one we used for the ground
 		// defined. This process is similar to the one we used for the ground
 		// body. Note that we reuse the polygon for each body fixture.
 		// body. Note that we reuse the polygon for each body fixture.
-		for (int i = 0; i < 20; i++) {
+		for (int i = 0; i < 45; i++) {
 			// Create the BodyDef, set a random position above the
 			// Create the BodyDef, set a random position above the
 			// ground and create a new body
 			// ground and create a new body
 			BodyDef boxBodyDef = new BodyDef();
 			BodyDef boxBodyDef = new BodyDef();

+ 15 - 3
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRendererDebug.java

@@ -58,6 +58,8 @@ public class SkeletonRendererDebug {
 	private boolean drawMeshHull = true, drawMeshTriangles = true;
 	private boolean drawMeshHull = true, drawMeshTriangles = true;
 	private final SkeletonBounds bounds = new SkeletonBounds();
 	private final SkeletonBounds bounds = new SkeletonBounds();
 	private float scale = 1;
 	private float scale = 1;
+	private float boneWidth = 2;
+	private boolean premultipliedAlpha;
 
 
 	public SkeletonRendererDebug () {
 	public SkeletonRendererDebug () {
 		shapes = new ShapeRenderer();
 		shapes = new ShapeRenderer();
@@ -72,21 +74,27 @@ public class SkeletonRendererDebug {
 		float skeletonY = skeleton.getY();
 		float skeletonY = skeleton.getY();
 
 
 		Gdx.gl.glEnable(GL20.GL_BLEND);
 		Gdx.gl.glEnable(GL20.GL_BLEND);
+		int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA;
+		Gdx.gl.glBlendFunc(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA);
+
 		ShapeRenderer shapes = this.shapes;
 		ShapeRenderer shapes = this.shapes;
-		shapes.begin(ShapeType.Line);
 
 
 		Array<Bone> bones = skeleton.getBones();
 		Array<Bone> bones = skeleton.getBones();
 		if (drawBones) {
 		if (drawBones) {
 			shapes.setColor(boneLineColor);
 			shapes.setColor(boneLineColor);
+			shapes.begin(ShapeType.Filled);
 			for (int i = 0, n = bones.size; i < n; i++) {
 			for (int i = 0, n = bones.size; i < n; i++) {
 				Bone bone = bones.get(i);
 				Bone bone = bones.get(i);
 				if (bone.parent == null) continue;
 				if (bone.parent == null) continue;
 				float x = skeletonX + bone.data.length * bone.m00 + bone.worldX;
 				float x = skeletonX + bone.data.length * bone.m00 + bone.worldX;
 				float y = skeletonY + bone.data.length * bone.m10 + bone.worldY;
 				float y = skeletonY + bone.data.length * bone.m10 + bone.worldY;
-				shapes.line(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y);
+				shapes.rectLine(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, boneWidth * scale);
 			}
 			}
+			shapes.end();
+			shapes.begin(ShapeType.Line);
 			shapes.x(skeletonX, skeletonY, 4 * scale);
 			shapes.x(skeletonX, skeletonY, 4 * scale);
-		}
+		} else
+			shapes.begin(ShapeType.Line);
 
 
 		if (drawRegionAttachments) {
 		if (drawRegionAttachments) {
 			shapes.setColor(attachmentLineColor);
 			shapes.setColor(attachmentLineColor);
@@ -207,4 +215,8 @@ public class SkeletonRendererDebug {
 	public void setMeshTriangles (boolean meshTriangles) {
 	public void setMeshTriangles (boolean meshTriangles) {
 		this.drawMeshTriangles = meshTriangles;
 		this.drawMeshTriangles = meshTriangles;
 	}
 	}
+
+	public void setPremultipliedAlpha (boolean premultipliedAlpha) {
+		this.premultipliedAlpha = premultipliedAlpha;
+	}
 }
 }

+ 12 - 10
spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java

@@ -232,16 +232,18 @@ public class SkeletonViewer extends ApplicationAdapter {
 		ui.stage.draw();
 		ui.stage.draw();
 
 
 		// Draw indicator for timeline position.
 		// Draw indicator for timeline position.
-		ShapeRenderer shapes = debugRenderer.getShapeRenderer();
-		TrackEntry entry = state.getCurrent(0);
-		if (entry != null) {
-			float percent = entry.getTime() / entry.getEndTime();
-			if (entry.getLoop()) percent %= 1;
-			float x = ui.window.getRight() + (Gdx.graphics.getWidth() - ui.window.getRight()) * percent;
-			shapes.setColor(Color.CYAN);
-			shapes.begin(ShapeType.Line);
-			shapes.line(x, 0, x, 20);
-			shapes.end();
+		if (state != null) {
+			ShapeRenderer shapes = debugRenderer.getShapeRenderer();
+			TrackEntry entry = state.getCurrent(0);
+			if (entry != null) {
+				float percent = entry.getTime() / entry.getEndTime();
+				if (entry.getLoop()) percent %= 1;
+				float x = ui.window.getRight() + (Gdx.graphics.getWidth() - ui.window.getRight()) * percent;
+				shapes.setColor(Color.CYAN);
+				shapes.begin(ShapeType.Line);
+				shapes.line(x, 0, x, 20);
+				shapes.end();
+			}
 		}
 		}
 	}
 	}