@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.WheelJointDef fd = new org.jbox2d.dynamics.joints.WheelJointDef(); fd.bodyA = bodyA.body; fd.bodyB = bodyB.body; fd.collideConnected = collideConnected; fd.localAxisA.set(localAxisA.x, localAxisA.y); fd.enableMotor = enableMotor; fd.maxMotorTorque = maxMotorTorque; fd.motorSpeed = motorSpeed; fd.frequencyHz = frequencyHz; fd.dampingRatio = dampingRatio; fd.localAnchorA.set(localAnchorA.x, localAnchorA.y); fd.localAnchorB.set(localAnchorB.x, localAnchorB.y); fd.type = org.jbox2d.dynamics.joints.JointType.WHEEL; return fd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.PrismaticJointDef jd = new org.jbox2d.dynamics.joints.PrismaticJointDef(); 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.localAxisA.set(localAxisA.x, localAxisA.y); jd.lowerTranslation = lowerTranslation; jd.maxMotorForce = maxMotorForce; jd.motorSpeed = motorSpeed; jd.referenceAngle = referenceAngle; jd.type = org.jbox2d.dynamics.joints.JointType.PRISMATIC; jd.upperTranslation = upperTranslation; return jd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.PulleyJointDef jd = new org.jbox2d.dynamics.joints.PulleyJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.groundAnchorA.set(groundAnchorA.x, groundAnchorB.y); jd.groundAnchorB.set(groundAnchorB.x, groundAnchorB.y); jd.lengthA = lengthA; jd.lengthB = lengthB; jd.localAnchorA.set(localAnchorA.x, localAnchorA.y); jd.localAnchorB.set(localAnchorB.x, localAnchorB.y); jd.ratio = ratio; jd.type = org.jbox2d.dynamics.joints.JointType.PULLEY; return jd; }
@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; }
/** * Depending on the type of joint there is no need of two bodies. You can safely * pass a JointDef and reuse it. If both bodies are not passed, then an error will * be prompt. * @param spriteA The first body. * @param spriteB The second body. * @param jointDef The joint definition. */ public B2FlxJoint(B2FlxShape spriteA, B2FlxShape spriteB, JointDef jointDef) { super(); if(spriteA != null) { bodyA = spriteA.body; spriteA.joints.add(this); } if(spriteB != null) { bodyB = spriteB.body; spriteB.joints.add(this); } if(bodyA == null && bodyB == null) throw new Error("your jointDef must have b2Body instances for its a and b properties"); if(jointDef != null) this.jointDef = jointDef; scrollFactor = new FlxPoint(1.0f,1.0f); B2FlxB.flxJoints.add(this); init(); }
public JointDef toJointDef(Body bodyA, Body bodyB){ logger.debug("Creating joint def"); JointDef jd = toJointDef(type); jd.bodyA = bodyA; jd.bodyB = bodyB; jd.collideConnected = collideConnected; return jd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.GearJointDef jd = new org.jbox2d.dynamics.joints.GearJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.joint1 = joint1.getJBox2DJoint(); jd.joint2 = joint2.getJBox2DJoint(); jd.ratio = ratio; jd.type = org.jbox2d.dynamics.joints.JointType.GEAR; return jd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.RopeJointDef fd = new org.jbox2d.dynamics.joints.RopeJointDef(); fd.bodyA = bodyA.body; fd.bodyB = bodyB.body; fd.collideConnected = collideConnected; fd.maxLength = maxLength; fd.localAnchorA.set(localAnchorA.x, localAnchorA.y); fd.localAnchorB.set(localAnchorB.x, localAnchorB.y); fd.type = org.jbox2d.dynamics.joints.JointType.ROPE; return fd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.MotorJointDef jd = new org.jbox2d.dynamics.joints.MotorJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.linearOffset.set(linearOffset.x, linearOffset.y); jd.angularOffset = angularOffset; jd.maxForce = maxForce; jd.maxTorque = maxTorque; jd.type = org.jbox2d.dynamics.joints.JointType.MOTOR; return jd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.FrictionJointDef jd = new org.jbox2d.dynamics.joints.FrictionJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.localAnchorA.set(localAnchorA.x, localAnchorA.y); jd.localAnchorB.set(localAnchorB.x, localAnchorB.y); jd.maxForce = maxForce; jd.maxTorque = maxTorque; jd.type = org.jbox2d.dynamics.joints.JointType.FRICTION; return jd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.WeldJointDef jd = new org.jbox2d.dynamics.joints.WeldJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.dampingRatio = dampingRatio; jd.frequencyHz = frequencyHz; jd.localAnchorA.set(localAnchorA.x, localAnchorA.y); jd.localAnchorB.set(localAnchorB.x, localAnchorB.y); jd.referenceAngle = referenceAngle; jd.type = org.jbox2d.dynamics.joints.JointType.WELD; return jd; }
@Override public org.jbox2d.dynamics.joints.JointDef toJBox2d () { org.jbox2d.dynamics.joints.MouseJointDef jd = new org.jbox2d.dynamics.joints.MouseJointDef(); jd.bodyA = bodyA.body; jd.bodyB = bodyB.body; jd.collideConnected = collideConnected; jd.dampingRatio = dampingRatio; jd.frequencyHz = frequencyHz; jd.maxForce = maxForce; jd.target.set(target.x, target.y); jd.type = org.jbox2d.dynamics.joints.JointType.MOUSE; return jd; }
@Override public JointDef createDef(Body sourceBody, Body targetBody, final Vector2 targetOffset) { WheelJointDef jointDef = new WheelJointDef() {{ enableMotor = true; frequencyHz = suspensionFrequencyHz; dampingRatio = suspensionDampingRatio; }}; Vector2 worldTarget = new Vector2(targetBody.getWorldCenter()).add(targetOffset); jointDef.initialize(sourceBody, targetBody, worldTarget, axisOfMovement); return jointDef; }
@Override public JointDef createDef(Body sourceBody, Body targetBody, final Vector2 targetOffset) { PrismaticJointDef jointDef = new PrismaticJointDef() {{ enableLimit = true; enableMotor = true; lowerTranslation = PrismaticJointConfig.this.lowerTranslation; upperTranslation = PrismaticJointConfig.this.upperTranslation; }}; Vector2 worldTarget = new Vector2(targetBody.getWorldCenter()).add(targetOffset); jointDef.initialize(sourceBody, targetBody, worldTarget, axisOfMovement); return jointDef; }
@Override public JointDef createDef(Body sourceBody, Body targetBody, final Vector2 targetOffset) { RevoluteJointDef jointDef = new RevoluteJointDef() {{ enableLimit = false; }}; Vector2 worldTarget = new Vector2(targetBody.getWorldCenter()).add(targetOffset); jointDef.initialize(sourceBody, targetBody, worldTarget); return jointDef; }
public Joint createJoint(final JointDef pDef) { return this.mWorld.createJoint(pDef); }
public JointModel(JointDef jd,String bodyName1, String bodyName2){ this.fromJointDef(jd,bodyName1,bodyName2); }
public JointModel(String theName, JointDef jd,String bodyName1, String bodyName2){ name = theName; this.fromJointDef(jd,bodyName1,bodyName2); }
public Joint toJoint(World world,Body bodyA, Body bodyB){ logger.debug("Creating Joint"); JointDef jd = this.toJointDef(bodyA,bodyB); return world.createJoint(jd); /* switch (type){ case DistanceJoint:{ return world.createJoint((DistanceJointDef)jd); } case FrictionJoint:{ return world.createJoint((FrictionJointDef)jd); } case GearJoint:{ return world.createJoint((GearJointDef)jd); } case MotorJoint:{ return world.createJoint((MotorJointDef)jd); } case MouseJoint:{ return world.createJoint((MouseJointDef)jd); } case PrismaticJoint:{ return world.createJoint((PrismaticJointDef)jd); } case PulleyJoint:{ return world.createJoint((PulleyJointDef)jd); } case RevoluteJoint:{ return world.createJoint((RevoluteJointDef)jd); } case RopeJoint:{ return world.createJoint((RopeJointDef)jd); } case WeldJoint:{ return world.createJoint((WeldJointDef)jd); } case WheelJoint:{ return world.createJoint((WheelJointDef)jd); } } return null; */ }
@Override public B2FlxWeldJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxRopeJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxDistanceJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxFrictionJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxRevoluteJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxWheelJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxGearJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
@Override public B2FlxPrismaticJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
/** * Set the joint definition. * @param jointDef * @return This joint. Handy for chaining stuff together. */ public B2FlxJoint setJointDef(JointDef jointDef) { this.jointDef = jointDef; return this; }
@Override public B2FlxPulleyJoint setJointDef(JointDef jointDef){super.setJointDef(jointDef);return this;}
public GearJointDef() { this.type = JointDef.JointType.GearJoint; }
public RopeJointDef() { this.type = JointDef.JointType.RopeJoint; }
public WheelJointDef() { this.type = JointDef.JointType.WheelJoint; }
public FrictionJointDef() { this.type = JointDef.JointType.FrictionJoint; }
public PrismaticJointDef() { this.type = JointDef.JointType.PrismaticJoint; }
public DistanceJointDef() { this.type = JointDef.JointType.DistanceJoint; }
public WeldJointDef() { this.type = JointDef.JointType.WeldJoint; }
public MouseJointDef() { this.type = JointDef.JointType.MouseJoint; }
public PulleyJointDef() { this.type = JointDef.JointType.PulleyJoint; this.collideConnected = true; }
public RevoluteJointDef() { this.type = JointDef.JointType.RevoluteJoint; }