/** Get the body transform for the body's origin. */ public Transform getTransform () { org.jbox2d.common.Transform trans = body.getTransform(); transform.vals[Transform.POS_X] = trans.p.x; transform.vals[Transform.POS_Y] = trans.p.y; transform.vals[Transform.COS] = trans.q.c; transform.vals[Transform.SIN] = trans.q.s; return transform; }
/** * Compute the distance from this fixture. * * @param p a point in world coordinates. * @return distance */ public float computeDistance(Vec2 p, int childIndex, Vec2 normalOut) { return m_shape.computeDistanceToOut(m_body.getTransform(), p, childIndex, normalOut); }
/** * Get the world manifold. */ public void getWorldManifold(WorldManifold worldManifold) { final Body bodyA = m_fixtureA.getBody(); final Body bodyB = m_fixtureB.getBody(); final Shape shapeA = m_fixtureA.getShape(); final Shape shapeB = m_fixtureB.getShape(); worldManifold.initialize(m_manifold, bodyA.getTransform(), shapeA.m_radius, bodyB.getTransform(), shapeB.m_radius); }
protected MouseJoint(IWorldPool argWorld, MouseJointDef def) { super(argWorld, def); assert (def.target.isValid()); assert (def.maxForce >= 0); assert (def.frequencyHz >= 0); assert (def.dampingRatio >= 0); m_targetA.set(def.target); Transform.mulTransToOutUnsafe(m_bodyB.getTransform(), m_targetA, m_localAnchorB); m_maxForce = def.maxForce; m_impulse.setZero(); m_frequencyHz = def.frequencyHz; m_dampingRatio = def.dampingRatio; m_beta = 0; m_gamma = 0; }
Transform xfA = bodyA.getTransform(); Transform xfB = bodyB.getTransform();
private void drawJoint(Joint joint) { Body bodyA = joint.getBodyA(); Body bodyB = joint.getBodyB(); Transform xf1 = bodyA.getTransform(); Transform xf2 = bodyB.getTransform(); Vec2 x1 = xf1.p; Vec2 x2 = xf2.p;
/** * Compute the distance from this fixture. * * @param p a point in world coordinates. * @return distance */ public float computeDistance(Vec2 p, int childIndex, Vec2 normalOut) { return m_shape.computeDistanceToOut(m_body.getTransform(), p, childIndex, normalOut); }
xf.set(b.getTransform()); for (Fixture f = b.getFixtureList(); f != null; f = f.getNext()) { if (b.isActive() == false) { xf.set(b.getTransform()); xf.p.set(b.getWorldCenter()); m_debugDraw.drawTransform(xf);
/** * Get the world manifold. */ public void getWorldManifold(WorldManifold worldManifold) { final Body bodyA = m_fixtureA.getBody(); final Body bodyB = m_fixtureB.getBody(); final Shape shapeA = m_fixtureA.getShape(); final Shape shapeB = m_fixtureB.getShape(); worldManifold.initialize(m_manifold, bodyA.getTransform(), shapeA.m_radius, bodyB.getTransform(), shapeB.m_radius); }
protected MouseJoint(IWorldPool argWorld, MouseJointDef def) { super(argWorld, def); assert (def.target.isValid()); assert (def.maxForce >= 0); assert (def.frequencyHz >= 0); assert (def.dampingRatio >= 0); m_targetA.set(def.target); Transform.mulTransToOutUnsafe(m_bodyB.getTransform(), m_targetA, m_localAnchorB); m_maxForce = def.maxForce; m_impulse.setZero(); m_frequencyHz = def.frequencyHz; m_dampingRatio = def.dampingRatio; m_beta = 0; m_gamma = 0; }
@Override public void step(TestbedSettings settings) { super.step(settings); addTextLine("Keys: (d) dynamic, (s) static, (k) kinematic"); // Drive the kinematic body. if (m_platform.getType() == BodyType.KINEMATIC) { Vec2 p = m_platform.getTransform().p; Vec2 v = m_platform.getLinearVelocity(); if ((p.x < -10.0f && v.x < 0.0f) || (p.x > 10.0f && v.x > 0.0f)) { v.x = -v.x; m_platform.setLinearVelocity(v); } } }
public boolean reportFixture(Fixture fixture) { if (m_count == e_maxCount) { return false; } Body body = fixture.getBody(); Shape shape = fixture.getShape(); boolean overlap = p.getCollision().testOverlap(shape, 0, m_circle, 0, body.getTransform(), m_transform); if (overlap) { DrawFixture(fixture); ++m_count; } return true; } }
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; } }
@Override public void step(TestbedSettings settings) { super.step(settings); Vec2 p = circle.getTransform().p; Vec2 v = circle.getLinearVelocity(); if ((p.x < -10.0f && v.x < 0.0f) || (p.x > 10.0f && v.x > 0.0f)) { v.x = -v.x; circle.setLinearVelocity(v); } int[] flagsBuffer = m_world.getParticleFlagsBuffer(); for (int i = 0; i < m_world.getParticleCount(); i++) { flagsBuffer[i] = flags; } addTextLine("'a' Clear"); addTextLine("'e' Elastic " + ((flags & ParticleType.b2_elasticParticle) != 0)); addTextLine("'q' Powder " + ((flags & ParticleType.b2_powderParticle) != 0)); addTextLine("'t' Tensile " + ((flags & ParticleType.b2_tensileParticle) != 0)); addTextLine("'v' Viscous " + ((flags & ParticleType.b2_viscousParticle) != 0)); }
Transform xfA = bodyA.getTransform(); Transform xfB = bodyB.getTransform();
private void drawJoint(Joint joint) { Body bodyA = joint.getBodyA(); Body bodyB = joint.getBodyB(); Transform xf1 = bodyA.getTransform(); Transform xf2 = bodyB.getTransform(); Vec2 x1 = xf1.p; Vec2 x2 = xf2.p;
/** * Compute the distance from this fixture. * * @param p a point in world coordinates. * @return distance */ public float computeDistance(Vec2 p, int childIndex, Vec2 normalOut) { return shape.computeDistanceToOut(body.getTransform(), p, childIndex, normalOut); }
/** * Compute the distance from this fixture. * * @param p a point in world coordinates. * @return distance */ public float computeDistance(Vec2 p, int childIndex, Vec2 normalOut) { return m_shape.computeDistanceToOut(m_body.getTransform(), p, childIndex, normalOut); }
/** * Get the world manifold. */ public void getWorldManifold(WorldManifold worldManifold) { final Body bodyA = m_fixtureA.getBody(); final Body bodyB = m_fixtureB.getBody(); final Shape shapeA = m_fixtureA.getShape(); final Shape shapeB = m_fixtureB.getShape(); worldManifold.initialize(m_manifold, bodyA.getTransform(), shapeA.m_radius, bodyB.getTransform(), shapeB.m_radius); }
xf.set(b.getTransform()); for (Fixture f = b.getFixtureList(); f != null; f = f.getNext()) { if (b.isActive() == false) { xf.set(b.getTransform()); xf.p.set(b.getWorldCenter()); m_debugDraw.drawTransform(xf);