/** Build vertices to represent an axis-aligned box. * @param hx the half-width. * @param hy the half-height. */ public void setAsBox (float hx, float hy) { shape.setAsBox(hx, hy); }
/** Build vertices to represent an oriented box. * @param hx the half-width. * @param hy the half-height. * @param center the center of the box in local coordinates. * @param angle the rotation in radians of the box in local coordinates. */ public void setAsBox (float hx, float hy, Vector2 center, float angle) { tmp.set(center.x, center.y); shape.setAsBox(hx, hy, tmp, angle); }
@Override public synchronized void step(TestbedSettings settings) { super.step(settings); if (m_count < MAX_NUM) { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(0.0f, 10.0f); Body body = m_world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(0.125f, 0.125f); body.createFixture(shape, 1.0f); ++m_count; } }
@Override public void initTest(boolean deserialized) { { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.allowSleep = false; bd.position.set(0.0f, 10.0f); Body body = m_world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(0.5f, 10.0f, new Vec2(10.0f, 0.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(0.5f, 10.0f, new Vec2(-10.0f, 0.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(10.0f, 0.5f, new Vec2(0.0f, 10.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(10.0f, 0.5f, new Vec2(0.0f, -10.0f), 0.0f); body.createFixture(shape, 5.0f); RevoluteJointDef jd = new RevoluteJointDef(); jd.bodyA = getGroundBody(); jd.bodyB = body; jd.localAnchorA.set(0.0f, 10.0f); jd.localAnchorB.set(0.0f, 0.0f); jd.referenceAngle = 0.0f; jd.motorSpeed = 0.05f * MathUtils.PI; jd.maxMotorTorque = 1e8f; jd.enableMotor = true; m_joint = (RevoluteJoint) m_world.createJoint(jd); } m_count = 0; }
shape.setAsBox(0.5f, 10.0f, new Vec2(20.0f, 0.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(0.5f, 10.0f, new Vec2(-20.0f, 0.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(20.0f, 0.5f, new Vec2(0.0f, 10.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(20.0f, 0.5f, new Vec2(0.0f, -10.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(9.0f, 9.0f, new Vec2(0.0f, 10.0f), 0.0f);
public void makeDomino(float x, float y, boolean horizontal, World world) { PolygonShape sd = new PolygonShape(); sd.setAsBox(.5f * dwidth, .5f * dheight); FixtureDef fd = new FixtureDef(); fd.shape = sd; fd.density = ddensity; BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; fd.friction = dfriction; fd.restitution = 0.65f; bd.position = new Vec2(x, y); bd.angle = horizontal ? (float) (Math.PI / 2.0) : 0f; Body myBody = getWorld().createBody(bd); myBody.createFixture(fd); }
@Override public void initTest(boolean argDeserialized) { input.transformA = new Transform(); input.transformB = new Transform(); { m_transformA = new Transform(); m_transformA.setIdentity(); m_transformA.p.set(0.0f, -0.2f); m_polygonA = new PolygonShape(); m_polygonA.setAsBox(10.0f, 0.2f); } { m_positionB = new Vec2(); m_positionB.set(12.017401f, 0.13678508f); m_angleB = -0.0109265f; m_transformB = new Transform(); m_transformB.set(m_positionB, m_angleB); m_polygonB = new PolygonShape(); m_polygonB.setAsBox(2.0f, 0.1f); } for (int i = 0; i < v.length; i++) { v[i] = new Vec2(); } }
@Override public void initTest(boolean argDeserialized) { // Ground body { BodyDef bd = new BodyDef(); Body ground = getWorld().createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f)); ground.createFixture(shape, 0.0f); } // Breakable dynamic body { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(0.0f, 40.0f); bd.angle = 0.25f * MathUtils.PI; m_body1 = getWorld().createBody(bd); m_shape1 = new PolygonShape(); m_shape1.setAsBox(0.5f, 0.5f, new Vec2(-0.5f, 0.0f), 0.0f); m_piece1 = m_body1.createFixture(m_shape1, 1.0f); m_shape2 = new PolygonShape(); m_shape2.setAsBox(0.5f, 0.5f, new Vec2(0.5f, 0.0f), 0.0f); m_piece2 = m_body1.createFixture(m_shape2, 1.0f); } m_break = false; m_broke = false; }
@Override public void initTest(boolean argDeserialized) { { BodyDef bd = new BodyDef(); Body ground = getWorld().createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f)); ground.createFixture(shape, 0.0f); } BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(0.0f, 10.0f); m_body = getWorld().createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(4.0f, 4.0f, new Vec2(0.0f, 0.0f), 0.0f); m_fixture1 = m_body.createFixture(shape, 10.0f); m_fixture2 = null; }
@Override public void initTest(boolean deserialized) { { BodyDef bd = new BodyDef(); Body ground = m_world.createBody(bd); ChainShape shape = new ChainShape(); Vec2[] vertices = new Vec2[] {new Vec2(-20, 0), new Vec2(20, 0), new Vec2(20, 40), new Vec2(-20, 40)}; shape.createLoop(vertices, 4); ground.createFixture(shape, 0.0f); } m_world.setParticleRadius(0.15f); m_world.setParticleDamping(0.2f); { PolygonShape shape = new PolygonShape(); shape.setAsBox(8, 10, new Vec2(-12, 10.1f), 0); ParticleGroupDef pd = new ParticleGroupDef(); pd.shape = shape; m_world.createParticleGroup(pd); } }
shape.setAsBox(2.0f, 0.5f);
shape.setAsBox(0.5f, 0.5f);
shape.setAsBox(0.6f, 0.125f);
shape.setAsBox(a, a);
shape.setAsBox(2.0f, 0.5f);
shape.setAsBox(3.0f, 0.5f); m_platform = body.createFixture(shape, 0.0f);