vertices[2].set(upper.x, upper.y);\r
vertices[3].set(lower.x, upper.y);\r
\r
- drawSolidPolygon(vertices, 4, AABB_COLOR);\r
+ drawSolidPolygon(vertices, 4, AABB_COLOR, true);\r
} else if (fixture.getType() == Type.Polygon) {\r
PolygonShape shape = (PolygonShape)fixture.getShape();\r
int vertexCount = shape.getVertexCount();\r
vertices[2].set(upper.x, upper.y);\r
vertices[3].set(lower.x, upper.y);\r
\r
- drawSolidPolygon(vertices, 4, AABB_COLOR);\r
+ drawSolidPolygon(vertices, 4, AABB_COLOR, true);\r
}\r
}\r
\r
edge.getVertex2(vertices[1]);\r
transform.mul(vertices[0]);\r
transform.mul(vertices[1]);\r
- drawSolidPolygon(vertices, 2, color);\r
+ drawSolidPolygon(vertices, 2, color, true);\r
}\r
\r
if (fixture.getType() == Type.Polygon) {\r
chain.getVertex(i, vertices[i]);\r
transform.mul(vertices[i]);\r
}\r
- drawSolidPolygon(vertices, vertexCount, color);\r
+ drawSolidPolygon(vertices, vertexCount, color, true);\r
}\r
\r
if (fixture.getType() == Type.Chain) {\r
chain.getVertex(i, vertices[i]);\r
transform.mul(vertices[i]);\r
}\r
- drawSolidPolygon(vertices, vertexCount, color);\r
+ drawSolidPolygon(vertices, vertexCount, color, chain.isLooped());\r
}\r
}\r
\r
renderer.line(center.x, center.y, 0, center.x + axis.x * radius, center.y + axis.y * radius, 0);\r
}\r
\r
- private void drawSolidPolygon (Vector2[] vertices, int vertexCount, Color color) {\r
+ private void drawSolidPolygon (Vector2[] vertices, int vertexCount, Color color, boolean closed) {\r
renderer.setColor(color.r, color.g, color.b, color.a);\r
for (int i = 0; i < vertexCount; i++) {\r
Vector2 v = vertices[i];\r
renderer.line(lv.x, lv.y, v.x, v.y);\r
lv.set(v);\r
}\r
- renderer.line(f.x, f.y, lv.x, lv.y);\r
+ if(closed) renderer.line(f.x, f.y, lv.x, lv.y);\r
}\r
\r
private void drawJoint (Joint joint) {\r
\r
import org.jbox2d.common.Vec2;\r
\r
+import com.badlogic.gdx.graphics.Color;\r
import com.badlogic.gdx.math.Vector2;\r
\r
public class ChainShape extends Shape {\r
org.jbox2d.collision.shapes.ChainShape shape;\r
+ boolean isLooped = false;\r
\r
public ChainShape () {\r
super(new org.jbox2d.collision.shapes.ChainShape());\r
v[i] = new Vec2(vertices[i].x, vertices[i].y);\r
}\r
shape.createLoop(v, v.length);\r
+ isLooped = true;\r
}\r
\r
/** Create a chain with isolated end vertices.\r
v[i] = new Vec2(vertices[i].x, vertices[i].y);\r
}\r
shape.createChain(v, v.length);\r
+ isLooped = false;\r
}\r
\r
/** Establish connectivity to a vertex that precedes the first vertex. Don't call this for loops. */\r
public int getChildCount () {\r
return shape.getChildCount();\r
}\r
+\r
+ public boolean isLooped () {\r
+ return isLooped;\r
+ }\r
}\r
vertices[2].set(upper.x, upper.y);\r
vertices[3].set(lower.x, upper.y);\r
\r
- drawSolidPolygon(vertices, 4, AABB_COLOR);\r
+ drawSolidPolygon(vertices, 4, AABB_COLOR, true);\r
} else if (fixture.getType() == Type.Polygon) {\r
PolygonShape shape = (PolygonShape)fixture.getShape();\r
int vertexCount = shape.getVertexCount();\r
vertices[2].set(upper.x, upper.y);\r
vertices[3].set(lower.x, upper.y);\r
\r
- drawSolidPolygon(vertices, 4, AABB_COLOR);\r
+ drawSolidPolygon(vertices, 4, AABB_COLOR, true);\r
}\r
}\r
\r
edge.getVertex2(vertices[1]);\r
transform.mul(vertices[0]);\r
transform.mul(vertices[1]);\r
- drawSolidPolygon(vertices, 2, color);\r
+ drawSolidPolygon(vertices, 2, color, true);\r
}\r
\r
if (fixture.getType() == Type.Polygon) {\r
chain.getVertex(i, vertices[i]);\r
transform.mul(vertices[i]);\r
}\r
- drawSolidPolygon(vertices, vertexCount, color);\r
+ drawSolidPolygon(vertices, vertexCount, color, true);\r
}\r
\r
if (fixture.getType() == Type.Chain) {\r
chain.getVertex(i, vertices[i]);\r
transform.mul(vertices[i]);\r
}\r
- drawSolidPolygon(vertices, vertexCount, color);\r
+ drawSolidPolygon(vertices, vertexCount, color, false);\r
}\r
}\r
\r
renderer.line(center.x, center.y, 0, center.x + axis.x * radius, center.y + axis.y * radius, 0);\r
}\r
\r
- private void drawSolidPolygon (Vector2[] vertices, int vertexCount, Color color) {\r
+ private void drawSolidPolygon (Vector2[] vertices, int vertexCount, Color color, boolean closed) {\r
renderer.setColor(color.r, color.g, color.b, color.a);\r
for (int i = 0; i < vertexCount; i++) {\r
Vector2 v = vertices[i];\r
renderer.line(lv.x, lv.y, v.x, v.y);\r
lv.set(v);\r
}\r
- renderer.line(f.x, f.y, lv.x, lv.y);\r
+ if(closed) renderer.line(f.x, f.y, lv.x, lv.y);\r
}\r
\r
private void drawJoint (Joint joint) {\r
/*JNI\r
#include <Box2D/Box2D.h>\r
*/\r
+ boolean isLooped = false;\r
\r
public ChainShape () {\r
addr = newChainShape();\r
verts[i + 1] = vertices[j].y;\r
}\r
jniCreateLoop(addr, verts, verts.length / 2);\r
+ isLooped = true;\r
}\r
\r
private native void jniCreateLoop (long addr, float[] verts, int numVertices); /*\r
verts[i + 1] = vertices[j].y;\r
}\r
jniCreateChain(addr, verts, verts.length / 2);\r
+ isLooped = false;\r
}\r
\r
private native void jniCreateChain (long addr, float[] verts, int numVertices); /*\r
verts[0] = v.x;\r
verts[1] = v.y;\r
*/\r
+ \r
+ public boolean isLooped() {\r
+ return isLooped;\r
+ }\r
\r
// /// Implement b2Shape. Vertices are cloned using b2Alloc.\r
// b2Shape* Clone(b2BlockAllocator* allocator) const;\r
config.useGL20 = test.needsGL20();\r
new LwjglApplication(test, config);\r
}\r
+ \r
+ \r
}\r