circCenterMoved.set(center).addLocal(liquidOffset); center.subLocal(liquidOffset); m_debugDraw.drawSegment(center, circCenterMoved, liquidColor); return; m_debugDraw.drawCircle(center, radius, axis, color); } else { m_debugDraw.drawSolidCircle(center, radius, axis, color); m_debugDraw.drawPolygon(vertices, vertexCount, color); } else { m_debugDraw.drawSolidPolygon(vertices, vertexCount, color); Transform.mulToOutUnsafe(xf, edge.m_vertex1, v1); Transform.mulToOutUnsafe(xf, edge.m_vertex2, v2); m_debugDraw.drawSegment(v1, v2, color); for (int i = 1; i < count; ++i) { Transform.mulToOutUnsafe(xf, vertices[i], v2); m_debugDraw.drawSegment(v1, v2, color); m_debugDraw.drawCircle(v1, 0.05f, color); v1.set(v2);
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); } } }
private void drawParticleSystem(ParticleSystem system) { boolean wireframe = (m_debugDraw.getFlags() & DebugDraw.e_wireframeDrawingBit) != 0; int particleCount = system.getParticleCount(); if (particleCount != 0) { float particleRadius = system.getParticleRadius(); Vec2[] positionBuffer = system.getParticlePositionBuffer(); ParticleColor[] colorBuffer = null; if (system.m_colorBuffer.data != null) { colorBuffer = system.getParticleColorBuffer(); } if (wireframe) { m_debugDraw.drawParticlesWireframe(positionBuffer, particleRadius, colorBuffer, particleCount); } else { m_debugDraw.drawParticles(positionBuffer, particleRadius, colorBuffer, particleCount); } } }
int flags = m_debugDraw.getFlags(); boolean wireframe = (flags & DebugDraw.e_wireframeDrawingBit) != 0; fixtureA.getAABB(c.getChildIndexA()).getCenterToOut(cA); fixtureB.getAABB(c.getChildIndexB()).getCenterToOut(cB); m_debugDraw.drawSegment(cA, cB, color); vs[2].set(aabb.upperBound.x, aabb.upperBound.y); vs[3].set(aabb.lowerBound.x, aabb.upperBound.y); m_debugDraw.drawPolygon(vs, 4, color); xf.set(b.getTransform()); xf.p.set(b.getWorldCenter()); m_debugDraw.drawTransform(xf); m_debugDraw.flush();
getDebugDraw().drawPolygon(vecs, 4, c); getDebugDraw().drawPolygon(vecs, 4, c); getDebugDraw().drawSegment(m_rayCastInput.p1, m_rayCastInput.p2, c); getDebugDraw().drawPoint(m_rayCastInput.p1, 6.0f, c1); getDebugDraw().drawPoint(m_rayCastInput.p2, 6.0f, c2); Vec2 p = m_rayCastInput.p2.sub(m_rayCastInput.p1) .mulLocal(m_rayActor.fraction).addLocal(m_rayCastInput.p1); getDebugDraw().drawPoint(p, 6.0f, cr); getDebugDraw().drawString(5, 30, "(c)reate proxy, (d)estroy proxy, (a)utomate", Color3f.WHITE);
debugDraw.drawString(camera.getTransform().getExtents().x, 15, title, Color3f.WHITE); m_textLine += TEXT_LINE_SPACE; debugDraw.drawString(5, m_textLine, "****PAUSED****", Color3f.WHITE); m_textLine += TEXT_LINE_SPACE; ? DebugDraw.e_wireframeDrawingBit : 0; debugDraw.setFlags(flags); debugDraw.drawString(5, m_textLine, "Engine Info", color4); m_textLine += TEXT_LINE_SPACE; debugDraw.drawString(5, m_textLine, "Framerate: " + (int) model.getCalculatedFps(), Color3f.WHITE); m_textLine += TEXT_LINE_SPACE; int particleCount = m_world.getParticleCount(); int groupCount = m_world.getParticleGroupCount(); debugDraw.drawString( 5, m_textLine, debugDraw.drawString(5, m_textLine, "World mouse position: " + mouseWorld.toString(), Color3f.WHITE); m_textLine += TEXT_LINE_SPACE; debugDraw.drawString(5, m_textLine, s, Color3f.WHITE); m_textLine += TEXT_LINE_SPACE;
/** * Draw a closed polygon provided in CCW order. This implementation uses * {@link #drawSegment(Vec2, Vec2, Color3f)} to draw each side of the polygon. * * @param vertices * @param vertexCount * @param color */ public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) { if (vertexCount == 1) { drawSegment(vertices[0], vertices[0], color); return; } for (int i = 0; i < vertexCount - 1; i += 1) { drawSegment(vertices[i], vertices[i + 1], color); } if (vertexCount > 2) { drawSegment(vertices[vertexCount - 1], vertices[0], color); } }
@Override public synchronized void step(TestbedSettings settings) { super.step(settings); shape.set(m_points, m_count); addTextLine("Press g to generate a new random convex hull"); getDebugDraw().drawPolygon(shape.m_vertices, shape.m_count, color); for (int i = 0; i < m_count; ++i) { getDebugDraw().drawPoint(m_points[i], 2.0f, color2); getDebugDraw().drawString(m_points[i].add(new Vec2(0.05f, 0.05f)), i + "", Color3f.WHITE); } assert (shape.validate()); if (m_auto) { generate(); } }
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; } }
/** Draws a circle with an axis */ public void drawCircle(Vec2 center, float radius, Vec2 axis, Color3f color) { drawCircle(center, radius, color); }
public void drawString(Vec2 pos, String s, Color3f color) { drawString(pos.x, pos.y, s, color); }
@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; } }
Transform.mulToOutUnsafe(m_transformA, m_polygonA.m_vertices[i], v[i]); getDebugDraw().drawPolygon(v, m_polygonA.m_count, color); getDebugDraw().drawPolygon(v, m_polygonB.m_count, color); Vec2 x2 = output.pointB; getDebugDraw().drawPoint(x1, 4.0f, c1); getDebugDraw().drawPoint(x2, 4.0f, c2);
public void mouseWheelMoved(MouseWheelEvent e) { DebugDraw d = draw; int notches = e.getWheelRotation(); TestbedTest currTest = model.getCurrTest(); if (currTest == null) { return; } OBBViewportTransform trans = (OBBViewportTransform) d.getViewportTranform(); oldCenter.set(model.getCurrTest().getWorldMouse()); // Change the zoom and clamp it to reasonable values - can't clamp now. if (notches < 0) { trans.mulByTransform(upScale); currTest.setCachedCameraScale(currTest.getCachedCameraScale() * ZOOM_IN_SCALE); } else if (notches > 0) { trans.mulByTransform(downScale); currTest.setCachedCameraScale(currTest.getCachedCameraScale() * ZOOM_OUT_SCALE); } d.getScreenToWorldToOut(model.getMouse(), newCenter); Vec2 transformedMove = oldCenter.subLocal(newCenter); d.getViewportTranform().setCenter( d.getViewportTranform().getCenter().addLocal(transformedMove)); currTest.setCachedCameraPos(d.getViewportTranform().getCenter()); } });
public void setCamera(Vec2 argPos) { model.getDebugDraw().getViewportTranform().setCenter(argPos); }
int flags = m_debugDraw.getFlags(); boolean wireframe = (flags & DebugDraw.e_wireframeDrawingBit) != 0; fixtureA.getAABB(c.getChildIndexA()).getCenterToOut(cA); fixtureB.getAABB(c.getChildIndexB()).getCenterToOut(cB); m_debugDraw.drawSegment(cA, cB, color); vs[2].set(aabb.upperBound.x, aabb.upperBound.y); vs[3].set(aabb.lowerBound.x, aabb.upperBound.y); m_debugDraw.drawPolygon(vs, 4, color); xf.set(b.getTransform()); xf.p.set(b.getWorldCenter()); m_debugDraw.drawTransform(xf); m_debugDraw.flush();
getDebugDraw().drawPolygon(vecs, 4, c); getDebugDraw().drawPolygon(vecs, 4, c); getDebugDraw().drawSegment(m_rayCastInput.p1, m_rayCastInput.p2, c); getDebugDraw().drawPoint(m_rayCastInput.p1, 6.0f, c1); getDebugDraw().drawPoint(m_rayCastInput.p2, 6.0f, c2); Vec2 p = m_rayCastInput.p2.sub(m_rayCastInput.p1) .mulLocal(m_rayActor.fraction).addLocal(m_rayCastInput.p1); getDebugDraw().drawPoint(p, 6.0f, cr); getDebugDraw().drawString(5, m_textLine, "(c)reate proxy, (d)estroy proxy, (a)utomate", Color3f.WHITE);
debugDraw.drawString(5, m_textLine, "****PAUSED****", Color3f.WHITE); m_textLine += 15; settings.getSetting(TestbedSettings.DrawCOMs).enabled ? DebugDraw.e_centerOfMassBit : 0; flags += settings.getSetting(TestbedSettings.DrawTree).enabled ? DebugDraw.e_dynamicTreeBit : 0; debugDraw.setFlags(flags); debugDraw.drawString(5, m_textLine, "Engine Info", color4); m_textLine += 15; debugDraw.drawString(5, m_textLine, "Framerate: " + model.getCalculatedFps(), Color3f.WHITE); m_textLine += 15; debugDraw.drawString( 5, m_textLine, + m_world.getProxyCount(), Color3f.WHITE); m_textLine += 15; debugDraw.drawString(5, m_textLine, "World mouse position: " + mouseWorld.toString(), Color3f.WHITE); m_textLine += 15; debugDraw.drawString(5, m_textLine, s, Color3f.WHITE); m_textLine += 15; debugDraw.drawString(5, m_textLine, "Help", color4); m_textLine += 15; debugDraw.drawString(5, m_textLine, "Click and drag the left mouse button to move objects.", Color3f.WHITE); m_textLine += 15;
m_debugDraw.drawSegment(p1, p2, color); break; Vec2 s1 = pulley.getGroundAnchorA(); Vec2 s2 = pulley.getGroundAnchorB(); m_debugDraw.drawSegment(s1, p1, color); m_debugDraw.drawSegment(s2, p2, color); m_debugDraw.drawSegment(s1, s2, color); m_debugDraw.drawSegment(x1, p1, color); m_debugDraw.drawSegment(p1, p2, color); m_debugDraw.drawSegment(x2, p2, color);
@Override public synchronized void step(TestbedSettings settings) { super.step(settings); shape.set(m_points, count); addTextLine("Press g to generate a new random convex hull"); getDebugDraw().drawPolygon(shape.m_vertices, shape.m_count, color); for (int i = 0; i < count; ++i) { getDebugDraw().drawPoint(m_points[i], 2.0f, color2); getDebugDraw().drawString(m_points[i].add(new Vec2(0.05f, 0.05f)), i + "", Color3f.WHITE); } assert (shape.validate()); if (m_auto) { generate(); } }