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

This commit is contained in:
Dario Segura 2014-12-01 14:58:55 -05:00
commit 145aed328e
3 changed files with 28 additions and 14 deletions

View File

@ -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();

View File

@ -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;
}
} }

View File

@ -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(); if (state != null) {
TrackEntry entry = state.getCurrent(0); ShapeRenderer shapes = debugRenderer.getShapeRenderer();
if (entry != null) { TrackEntry entry = state.getCurrent(0);
float percent = entry.getTime() / entry.getEndTime(); if (entry != null) {
if (entry.getLoop()) percent %= 1; float percent = entry.getTime() / entry.getEndTime();
float x = ui.window.getRight() + (Gdx.graphics.getWidth() - ui.window.getRight()) * percent; if (entry.getLoop()) percent %= 1;
shapes.setColor(Color.CYAN); float x = ui.window.getRight() + (Gdx.graphics.getWidth() - ui.window.getRight()) * percent;
shapes.begin(ShapeType.Line); shapes.setColor(Color.CYAN);
shapes.line(x, 0, x, 20); shapes.begin(ShapeType.Line);
shapes.end(); shapes.line(x, 0, x, 20);
shapes.end();
}
} }
} }