private void joinReelToAxis() { RevoluteJointDef jointDef = new RevoluteJointDef(); jointDef.bodyA = axis; jointDef.bodyB = reel; world.createJoint(jointDef); }
djd.initialize(bodies[i], bodies[next], bodies[i].getWorldCenter(), bodies[next].getWorldCenter()); distanceJoints[i] = (DistanceJoint) world.createJoint(djd);
/** Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies * to cease colliding. * @warning This function is locked during callbacks. */ public Joint createJoint (JointDef def) { org.jbox2d.dynamics.joints.JointDef jd = def.toJBox2d(); org.jbox2d.dynamics.joints.Joint j = world.createJoint(jd); Joint joint = null; if (def.type == JointType.DistanceJoint) joint = new DistanceJoint(this, (org.jbox2d.dynamics.joints.DistanceJoint)j); if (def.type == JointType.FrictionJoint) joint = new FrictionJoint(this, (org.jbox2d.dynamics.joints.FrictionJoint)j); if (def.type == JointType.GearJoint) joint = new GearJoint(this, (org.jbox2d.dynamics.joints.GearJoint)j, ((GearJointDef) def).joint1, ((GearJointDef) def).joint2); if (def.type == JointType.MotorJoint) joint = new MotorJoint(this, (org.jbox2d.dynamics.joints.MotorJoint)j); if (def.type == JointType.MouseJoint) joint = new MouseJoint(this, (org.jbox2d.dynamics.joints.MouseJoint)j); if (def.type == JointType.PrismaticJoint) joint = new PrismaticJoint(this, (org.jbox2d.dynamics.joints.PrismaticJoint)j); if (def.type == JointType.PulleyJoint) joint = new PulleyJoint(this, (org.jbox2d.dynamics.joints.PulleyJoint)j); if (def.type == JointType.RevoluteJoint) joint = new RevoluteJoint(this, (org.jbox2d.dynamics.joints.RevoluteJoint)j); if (def.type == JointType.RopeJoint) joint = new RopeJoint(this, (org.jbox2d.dynamics.joints.RopeJoint)j); if (def.type == JointType.WeldJoint) joint = new WeldJoint(this, (org.jbox2d.dynamics.joints.WeldJoint)j); if (def.type == JointType.WheelJoint) joint = new WheelJoint(this, (org.jbox2d.dynamics.joints.WheelJoint)j); if (joint == null) throw new GdxRuntimeException("Joint type '" + def.type + "' not yet supported by GWT backend"); joints.put(j, joint); return joint; }
@Override public void keyPressed(char keyChar, int keyCode) { switch (keyChar) { case 'j': if (m_rope != null) { getWorld().destroyJoint(m_rope); m_rope = null; } else { m_rope = getWorld().createJoint(m_ropeDef); } break; } }
djd.initialize(bodies[i], bodies[next], bodies[i].getWorldCenter(), bodies[next].getWorldCenter()); distanceJoints[i] = (DistanceJoint) world.createJoint(djd);
private void spawnMouseJoint(Vec2 p) { if (mouseJoint != null) { return; } queryAABB.lowerBound.set(p.x - .001f, p.y - .001f); queryAABB.upperBound.set(p.x + .001f, p.y + .001f); callback.point.set(p); callback.fixture = null; m_world.queryAABB(callback, queryAABB); if (callback.fixture != null) { Body body = callback.fixture.getBody(); MouseJointDef def = new MouseJointDef(); def.bodyA = groundBody; def.bodyB = body; def.collideConnected = true; def.target.set(p); def.maxForce = 1000f * body.getMass(); mouseJoint = (MouseJoint) m_world.createJoint(def); body.setAwake(true); } }
getWorld().createJoint(djd); getWorld().createJoint(djd); getWorld().createJoint(djd); getWorld().createJoint(djd); getWorld().createJoint(rjd);
getWorld().createJoint(jd); m_rope = getWorld().createJoint(m_ropeDef);
getWorld().createJoint(jointDef);
mjd.maxForce = 1000.0f; mjd.maxTorque = 1000.0f; m_joint = (MotorJoint) m_world.createJoint(mjd);
@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; }
cvjd.dampingRatio = 1.0f; cvjd.collideConnected = false; getWorld().createJoint(cvjd);
getWorld().createJoint(jd);
pjd.enableLimit = true; m_joint = (PrismaticJoint) getWorld().createJoint(pjd);
rjd.maxMotorTorque = 50.0f; rjd.enableMotor = true; getWorld().createJoint(rjd); pjd.enableLimit = true; getWorld().createJoint(pjd);
jointDef.initialize(base, pendulum, new Vec2(0, 0)); getWorld().createJoint(jointDef);
jd.maxMotorTorque = 1e7f; jd.enableMotor = true; m_joint = (RevoluteJoint) m_world.createJoint(jd);
rjd.collideConnected = true; m_joint = (RevoluteJoint) getWorld().createJoint(rjd); rjd.upperAngle = 0.0f * MathUtils.PI; rjd.enableLimit = true; m_world.createJoint(rjd);
pulleyDef.initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 2.0f); m_joint1 = (PulleyJoint) getWorld().createJoint(pulleyDef);
jd.maxMotorTorque = 400.0f; jd.enableMotor = m_motorOn; m_motorJoint = (RevoluteJoint) getWorld().createJoint(jd);