Package org.jbox2d.dynamics.joints

Examples of org.jbox2d.dynamics.joints.Joint


    assert (isLocked() == false);
    if (isLocked()) {
      return null;
    }

    Joint j = Joint.create(this, def);

    // Connect to the world list.
    j.m_prev = null;
    j.m_next = m_jointList;
    if (m_jointList != null) {
      m_jointList.m_prev = j;
    }
    m_jointList = j;
    ++m_jointCount;

    // Connect to the bodies' doubly linked lists.
    j.m_edgeA.joint = j;
    j.m_edgeA.other = j.getBodyB();
    j.m_edgeA.prev = null;
    j.m_edgeA.next = j.getBodyA().m_jointList;
    if (j.getBodyA().m_jointList != null) {
      j.getBodyA().m_jointList.prev = j.m_edgeA;
    }
    j.getBodyA().m_jointList = j.m_edgeA;

    j.m_edgeB.joint = j;
    j.m_edgeB.other = j.getBodyA();
    j.m_edgeB.prev = null;
    j.m_edgeB.next = j.getBodyB().m_jointList;
    if (j.getBodyB().m_jointList != null) {
      j.getBodyB().m_jointList.prev = j.m_edgeB;
    }
    j.getBodyB().m_jointList = j.m_edgeB;

    Body bodyA = def.bodyA;
    Body bodyB = def.bodyB;

    // If the joint prevents collisions, then flag any contacts for filtering.
View Full Code Here


    assert (isLocked() == false);
    if (isLocked()) {
      return null;
    }

    Joint j = Joint.create(this, def);

    // Connect to the world list.
    j.m_prev = null;
    j.m_next = m_jointList;
    if (m_jointList != null) {
      m_jointList.m_prev = j;
    }
    m_jointList = j;
    ++m_jointCount;

    // Connect to the bodies' doubly linked lists.
    j.m_edgeA.joint = j;
    j.m_edgeA.other = j.getBodyB();
    j.m_edgeA.prev = null;
    j.m_edgeA.next = j.getBodyA().m_jointList;
    if (j.getBodyA().m_jointList != null) {
      j.getBodyA().m_jointList.prev = j.m_edgeA;
    }
    j.getBodyA().m_jointList = j.m_edgeA;

    j.m_edgeB.joint = j;
    j.m_edgeB.other = j.getBodyA();
    j.m_edgeB.prev = null;
    j.m_edgeB.next = j.getBodyB().m_jointList;
    if (j.getBodyB().m_jointList != null) {
      j.getBodyB().m_jointList.prev = j.m_edgeB;
    }
    j.getBodyB().m_jointList = j.m_edgeB;

    Body bodyA = def.bodyA;
    Body bodyB = def.bodyB;

    // If the joint prevents collisions, then flag any contacts for filtering.
