private void joinReelToAxis() { RevoluteJointDef jointDef = new RevoluteJointDef(); jointDef.bodyA = axis; jointDef.bodyB = reel; world.createJoint(jointDef); }
RevoluteJointDef jointDef = new RevoluteJointDef(); jointDef.initialize(pendulum, ground, new Vec2(0, 0)); else jointDef.initialize(ground, pendulum, new Vec2(0, 0));
RevoluteJointDef jointDef = new RevoluteJointDef(); Vector2 anchor = (new Vector2(-width,-height/2)).add(chassis.getWorldCenter()); jointDef.initialize(chassis, wheel, anchor); jointDef.collideConnected = true; world.createJoint(jointDef);
RevoluteJointDef jointDef = new RevoluteJointDef(); jointDef.initialize(pendulum, base, new Vec2(0, 0)); else jointDef.initialize(base, pendulum, new Vec2(0, 0));
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.RevoluteJointDef jd = new org.jbox2d.dynamics.joints.RevoluteJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.enableLimit = enableLimit; jd.enableMotor = enableMotor; jd.localAnchorA.set(localAnchorA.x, localAnchorA.y); jd.localAnchorB.set(localAnchorB.x, localAnchorB.y); jd.lowerAngle = lowerAngle; jd.maxMotorTorque = maxMotorTorque; jd.motorSpeed = motorSpeed; jd.referenceAngle = referenceAngle; jd.type = org.jbox2d.dynamics.joints.JointType.REVOLUTE; jd.upperAngle = upperAngle; return jd; } }
fd.friction = 0.2f; RevoluteJointDef jd = new RevoluteJointDef(); jd.collideConnected = false; jd.initialize(prevBody, body, anchor); getWorld().createJoint(jd);
private void Joint(Body A,Body B) { RevoluteJointDef jointDef = new RevoluteJointDef(); jointDef.bodyA = A; jointDef.bodyB = B; jointDef.type = JointDef.JointType.RevoluteJoint; jointDef.collideConnected = true; jointDef.localAnchorA.set(5, 0); jointDef.localAnchorB.set(5,0); jointDef.collideConnected=false; jointDef.enableMotor=true; jointDef.motorSpeed=1; jointDef.maxMotorTorque=50; world.createJoint(jointDef); }
body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 5.0f)); rjd.motorSpeed = 1.0f * MathUtils.PI; rjd.maxMotorTorque = 10000.0f; body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 9.0f)); rjd.enableMotor = false; getWorld().createJoint(rjd); body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f)); getWorld().createJoint(rjd);
RevoluteJointDef jointDef = new RevoluteJointDef(); Vector2 anchor = (new Vector2(-width,-height/2)).add(chassis.getWorldCenter()); jointDef.bodyA = chassis; jointDef.bodyB = wheel; jointDef.localAnchorA = chassis.getLocalPoint(anchor); jointDef.localAnchorB = wheel.getLocalPoint(anchor); jointDef.referenceAngle = wheel.getAngle() - chassis.getAngle(); world.createJoint(jointDef);
body3.createFixture(circle2, 5.0f); RevoluteJointDef jd1 = new RevoluteJointDef(); jd1.initialize(body2, body1, bd1.position); Joint joint1 = m_world.createJoint(jd1); RevoluteJointDef jd2 = new RevoluteJointDef(); jd2.initialize(body2, body3, bd3.position); Joint joint2 = m_world.createJoint(jd2); body1.createFixture(circle1, 5.0f); RevoluteJointDef jd1 = new RevoluteJointDef(); jd1.bodyA = ground; jd1.bodyB = body1; body2.createFixture(circle2, 5.0f); RevoluteJointDef jd2 = new RevoluteJointDef(); jd2.initialize(ground, body2, bd2.position); m_joint2 = (RevoluteJoint) m_world.createJoint(jd2);
@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; }
RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(body, ground, body.getPosition()); rjd.motorSpeed = MathUtils.PI; rjd.maxMotorTorque = 1000000.0f; body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 5.0f)); rjd.motorSpeed = 1.0f * MathUtils.PI; rjd.maxMotorTorque = 20000; body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 9.0f)); rjd.enableMotor = false; world.createJoint(rjd); body.createFixture(piston); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f)); world.createJoint(rjd);
RevoluteJointDef def = new RevoluteJointDef(); jd = def; def.enableLimit = joint.getEnableLimit();
bd.type = BodyType.DYNAMIC; RevoluteJointDef rjd = new RevoluteJointDef(); body.setLinearVelocity(new Vec2(-8.0f * w, 0.0f)); rjd.initialize(ground, body, new Vec2(-10.0f, 12.0f)); rjd.motorSpeed = -1.0f * MathUtils.PI; rjd.maxMotorTorque = 10000.0f; polygon_body.createFixture(polygon_shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(ground, polygon_body, new Vec2(20.0f, 10.0f)); rjd.lowerAngle = -0.25f * MathUtils.PI; rjd.upperAngle = 0.0f * MathUtils.PI;
Body bodyA, bodyB; ... //I'm creating joint Revolute type RevoluteJointDef jointDef = new RevoluteJointDef(); //I'm setting two bodies between which joint will be created jointDef.bodyA = bodyA; jointDef.bodyB = bodyB; //I'm setting local offset for bodyA and bodyB jointDef.localAnchorA.set( new Vector2(0, 10)); //the point over center of bodyA jointDef.localAnchorB.set( new Vector2(0, -10 ); //the point under center of bodyB ... //I can also define some joint characteristics like .enableLimit, .lowerAngle etc depending on joint type //finally I'm creating the joint world.createJoint(jointDef);
RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(body, getGroundBody(), body.getPosition()); rjd.motorSpeed = MathUtils.PI; rjd.maxMotorTorque = 1000000.0f; body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 5.0f)); rjd.motorSpeed = 1.0f * MathUtils.PI; rjd.maxMotorTorque = 20000; body.createFixture(shape, 2.0f); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 9.0f)); rjd.enableMotor = false; getWorld().createJoint(rjd); body.setBullet(false); RevoluteJointDef rjd = new RevoluteJointDef(); rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f)); getWorld().createJoint(rjd);
body.createFixture(shape, 5.0f); RevoluteJointDef jd = new RevoluteJointDef(); jd.bodyA = getGroundBody(); jd.bodyB = body;
fd.filter.maskBits = 0xFFFF & ~0x0002; RevoluteJointDef jd = new RevoluteJointDef(); jd.collideConnected = false; jd.initialize(prevBody, body, anchor); getWorld().createJoint(jd);
@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; }
RevoluteJointDef jd = new RevoluteJointDef(); Body prevBody = startBody; for(int i=0; i<ringCount; i++) { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.angle = angle-MathUtils.PI/2; bd.position.set(position.x + i*MathUtils.cos(angle)*EACH_RING_DISTANCE, position.y + i*MathUtils.sin(angle)*EACH_RING_DISTANCE); Body body = world.createBody(bd); body.createFixture(eachRingFD); Vector2 anchor = new Vector2(bd.position.x - MathUtils.cos(angle)*EACH_RING_DISTANCE/2f, bd.position.y - MathUtils.sin(angle)*EACH_RING_DISTANCE/2f); jd.initialize(prevBody, body, anchor); prevBody = body; } //connect a hanging shape to rope here if exists