public void drawTree(DebugDraw argDraw, DynamicTreeNode node, int spot, int height) { node.aabb.getVertices(drawVecs); color.set(1, (height - spot) * 1f / height, (height - spot) * 1f / height); argDraw.drawPolygon(drawVecs, 4, color); argDraw.getViewportTranform().getWorldToScreen(node.aabb.upperBound, textVec); argDraw.drawString(textVec.x, textVec.y, node.id + "-" + (spot + 1) + "/" + height, color); if (node.child1 != null) { drawTree(argDraw, node.child1, spot + 1, height); } if (node.child2 != null) { drawTree(argDraw, node.child2, spot + 1, height); } } }
continue; Color3f c = new Color3f(0.9f, 0.9f, 0.9f); if (actor == m_rayActor && actor.overlap) { c.set(0.9f, 0.6f, 0.6f); } else if (actor == m_rayActor) { c.set(0.6f, 0.9f, 0.6f); } else if (actor.overlap) { c.set(0.6f, 0.6f, 0.9f); Color3f c = new Color3f(0.7f, 0.7f, 0.7f); m_queryAABB.getVertices(vecs); getDebugDraw().drawPolygon(vecs, 4, c); Color3f c1 = new Color3f(0.2f, 0.9f, 0.2f); Color3f c2 = new Color3f(0.9f, 0.2f, 0.2f); getDebugDraw().drawPoint(m_rayCastInput.p1, 6.0f, c1); getDebugDraw().drawPoint(m_rayCastInput.p2, 6.0f, c2); Color3f cr = new Color3f(0.2f, 0.2f, 0.9f); Vec2 p = m_rayCastInput.p2.sub(m_rayCastInput.p1) .mulLocal(m_rayActor.fraction).addLocal(m_rayCastInput.p1);
@Override public void step(TestbedSettings settings) { boolean advanceRay = settings.pause == false || settings.singleStep; super.step(settings); addTextLine("Press 1-5 to drop stuff"); float L = 25.0f; Vec2 point1 = new Vec2(0.0f, 10.0f); Vec2 d = new Vec2(L * MathUtils.cos(m_angle), -L * MathUtils.abs(MathUtils.sin(m_angle))); Vec2 point2 = point1.add(d); callback.m_fixture = null; getWorld().raycast(callback, point1, point2); if (callback.m_fixture != null) { getDebugDraw().drawPoint(callback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, callback.m_point, new Color3f(0.8f, 0.8f, 0.8f)); Vec2 head = callback.m_normal.mul(.5f).addLocal(callback.m_point); getDebugDraw().drawSegment(callback.m_point, head, new Color3f(0.9f, 0.9f, 0.4f)); } else { getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); } if (advanceRay) { m_angle += 0.25f * MathUtils.PI / 180.0f; } }
continue; Color3f c = new Color3f(0.9f, 0.9f, 0.9f); if (actor == m_rayActor && actor.overlap) { c.set(0.9f, 0.6f, 0.6f); } else if (actor == m_rayActor) { c.set(0.6f, 0.9f, 0.6f); } else if (actor.overlap) { c.set(0.6f, 0.6f, 0.9f); Color3f c = new Color3f(0.7f, 0.7f, 0.7f); m_queryAABB.getVertices(vecs); getDebugDraw().drawPolygon(vecs, 4, c); Color3f c1 = new Color3f(0.2f, 0.9f, 0.2f); Color3f c2 = new Color3f(0.9f, 0.2f, 0.2f); getDebugDraw().drawPoint(m_rayCastInput.p1, 6.0f, c1); getDebugDraw().drawPoint(m_rayCastInput.p2, 6.0f, c2); Color3f cr = new Color3f(0.2f, 0.2f, 0.9f); Vec2 p = m_rayCastInput.p2.sub(m_rayCastInput.p1) .mulLocal(m_rayActor.fraction).addLocal(m_rayCastInput.p1);
getDebugDraw().drawPoint(ccallback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, ccallback.m_point, new Color3f(0.8f, 0.8f, 0.8f)); pooledHead.set(ccallback.m_normal); pooledHead.mulLocal(.5f).addLocal(ccallback.m_point); getDebugDraw().drawSegment(ccallback.m_point, pooledHead, new Color3f(0.9f, 0.9f, 0.4f)); } else { getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); getDebugDraw().drawPoint(acallback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, acallback.m_point, new Color3f(0.8f, 0.8f, 0.8f)); pooledHead.set(acallback.m_normal); pooledHead.mulLocal(.5f).addLocal(acallback.m_point); getDebugDraw().drawSegment(acallback.m_point, pooledHead, new Color3f(0.9f, 0.9f, 0.4f)); } else { getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); getDebugDraw().drawPoint(p, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, p, new Color3f(0.8f, 0.8f, 0.8f)); pooledHead.set(n); pooledHead.mulLocal(.5f).addLocal(p); getDebugDraw().drawSegment(p, pooledHead, new Color3f(0.9f, 0.9f, 0.4f));
public void drawTree(DebugDraw argDraw, int node, int spot, int height) { AABB a = m_aabb[node]; a.getVertices(drawVecs); color.set(1, (height - spot) * 1f / height, (height - spot) * 1f / height); argDraw.drawPolygon(drawVecs, 4, color); argDraw.getViewportTranform().getWorldToScreen(a.upperBound, textVec); argDraw.drawString(textVec.x, textVec.y, node + "-" + (spot + 1) + "/" + height, color); int c1 = m_child1[node]; int c2 = m_child2[node]; if (c1 != NULL_NODE) { drawTree(argDraw, c1, spot + 1, height); } if (c2 != NULL_NODE) { drawTree(argDraw, c2, spot + 1, height); } } }
void DrawFixture(Fixture fixture) { Color3f color = new Color3f(0.95f, 0.95f, 0.6f); final Transform xf = fixture.getBody().getTransform(); switch (fixture.getType()) { case CIRCLE: { CircleShape circle = (CircleShape) fixture.getShape(); Vec2 center = Transform.mul(xf, circle.m_p); float radius = circle.m_radius; debugDraw.drawCircle(center, radius, color); } break; case POLYGON: { PolygonShape poly = (PolygonShape) fixture.getShape(); int vertexCount = poly.m_count; assert (vertexCount <= Settings.maxPolygonVertices); Vec2 vertices[] = new Vec2[Settings.maxPolygonVertices]; for (int i = 0; i < vertexCount; ++i) { vertices[i] = Transform.mul(xf, poly.m_vertices[i]); } debugDraw.drawPolygon(vertices, vertexCount, color); } break; default: break; } }
for (Fixture f = b.getFixtureList(); f != null; f = f.getNext()) { if (b.isActive() == false) { color.set(0.5f, 0.5f, 0.3f); drawShape(f, xf, color, wireframe); } else if (b.getType() == BodyType.STATIC) { color.set(0.5f, 0.9f, 0.3f); drawShape(f, xf, color, wireframe); } else if (b.getType() == BodyType.KINEMATIC) { color.set(0.5f, 0.5f, 0.9f); drawShape(f, xf, color, wireframe); } else if (b.isAwake() == false) { color.set(0.5f, 0.5f, 0.5f); drawShape(f, xf, color, wireframe); } else { color.set(0.9f, 0.7f, 0.7f); drawShape(f, xf, color, wireframe); color.set(0.3f, 0.9f, 0.9f); for (Contact c = m_contactManager.m_contactList; c != null; c = c.getNext()) { Fixture fixtureA = c.getFixtureA(); color.set(0.9f, 0.3f, 0.9f);
/** * @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.TestbedSettings) */ @Override public void step(TestbedSettings settings) { super.step(settings); PolyShapesCallback callback = new PolyShapesCallback(getWorld().getPool()); callback.m_circle.m_radius = 2.0f; callback.m_circle.m_p.set(0.0f, 2.1f); callback.m_transform.setIdentity(); callback.debugDraw = getDebugDraw(); AABB aabb = new AABB(); callback.m_circle.computeAABB(aabb, callback.m_transform, 0); getWorld().queryAABB(callback, aabb); Color3f color = new Color3f(0.4f, 0.7f, 0.8f); getDebugDraw().drawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color); addTextLine("Press 1-5 to drop stuff"); addTextLine("Press 'a' to (de)activate some bodies"); addTextLine("Press 'd' to destroy a body"); addTextLine("Up to 30 bodies in the target circle are highlighted"); }
joint.getAnchorB(p2); color.set(0.5f, 0.8f, 0.8f);
@Override public void step(TestbedSettings settings) { boolean advanceRay = settings.pause == false || settings.singleStep; super.step(settings); addTextLine("Press 1-5 to drop stuff"); float L = 25.0f; Vec2 point1 = new Vec2(0.0f, 10.0f); Vec2 d = new Vec2(L * MathUtils.cos(m_angle), -L * MathUtils.abs(MathUtils.sin(m_angle))); Vec2 point2 = point1.add(d); callback.m_fixture = null; getWorld().raycast(callback, point1, point2); if (callback.m_fixture != null) { getDebugDraw().drawPoint(callback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, callback.m_point, new Color3f(0.8f, 0.8f, 0.8f)); Vec2 head = callback.m_normal.mul(.5f).addLocal(callback.m_point); getDebugDraw().drawSegment(callback.m_point, head, new Color3f(0.9f, 0.9f, 0.4f)); } else { getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); } if (advanceRay) { m_angle += 0.25f * MathUtils.PI / 180.0f; } }
public void drawTree(DebugDraw argDraw, DynamicTreeNode node, int spot, int height) { node.aabb.getVertices(drawVecs); color.set(1, (height - spot) * 1f / height, (height - spot) * 1f / height); argDraw.drawPolygon(drawVecs, 4, color); argDraw.getViewportTranform().getWorldToScreen(node.aabb.upperBound, textVec); argDraw.drawString(textVec.x, textVec.y, node.id + "-" + (spot + 1) + "/" + height, color); if (node.child1 != null) { drawTree(argDraw, node.child1, spot + 1, height); } if (node.child2 != null) { drawTree(argDraw, node.child2, spot + 1, height); } } }
getDebugDraw().drawPoint(ccallback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, ccallback.m_point, new Color3f(0.8f, 0.8f, 0.8f)); pooledHead.set(ccallback.m_normal); pooledHead.mulLocal(.5f).addLocal(ccallback.m_point); getDebugDraw().drawSegment(ccallback.m_point, pooledHead, new Color3f(0.9f, 0.9f, 0.4f)); } else { getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); getDebugDraw().drawPoint(acallback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, acallback.m_point, new Color3f(0.8f, 0.8f, 0.8f)); pooledHead.set(acallback.m_normal); pooledHead.mulLocal(.5f).addLocal(acallback.m_point); getDebugDraw().drawSegment(acallback.m_point, pooledHead, new Color3f(0.9f, 0.9f, 0.4f)); } else { getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f)); getDebugDraw().drawPoint(p, 5.0f, new Color3f(0.4f, 0.9f, 0.4f)); getDebugDraw().drawSegment(point1, p, new Color3f(0.8f, 0.8f, 0.8f)); pooledHead.set(n); pooledHead.mulLocal(.5f).addLocal(p); getDebugDraw().drawSegment(p, pooledHead, new Color3f(0.9f, 0.9f, 0.4f));
public void drawTree(DebugDraw argDraw, int node, int spot, int height) { AABB a = m_aabb[node]; a.getVertices(drawVecs); color.set(1, (height - spot) * 1f / height, (height - spot) * 1f / height); argDraw.drawPolygon(drawVecs, 4, color); argDraw.getViewportTranform().getWorldToScreen(a.upperBound, textVec); argDraw.drawString(textVec.x, textVec.y, node + "-" + (spot + 1) + "/" + height, color); int c1 = m_child1[node]; int c2 = m_child2[node]; if (c1 != NULL_NODE) { drawTree(argDraw, c1, spot + 1, height); } if (c2 != NULL_NODE) { drawTree(argDraw, c2, spot + 1, height); } } }
void DrawFixture(Fixture fixture) { Color3f color = new Color3f(0.95f, 0.95f, 0.6f); final Transform xf = fixture.getBody().getTransform(); switch (fixture.getType()) { case CIRCLE: { CircleShape circle = (CircleShape) fixture.getShape(); Vec2 center = Transform.mul(xf, circle.m_p); float radius = circle.m_radius; debugDraw.drawCircle(center, radius, color); } break; case POLYGON: { PolygonShape poly = (PolygonShape) fixture.getShape(); int vertexCount = poly.m_count; assert (vertexCount <= Settings.maxPolygonVertices); Vec2 vertices[] = new Vec2[Settings.maxPolygonVertices]; for (int i = 0; i < vertexCount; ++i) { vertices[i] = Transform.mul(xf, poly.m_vertices[i]); } debugDraw.drawPolygon(vertices, vertexCount, color); } break; default: break; } }
for (Fixture f = b.getFixtureList(); f != null; f = f.getNext()) { if (b.isActive() == false) { color.set(0.5f, 0.5f, 0.3f); drawShape(f, xf, color, wireframe); } else if (b.getType() == BodyType.STATIC) { color.set(0.5f, 0.9f, 0.3f); drawShape(f, xf, color, wireframe); } else if (b.getType() == BodyType.KINEMATIC) { color.set(0.5f, 0.5f, 0.9f); drawShape(f, xf, color, wireframe); } else if (b.isAwake() == false) { color.set(0.5f, 0.5f, 0.5f); drawShape(f, xf, color, wireframe); } else { color.set(0.9f, 0.7f, 0.7f); drawShape(f, xf, color, wireframe); color.set(0.3f, 0.9f, 0.9f); for (Contact c = m_contactManager.m_contactList; c != null; c = c.getNext()) { Fixture fixtureA = c.getFixtureA(); color.set(0.9f, 0.3f, 0.9f);
/** * @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.TestbedSettings) */ @Override public void step(TestbedSettings settings) { super.step(settings); PolyShapesCallback callback = new PolyShapesCallback(getWorld().getPool()); callback.m_circle.m_radius = 2.0f; callback.m_circle.m_p.set(0.0f, 2.1f); callback.m_transform.setIdentity(); callback.debugDraw = getDebugDraw(); AABB aabb = new AABB(); callback.m_circle.computeAABB(aabb, callback.m_transform, 0); getWorld().queryAABB(callback, aabb); Color3f color = new Color3f(0.4f, 0.7f, 0.8f); getDebugDraw().drawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color); addTextLine("Press 1-5 to drop stuff"); addTextLine("Press 'a' to (de)activate some bodies"); addTextLine("Press 'd' to destroy a body"); addTextLine("Up to 30 bodies in the target circle are highlighted"); }
joint.getAnchorB(p2); color.set(0.5f, 0.8f, 0.8f);
public void drawTree(DebugDraw argDraw, DynamicTreeNode node, int spot, int height) { node.aabb.getVertices(drawVecs); color.set(1, (height - spot) * 1f / height, (height - spot) * 1f / height); argDraw.drawPolygon(drawVecs, 4, color); argDraw.getViewportTranform().getWorldToScreen(node.aabb.upperBound, textVec); argDraw.drawString(textVec.x, textVec.y, node.id + "-" + (spot + 1) + "/" + height, color); if (node.child1 != null) { drawTree(argDraw, node.child1, spot + 1, height); } if (node.child2 != null) { drawTree(argDraw, node.child2, spot + 1, height); } }
public void drawTree(DebugDraw argDraw, DynamicTreeNode node, int spot, int height) { node.aabb.getVertices(drawVecs); color.set(1, (height - spot) * 1f / height, (height - spot) * 1f / height); argDraw.drawPolygon(drawVecs, 4, color); argDraw.getViewportTranform().getWorldToScreen(node.aabb.upperBound, textVec); argDraw.drawString(textVec.x, textVec.y, node.id + "-" + (spot + 1) + "/" + height, color); if (node.child1 != null) { drawTree(argDraw, node.child1, spot + 1, height); } if (node.child2 != null) { drawTree(argDraw, node.child2, spot + 1, height); } } }