/** Get the centroid and apply the supplied transform. */ public Vec2 centroid(final Transform xf) { return Transform.mul(xf, m_centroid); }
/** Get the centroid and apply the supplied transform. */ public Vec2 centroid(final Transform xf) { return Transform.mul(xf, m_centroid); }
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; } }
/** Get the centroid and apply the supplied transform. */ public Vec2 centroid(final Transform xf) { return Transform.mul(xf, m_centroid); }
/** Get the centroid and apply the supplied transform. */ public Vec2 centroid(final Transform xf) { return Transform.mul(xf, m_centroid); }
/** Get the centroid and apply the supplied transform. */ public Vec2 centroid(final Transform xf) { return Transform.mul(xf, m_centroid); }
vertices[0] = Transform.mul(xf1, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf1, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf1, new Vec2(0.0f, 0.5f)); Rot.mulToOut(xf2.q, new Vec2(-1.0f, 0.0f), xf2.p); vertices[0] = Transform.mul(xf2, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf2, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf2, new Vec2(0.0f, 0.5f));
vertices[0] = Transform.mul(xf1, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf1, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf1, new Vec2(0.0f, 0.5f)); triangle1.set(vertices, 3); vertices[0] = Transform.mul(xf2, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf2, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf2, new Vec2(0.0f, 0.5f)); triangle2.set(vertices, 3);
// we need to get the body's position, let's use a Vector2 to store it. Vector2 vec = new Vector2(); Body body = fixture.getBody(); // what is this magic? Why, it's a wonderful object that transforms fixture // position information based on the body's position! Transform transform = body.getTransform(); CircleShape shape = (CircleShape) fixture.getShape(); vec.set(shape.getPosition()); // apply the transformation transform.mul(vec); // now vec.x and vec.y will be what you want!
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; } }
vertices[0] = Transform.mul(xf1, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf1, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf1, new Vec2(0.0f, 0.5f)); Rot.mulToOut(xf2.q, new Vec2(-1.0f, 0.0f), xf2.p); vertices[0] = Transform.mul(xf2, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf2, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf2, new Vec2(0.0f, 0.5f));
vertices[0] = Transform.mul(xf1, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf1, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf1, new Vec2(0.0f, 0.5f)); triangle1.set(vertices, 3); vertices[0] = Transform.mul(xf2, new Vec2(-1.0f, 0.0f)); vertices[1] = Transform.mul(xf2, new Vec2(1.0f, 0.0f)); vertices[2] = Transform.mul(xf2, new Vec2(0.0f, 0.5f)); triangle2.set(vertices, 3);