Package org.jbox2d.dynamics.joints

Examples of org.jbox2d.dynamics.joints.PrismaticJointDef


        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f));
        world.createJoint(rjd);

        PrismaticJointDef pjd = new PrismaticJointDef();
        pjd.initialize(ground, body, new Vec2(0.0f, 17.0f), new Vec2(0.0f, 1.0f));

        pjd.maxMotorForce = 1000.0f;
        pjd.enableMotor = true;

        m_joint2 = (PrismaticJoint) world.createJoint(pjd);
View Full Code Here


        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f));
        world.createJoint(rjd);

        PrismaticJointDef pjd = new PrismaticJointDef();
        pjd.initialize(ground, body, new Vec2(0.0f, 17.0f), new Vec2(0.0f, 1.0f));

        pjd.maxMotorForce = 1000.0f;
        pjd.enableMotor = true;

        m_joint2 = (PrismaticJoint) world.createJoint(pjd);
View Full Code Here

      bd.angle = 0.5f * MathUtils.PI;
      bd.allowSleep = false;
      Body body = getWorld().createBody(bd);
      body.createFixture(shape, 5.0f);

      PrismaticJointDef pjd = new PrismaticJointDef();

      // Bouncy limit
      Vec2 axis = new Vec2(2.0f, 1.0f);
      axis.normalize();
      pjd.initialize(ground, body, new Vec2(0.0f, 0.0f), axis);

      // Non-bouncy limit
      // pjd.Initialize(ground, body, Vec2(-10.0f, 10.0f), Vec2(1.0f, 0.0f));

      pjd.motorSpeed = 10.0f;
View Full Code Here

      PolygonShape p = new PolygonShape();
      p.setAsBox(0.5f, 1.0f);
      body.createFixture(p, 1.0f);

      PrismaticJointDef jd = new PrismaticJointDef();
      jd.bodyA = body2;
      jd.bodyB = body;
      jd.enableLimit = true;
      jd.localAnchorA.set(0.0f, 4.0f);
      jd.localAnchorB.setZero();
View Full Code Here

        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f));
        getWorld().createJoint(rjd);

        PrismaticJointDef pjd = new PrismaticJointDef();
        pjd.initialize(ground, body, new Vec2(0.0f, 17.0f), new Vec2(0.0f, 1.0f));

        pjd.maxMotorForce = 1000.0f;
        pjd.enableMotor = false;

        m_joint2 = (PrismaticJoint) getWorld().createJoint(pjd);
