@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; } }
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));
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); 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);
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; } }
/** * @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"); }
@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; } }
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));
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); 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);
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; } }
/** * @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"); }