Examples of MouseJointDef


Examples of com.badlogic.gdx.physics.box2d.joints.MouseJointDef

      MotorJointDef d = (MotorJointDef)def;
      return jniCreateMotorJoint(addr, d.bodyA.addr, d.bodyB.addr, d.collideConnected, d.linearOffset.x, d.linearOffset.y,
        d.angularOffset, d.maxForce, d.maxTorque, d.correctionFactor);
    }
    if (def.type == JointType.MouseJoint) {
      MouseJointDef d = (MouseJointDef)def;
      return jniCreateMouseJoint(addr, d.bodyA.addr, d.bodyB.addr, d.collideConnected, d.target.x, d.target.y, d.maxForce,
        d.frequencyHz, d.dampingRatio);
    }
    if (def.type == JointType.PrismaticJoint) {
      PrismaticJointDef d = (PrismaticJointDef)def;
View Full Code Here

Examples of com.badlogic.gdx.physics.box2d.joints.MouseJointDef

    if (def.type == JointType.GearJoint) {
      GearJointDef d = (GearJointDef)def;
      return jniCreateGearJoint(addr, d.bodyA.addr, d.bodyB.addr, d.collideConnected, d.joint1.addr, d.joint2.addr, d.ratio);
    }
    if (def.type == JointType.MouseJoint) {
      MouseJointDef d = (MouseJointDef)def;
      return jniCreateMouseJoint(addr, d.bodyA.addr, d.bodyB.addr, d.collideConnected, d.target.x, d.target.y, d.maxForce,
        d.frequencyHz, d.dampingRatio);
    }
    if (def.type == JointType.PrismaticJoint) {
      PrismaticJointDef d = (PrismaticJointDef)def;
View Full Code Here

Examples of com.badlogic.gdx.physics.box2d.joints.MouseJointDef

        testPoint.x + 0.1f, testPoint.y + 0.1f);

    // if we hit something we create a new mouse joint
    // and attach it to the hit body.
    if (hitBody != null) {
      MouseJointDef def = new MouseJointDef();
      def.bodyA = groundBody;
      def.bodyB = hitBody;
      def.collideConnected = true;
      def.target.set(testPoint.x, testPoint.y);
      def.maxForce = 1000.0f * hitBody.getMass();
 
View Full Code Here

Examples of com.badlogic.gdx.physics.box2d.joints.MouseJointDef

    if (def.type == JointType.GearJoint) {
      GearJointDef d = (GearJointDef)def;
      return jniCreateGearJoint(addr, d.bodyA.addr, d.bodyB.addr, d.collideConnected, d.joint1.addr, d.joint2.addr, d.ratio);
    }
    if (def.type == JointType.MouseJoint) {
      MouseJointDef d = (MouseJointDef)def;
      return jniCreateMouseJoint(addr, d.bodyA.addr, d.bodyB.addr, d.collideConnected, d.target.x, d.target.y, d.maxForce,
        d.frequencyHz, d.dampingRatio);
    }
    if (def.type == JointType.PrismaticJoint) {
      PrismaticJointDef d = (PrismaticJointDef)def;
View Full Code Here

Examples of org.jbox2d.dynamics.joints.MouseJointDef

    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.target.set(p);
      def.maxForce = 1000f * body.getMass();
      mouseJoint = (MouseJoint) m_world.createJoint(def);
View Full Code Here

Examples of org.jbox2d.dynamics.joints.MouseJointDef

        imgMallet = new Image("airhockey/assets/mallet.png");
        imgMallet2 = new Image("airhockey/assets/mallet2.png");
       
        isWaiting = false;
       
        MouseJointDef md = new MouseJointDef();
        md.bodyA = world.createBody(new BodyDef());
        md.bodyB = mallet.body;
        md.maxForce = 10000.0f * mallet.body.getMass();
        md.dampingRatio = 0;
        md.frequencyHz = 120;
View Full Code Here

Examples of org.jbox2d.dynamics.joints.MouseJointDef

        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

Examples of org.jbox2d.dynamics.joints.MouseJointDef

    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();
 
View Full Code Here

Examples of org.jbox2d.dynamics.joints.MouseJointDef

public class PhysicsHelper {
 
 
  public static MouseJoint createDragJoint(World world, Body body, float x, float y){
    MouseJointDef mjd = new MouseJointDef();
    mjd.body1 = body; // Not used, avoid a NPE
    mjd.body2 = body;
    mjd.target = new Vec2(x, y);
//    mjd.target = new Vec2(x/scale, y/scale);
//    mjd.maxForce = 8000.0f * body.m_mass;
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.