View Full Code Here

    assert (isLocked() == false);
    if (isLocked()) {
      return null;
    }
   
    Joint j = Joint.create(this, def);
   
    // Connect to the world list.
    j.m_prev = null;
    j.m_next = m_jointList;
    if (m_jointList != null) {
View Full Code Here

    assert (isLocked() == false);
    if (isLocked()) {
      return null;
    }

    Joint j = Joint.create(this, def);

    // Connect to the world list.
    j.m_prev = null;
    j.m_next = m_jointList;
    if (m_jointList != null) {
View Full Code Here

    assert (isLocked() == false);
    if (isLocked()) {
      return null;
    }

    Joint j = Joint.create(this, def);

    // Connect to the world list.
    j.m_prev = null;
    j.m_next = m_jointList;
    if (m_jointList != null) {
      m_jointList.m_prev = j;
    }
    m_jointList = j;
    ++m_jointCount;

    // Connect to the bodies' doubly linked lists.
    j.m_edgeA.joint = j;
    j.m_edgeA.other = j.getBodyB();
    j.m_edgeA.prev = null;
    j.m_edgeA.next = j.getBodyA().m_jointList;
    if (j.getBodyA().m_jointList != null) {
      j.getBodyA().m_jointList.prev = j.m_edgeA;
    }
    j.getBodyA().m_jointList = j.m_edgeA;

    j.m_edgeB.joint = j;
    j.m_edgeB.other = j.getBodyA();
    j.m_edgeB.prev = null;
    j.m_edgeB.next = j.getBodyB().m_jointList;
    if (j.getBodyB().m_jointList != null) {
      j.getBodyB().m_jointList.prev = j.m_edgeB;
    }
    j.getBodyB().m_jointList = j.m_edgeB;

    Body bodyA = def.bodyA;
    Body bodyB = def.bodyB;

    // If the joint prevents collisions, then flag any contacts for filtering.
View Full Code Here

      cnt++;
      cbody = cbody.m_next;
    }
    cnt = 0;
    HashMap<Joint, Integer> joints = new HashMap<Joint, Integer>();
    Joint cjoint = argWorld.getJointList();
    // first pass
    while (cjoint != null) {
      if (SerializationHelper.isIndependentJoint(cjoint.getType())) {
        builder.addJoints(serializeJoint(cjoint, bodies, joints));
        joints.put(cjoint, cnt);
        cnt++;
      }
      cjoint = cjoint.m_next;
    }

    // second pass for dependent joints
    cjoint = argWorld.getJointList();
    while (cjoint != null) {
      if (!SerializationHelper.isIndependentJoint(cjoint.getType())) {
        builder.addJoints(serializeJoint(cjoint, bodies, joints));
        joints.put(cjoint, cnt);
        cnt++;
      }
      cjoint = cjoint.m_next;
View Full Code Here

    // first pass, indep joints
    int cnt = 0;
    for (int i = 0; i < pbWorld.getJointsCount(); i++) {
      PbJoint pbJoint = pbWorld.getJoints(i);
      if (isIndependentJoint(pbJoint.getType())) {
        Joint joint = deserializeJoint(world, pbJoint, bodyMap, jointMap);
        jointMap.put(cnt, joint);
        cnt++;
      }
    }

    // second pass, dep joints
    for (int i = 0; i < pbWorld.getJointsCount(); i++) {
      PbJoint pbJoint = pbWorld.getJoints(i);
      if (!isIndependentJoint(pbJoint.getType())) {
        Joint joint = deserializeJoint(world, pbJoint, bodyMap, jointMap);
        jointMap.put(cnt, joint);
        cnt++;
      }
    }
View Full Code Here

          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 =
            new UnsupportedObjectException("Line joint no longer supported.", Type.JOINT);
        if (ulistener == null || ulistener.isUnsupported(e)) {
          throw e;
        }
        return null;
      }
      default: {
        UnsupportedObjectException e =
            new UnsupportedObjectException("Unknown joint type: " + joint.getType(), Type.JOINT);
        if (ulistener == null || ulistener.isUnsupported(e)) {
          throw e;
        }
        return null;
      }
    }

    jd.collideConnected = joint.getCollideConnected();

    if (!argBodyMap.containsKey(joint.getBodyA())) {
      throw new IllegalArgumentException("Index " + joint.getBodyA()
          + " is not present in the body map");
    }
    jd.bodyA = argBodyMap.get(joint.getBodyA());

    if (!argBodyMap.containsKey(joint.getBodyB())) {
      throw new IllegalArgumentException("Index " + joint.getBodyB()
          + " is not present in the body map");
    }
    jd.bodyB = argBodyMap.get(joint.getBodyB());

    Joint realJoint = argWorld.createJoint(jd);
    if (listener != null && joint.hasTag()) {
      listener.processJoint(realJoint, joint.getTag());
    }

    return realJoint;
View Full Code Here

      Body body3 = m_world.createBody(bd3);
      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);

      GearJointDef jd4 = new GearJointDef();
      jd4.bodyA = body1;
      jd4.bodyB = body3;
      jd4.joint1 = joint1;
View Full Code Here

TOP

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

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.