View Full Code Here

      Map<Integer, Joint> jointMap) {
    JointDef jd = null;

    switch (joint.getType()) {
      case PRISMATIC: {
        PrismaticJointDef def = new PrismaticJointDef();
        jd = def;
        def.enableLimit = joint.getEnableLimit();
        def.enableMotor = joint.getEnableMotor();
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.localAxisA.set(pbToVec(joint.getLocalAxisA()));
        def.lowerTranslation = joint.getLowerLimit();
        def.maxMotorForce = joint.getMaxMotorForce();
        def.motorSpeed = joint.getMotorSpeed();
        def.referenceAngle = joint.getRefAngle();
        def.upperTranslation = joint.getUpperLimit();
        break;
      }
      case REVOLUTE: {
        RevoluteJointDef def = new RevoluteJointDef();
        jd = def;
        def.enableLimit = joint.getEnableLimit();
        def.enableMotor = joint.getEnableMotor();
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.lowerAngle = joint.getLowerLimit();
        def.maxMotorTorque = joint.getMaxMotorTorque();
        def.motorSpeed = joint.getMotorSpeed();
        def.referenceAngle = joint.getRefAngle();
        def.upperAngle = joint.getUpperLimit();
        break;
      }
      case DISTANCE: {
        DistanceJointDef def = new DistanceJointDef();
        jd = def;
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.dampingRatio = joint.getDampingRatio();
        def.frequencyHz = joint.getFrequency();
        def.length = joint.getLength();
        break;
      }
      case PULLEY: {
        PulleyJointDef def = new PulleyJointDef();
        jd = def;
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.groundAnchorA.set(pbToVec(joint.getGroundAnchorA()));
        def.groundAnchorB.set(pbToVec(joint.getGroundAnchorB()));
        def.lengthA = joint.getLengthA();
        def.lengthB = joint.getLengthB();
        def.ratio = joint.getRatio();
        break;
      }
      case MOUSE: {
        MouseJointDef def = new MouseJointDef();
        jd = def;
        def.dampingRatio = joint.getDampingRatio();
        def.frequencyHz = joint.getFrequency();
        def.maxForce = joint.getMaxForce();
        def.target.set(pbToVec(joint.getTarget()));
        break;
      }
      case GEAR: {
        GearJointDef def = new GearJointDef();
        jd = def;
        if (!jointMap.containsKey(joint.getJoint1())) {
          throw new IllegalArgumentException("Index " + joint.getJoint1()
              + " is not present in the joint map.");
        }
        def.joint1 = jointMap.get(joint.getJoint1());
        if (!jointMap.containsKey(joint.getJoint2())) {
          throw new IllegalArgumentException("Index " + joint.getJoint2()
              + " is not present in the joint map.");
        }
        def.joint2 = jointMap.get(joint.getJoint2());
        def.ratio = joint.getRatio();
        break;
      }
      case WHEEL: {
        WheelJointDef def = new WheelJointDef();
        jd = def;
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.localAxisA.set(pbToVec(joint.getLocalAxisA()));
        def.enableMotor = joint.getEnableMotor();
        def.maxMotorTorque = joint.getMaxMotorTorque();
        def.motorSpeed = joint.getMotorSpeed();
        def.frequencyHz = joint.getFrequency();
        def.dampingRatio = joint.getDampingRatio();
        break;
      }
      case WELD: {
        WeldJointDef def = new WeldJointDef();
        jd = def;
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.referenceAngle = joint.getRefAngle();
        def.frequencyHz = joint.getFrequency();
        def.dampingRatio = joint.getDampingRatio();
        break;
      }
      case FRICTION: {
        FrictionJointDef def = new FrictionJointDef();
        jd = def;
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.maxForce = joint.getMaxForce();
        def.maxTorque = joint.getMaxTorque();
        break;
      }
      case ROPE: {
        RopeJointDef def = new RopeJointDef();
        jd = def;
        def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
        def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
        def.maxLength = joint.getMaxLength();
        return null;
      }
      case CONSTANT_VOLUME: {
        ConstantVolumeJointDef def = new ConstantVolumeJointDef();
        jd = def;
        def.dampingRatio = joint.getDampingRatio();
        def.frequencyHz = joint.getFrequency();
        if (joint.getBodiesCount() != joint.getJointsCount()) {
          throw new IllegalArgumentException(
              "Constant volume joint must have bodies and joints defined");
        }
        for (int i = 0; i < joint.getBodiesCount(); i++) {
          int body = joint.getBodies(i);
          if (!argBodyMap.containsKey(body)) {
            throw new IllegalArgumentException("Index " + body + " is not present in the body map");
          }
          int jointIndex = joint.getJoints(i);
          if (!jointMap.containsKey(jointIndex)) {
            throw new IllegalArgumentException("Index " + jointIndex
                + " is not present in the joint map");
          }
          Joint djoint = jointMap.get(jointIndex);
          if (!(djoint instanceof DistanceJoint)) {
            throw new IllegalArgumentException(
                "Joints for constant volume joint must be distance joints");
          }
          def.addBodyAndJoint(argBodyMap.get(body), (DistanceJoint) djoint);
        }
        break;
      }
      case LINE: {
        UnsupportedObjectException e =
View Full Code Here

      rjd.initialize(m_attachment, m_platform, new Vec2(0.0f, 5.0f));
      rjd.maxMotorTorque = 50.0f;
      rjd.enableMotor = true;
      getWorld().createJoint(rjd);

      PrismaticJointDef pjd = new PrismaticJointDef();
      pjd.initialize(ground, m_platform, new Vec2(0.0f, 5.0f), new Vec2(1.0f, 0.0f));

      pjd.maxMotorForce = 1000.0f;
      pjd.enableMotor = true;
      pjd.lowerTranslation = -10.0f;
      pjd.upperTranslation = 10.0f;
View Full Code Here

       
        RevoluteJointDef rjd = new RevoluteJointDef();
        rjd.initialize(prevBody, body, new Vec2(0.0f, 17.0f));
        getWorld().createJoint(rjd);

        PrismaticJointDef pjd = new PrismaticJointDef();
        pjd.initialize(ground, body, new Vec2(0.0f, 17.0f), new Vec2(0.0f, 1.0f));

        pjd.maxMotorForce = 1000.0f;
        pjd.enableMotor = true;

        getWorld().createJoint(pjd);
View Full Code Here

      bd3.type = BodyType.DYNAMIC;
      bd3.position.set(2.5f, 12.0f);
      Body body3 = m_world.createBody(bd3);
      body3.createFixture(box, 5.0f);

      PrismaticJointDef jd3 = new PrismaticJointDef();
      jd3.initialize(ground, body3, bd3.position, new Vec2(0.0f, 1.0f));
      jd3.lowerTranslation = -5.0f;
      jd3.upperTranslation = 5.0f;
      jd3.enableLimit = true;

      m_joint3 = (PrismaticJoint) m_world.createJoint(jd3);
View Full Code Here

TOP

Related Classes of org.jbox2d.dynamics.joints.PrismaticJointDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.