Java 类com.badlogic.gdx.physics.box2d.joints.PulleyJoint 实例源码

项目:libgdxcn    文件:Box2DDebugRenderer.java   
private void drawJoint (Joint joint) {
    Body bodyA = joint.getBodyA();
    Body bodyB = joint.getBodyB();
    Transform xf1 = bodyA.getTransform();
    Transform xf2 = bodyB.getTransform();

    Vector2 x1 = xf1.getPosition();
    Vector2 x2 = xf2.getPosition();
    Vector2 p1 = joint.getAnchorA();
    Vector2 p2 = joint.getAnchorB();

    if (joint.getType() == JointType.DistanceJoint) {
        drawSegment(p1, p2, JOINT_COLOR);
    } else if (joint.getType() == JointType.PulleyJoint) {
        PulleyJoint pulley = (PulleyJoint)joint;
        Vector2 s1 = pulley.getGroundAnchorA();
        Vector2 s2 = pulley.getGroundAnchorB();
        drawSegment(s1, p1, JOINT_COLOR);
        drawSegment(s2, p2, JOINT_COLOR);
        drawSegment(s1, s2, JOINT_COLOR);
    } else if (joint.getType() == JointType.MouseJoint) {
        drawSegment(joint.getAnchorA(), joint.getAnchorB(), JOINT_COLOR);
    } else {
        drawSegment(x1, p1, JOINT_COLOR);
        drawSegment(p1, p2, JOINT_COLOR);
        drawSegment(x2, p2, JOINT_COLOR);
    }
}
项目:libgdxcn    文件:Box2DDebugRenderer.java   
private void drawJoint (Joint joint) {
    Body bodyA = joint.getBodyA();
    Body bodyB = joint.getBodyB();
    Transform xf1 = bodyA.getTransform();
    Transform xf2 = bodyB.getTransform();

    Vector2 x1 = xf1.getPosition();
    Vector2 x2 = xf2.getPosition();
    Vector2 p1 = joint.getAnchorA();
    Vector2 p2 = joint.getAnchorB();

    if (joint.getType() == JointType.DistanceJoint) {
        drawSegment(p1, p2, JOINT_COLOR);
    } else if (joint.getType() == JointType.PulleyJoint) {
        PulleyJoint pulley = (PulleyJoint)joint;
        Vector2 s1 = pulley.getGroundAnchorA();
        Vector2 s2 = pulley.getGroundAnchorB();
        drawSegment(s1, p1, JOINT_COLOR);
        drawSegment(s2, p2, JOINT_COLOR);
        drawSegment(s1, s2, JOINT_COLOR);
    } else if (joint.getType() == JointType.MouseJoint) {
        drawSegment(joint.getAnchorA(), joint.getAnchorB(), JOINT_COLOR);
    } else {
        drawSegment(x1, p1, JOINT_COLOR);
        drawSegment(p1, p2, JOINT_COLOR);
        drawSegment(x2, p2, JOINT_COLOR);
    }
}
项目:flixel-gdx-box2d    文件:B2FlxPulleyJoint.java   
@Override
public boolean onScreen(FlxCamera camera)
{
    if(joint == null)
        return false;
    if(camera == null)
        camera = FlxG.camera;

    p1.set(joint.getAnchorA().scl(B2FlxB.RATIO));
    p2.set(joint.getAnchorB().scl(B2FlxB.RATIO));

    p1.x -= camera.scroll.x * scrollFactor.x;
    p1.y -= camera.scroll.y * scrollFactor.y;
    p2.x -= camera.scroll.x * scrollFactor.x;
    p2.y -= camera.scroll.y * scrollFactor.y;

    x1.set(((PulleyJoint)joint).getGroundAnchorA().scl(B2FlxB.RATIO));
    x2.set(((PulleyJoint)joint).getGroundAnchorB().scl(B2FlxB.RATIO));
    x1.x -= (int)camera.scroll.x * scrollFactor.x;
    x1.y -= (int)camera.scroll.y * scrollFactor.y;
    x2.x -= (int)camera.scroll.x * scrollFactor.x;
    x2.y -= (int)camera.scroll.y * scrollFactor.y;

    boolean onScreenX = false;
    boolean onScreenY = false;
    if((p1.x <= p2.x) && (p2.x >= 0 && p2.x <= camera.width) || p2.x >= camera.width && p1.x <= camera.width)
        onScreenX = true;
    else if((p1.x >= p2.x) && (p1.x >= 0 && p1.x <= camera.width) || p1.x >= camera.width && p2.x <= camera.width)
        onScreenX = true;
    if((p1.y <= p2.y) && (p2.y >= 0 && p2.y <= camera.height) || p2.y >= camera.height && p1.y <= camera.height)
        onScreenY = true;
    else if((p1.y >= p2.y) && (p1.y >= 0 && p1.y <= camera.height) || p1.y >= camera.height && p2.y <= camera.height)
        onScreenY = true;
    if((x1.y <= x2.y) && (x2.y >= 0 && x2.y <= camera.height) || x2.y >= camera.height && x1.y <= camera.height)
        onScreenY = true;
    else if((x1.y >= x2.y) && (x1.y >= 0 && x1.y <= camera.height) || x1.y >= camera.height && x2.y <= camera.height)
        onScreenY = true;
    return (onScreenX && onScreenY);
}
项目:ingress-indonesia-dev    文件:Box2DDebugRenderer.java   
private void drawJoint(Joint paramJoint)
{
  Body localBody1 = paramJoint.getBodyA();
  Body localBody2 = paramJoint.getBodyB();
  Transform localTransform1 = localBody1.getTransform();
  Transform localTransform2 = localBody2.getTransform();
  Vector2 localVector21 = localTransform1.getPosition();
  Vector2 localVector22 = localTransform2.getPosition();
  Vector2 localVector23 = paramJoint.getAnchorA();
  Vector2 localVector24 = paramJoint.getAnchorB();
  if (paramJoint.getType() == JointDef.JointType.DistanceJoint)
  {
    drawSegment(localVector23, localVector24, this.JOINT_COLOR);
    return;
  }
  if (paramJoint.getType() == JointDef.JointType.PulleyJoint)
  {
    PulleyJoint localPulleyJoint = (PulleyJoint)paramJoint;
    Vector2 localVector25 = localPulleyJoint.getGroundAnchorA();
    Vector2 localVector26 = localPulleyJoint.getGroundAnchorB();
    drawSegment(localVector25, localVector23, this.JOINT_COLOR);
    drawSegment(localVector26, localVector24, this.JOINT_COLOR);
    drawSegment(localVector25, localVector26, this.JOINT_COLOR);
    return;
  }
  if (paramJoint.getType() == JointDef.JointType.MouseJoint)
  {
    drawSegment(paramJoint.getAnchorA(), paramJoint.getAnchorB(), this.JOINT_COLOR);
    return;
  }
  drawSegment(localVector21, localVector23, this.JOINT_COLOR);
  drawSegment(localVector23, localVector24, this.JOINT_COLOR);
  drawSegment(localVector22, localVector24, this.JOINT_COLOR);
}
项目:flixel-gdx-box2d    文件:B2FlxPulleyJoint.java   
@Override
public PulleyJoint getJoint(){return (PulleyJoint)joint;}
项目:ingress-indonesia-dev    文件:World.java   
private long createProperJoint(JointDef paramJointDef)
{
  if (paramJointDef.type == JointDef.JointType.DistanceJoint)
  {
    DistanceJointDef localDistanceJointDef = (DistanceJointDef)paramJointDef;
    return jniCreateDistanceJoint(this.addr, localDistanceJointDef.bodyA.addr, localDistanceJointDef.bodyB.addr, localDistanceJointDef.collideConnected, localDistanceJointDef.localAnchorA.x, localDistanceJointDef.localAnchorA.y, localDistanceJointDef.localAnchorB.x, localDistanceJointDef.localAnchorB.y, localDistanceJointDef.length, localDistanceJointDef.frequencyHz, localDistanceJointDef.dampingRatio);
  }
  if (paramJointDef.type == JointDef.JointType.FrictionJoint)
  {
    FrictionJointDef localFrictionJointDef = (FrictionJointDef)paramJointDef;
    return jniCreateFrictionJoint(this.addr, localFrictionJointDef.bodyA.addr, localFrictionJointDef.bodyB.addr, localFrictionJointDef.collideConnected, localFrictionJointDef.localAnchorA.x, localFrictionJointDef.localAnchorA.y, localFrictionJointDef.localAnchorB.x, localFrictionJointDef.localAnchorB.y, localFrictionJointDef.maxForce, localFrictionJointDef.maxTorque);
  }
  if (paramJointDef.type == JointDef.JointType.GearJoint)
  {
    GearJointDef localGearJointDef = (GearJointDef)paramJointDef;
    return jniCreateGearJoint(this.addr, localGearJointDef.bodyA.addr, localGearJointDef.bodyB.addr, localGearJointDef.collideConnected, localGearJointDef.joint1.addr, localGearJointDef.joint2.addr, localGearJointDef.ratio);
  }
  if (paramJointDef.type == JointDef.JointType.MouseJoint)
  {
    MouseJointDef localMouseJointDef = (MouseJointDef)paramJointDef;
    return jniCreateMouseJoint(this.addr, localMouseJointDef.bodyA.addr, localMouseJointDef.bodyB.addr, localMouseJointDef.collideConnected, localMouseJointDef.target.x, localMouseJointDef.target.y, localMouseJointDef.maxForce, localMouseJointDef.frequencyHz, localMouseJointDef.dampingRatio);
  }
  if (paramJointDef.type == JointDef.JointType.PrismaticJoint)
  {
    PrismaticJointDef localPrismaticJointDef = (PrismaticJointDef)paramJointDef;
    return jniCreatePrismaticJoint(this.addr, localPrismaticJointDef.bodyA.addr, localPrismaticJointDef.bodyB.addr, localPrismaticJointDef.collideConnected, localPrismaticJointDef.localAnchorA.x, localPrismaticJointDef.localAnchorA.y, localPrismaticJointDef.localAnchorB.x, localPrismaticJointDef.localAnchorB.y, localPrismaticJointDef.localAxisA.x, localPrismaticJointDef.localAxisA.y, localPrismaticJointDef.referenceAngle, localPrismaticJointDef.enableLimit, localPrismaticJointDef.lowerTranslation, localPrismaticJointDef.upperTranslation, localPrismaticJointDef.enableMotor, localPrismaticJointDef.maxMotorForce, localPrismaticJointDef.motorSpeed);
  }
  if (paramJointDef.type == JointDef.JointType.PulleyJoint)
  {
    PulleyJointDef localPulleyJointDef = (PulleyJointDef)paramJointDef;
    return jniCreatePulleyJoint(this.addr, localPulleyJointDef.bodyA.addr, localPulleyJointDef.bodyB.addr, localPulleyJointDef.collideConnected, localPulleyJointDef.groundAnchorA.x, localPulleyJointDef.groundAnchorA.y, localPulleyJointDef.groundAnchorB.x, localPulleyJointDef.groundAnchorB.y, localPulleyJointDef.localAnchorA.x, localPulleyJointDef.localAnchorA.y, localPulleyJointDef.localAnchorB.x, localPulleyJointDef.localAnchorB.y, localPulleyJointDef.lengthA, localPulleyJointDef.lengthB, localPulleyJointDef.ratio);
  }
  if (paramJointDef.type == JointDef.JointType.RevoluteJoint)
  {
    RevoluteJointDef localRevoluteJointDef = (RevoluteJointDef)paramJointDef;
    return jniCreateRevoluteJoint(this.addr, localRevoluteJointDef.bodyA.addr, localRevoluteJointDef.bodyB.addr, localRevoluteJointDef.collideConnected, localRevoluteJointDef.localAnchorA.x, localRevoluteJointDef.localAnchorA.y, localRevoluteJointDef.localAnchorB.x, localRevoluteJointDef.localAnchorB.y, localRevoluteJointDef.referenceAngle, localRevoluteJointDef.enableLimit, localRevoluteJointDef.lowerAngle, localRevoluteJointDef.upperAngle, localRevoluteJointDef.enableMotor, localRevoluteJointDef.motorSpeed, localRevoluteJointDef.maxMotorTorque);
  }
  if (paramJointDef.type == JointDef.JointType.WeldJoint)
  {
    WeldJointDef localWeldJointDef = (WeldJointDef)paramJointDef;
    return jniCreateWeldJoint(this.addr, localWeldJointDef.bodyA.addr, localWeldJointDef.bodyB.addr, localWeldJointDef.collideConnected, localWeldJointDef.localAnchorA.x, localWeldJointDef.localAnchorA.y, localWeldJointDef.localAnchorB.x, localWeldJointDef.localAnchorB.y, localWeldJointDef.referenceAngle);
  }
  if (paramJointDef.type == JointDef.JointType.RopeJoint)
  {
    RopeJointDef localRopeJointDef = (RopeJointDef)paramJointDef;
    return jniCreateRopeJoint(this.addr, localRopeJointDef.bodyA.addr, localRopeJointDef.bodyB.addr, localRopeJointDef.collideConnected, localRopeJointDef.localAnchorA.x, localRopeJointDef.localAnchorA.y, localRopeJointDef.localAnchorB.x, localRopeJointDef.localAnchorB.y, localRopeJointDef.maxLength);
  }
  if (paramJointDef.type == JointDef.JointType.WheelJoint)
  {
    WheelJointDef localWheelJointDef = (WheelJointDef)paramJointDef;
    return jniCreateWheelJoint(this.addr, localWheelJointDef.bodyA.addr, localWheelJointDef.bodyB.addr, localWheelJointDef.collideConnected, localWheelJointDef.localAnchorA.x, localWheelJointDef.localAnchorA.y, localWheelJointDef.localAnchorB.x, localWheelJointDef.localAnchorB.y, localWheelJointDef.localAxisA.x, localWheelJointDef.localAxisA.y, localWheelJointDef.enableMotor, localWheelJointDef.maxMotorTorque, localWheelJointDef.motorSpeed, localWheelJointDef.frequencyHz, localWheelJointDef.dampingRatio);
  }
  return 0L;
}