Examples of DistanceJoint


Examples of eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.DistanceJoint

        envs[0] = env;
       
        env.addAgent(new Phys3Agent(0, env, "Agent0", 10, params), new Vector2D(0, -5), 180);
        env.addAgent(new Phys3JetAgent(1, env, "Agent1", 10, params), new Vector2D(-3, 1), 180);
        env.addAgent(new Phys3JetAgent(2, env, "Agent2", 10, params), new Vector2D(3, 1), 180);
        j1 = new DistanceJoint(
                env.getAgent(0),
                env.getAgent(1),
                new Vector2f(4, -5),
                new Vector2f(0, 0.9f),
                0);
        j2 = new DistanceJoint(
                env.getAgent(0),
                env.getAgent(2),
                new Vector2f(-4, -5),
                new Vector2f(0, 0.9f),
                0);
View Full Code Here

Examples of net.phys2d.raw.DistanceJoint

      g.drawLine((int) p1.x, (int) p1.y, (int) x2.getX(), (int) x2.getY());
      g.drawLine((int) x2.getX(), (int) x2.getY(), (int) p2.x, (int) p2.y);
      g.drawLine((int) p2.x, (int) p2.y, (int) x1.getX(), (int) x1.getY());
    }
    if(j instanceof DistanceJoint){
      DistanceJoint joint = (DistanceJoint) j;
     
      Body b1 = joint.getBody1();
      Body b2 = joint.getBody2();
 
      Matrix2f R1 = new Matrix2f(b1.getRotation());
      Matrix2f R2 = new Matrix2f(b2.getRotation());
 
      ROVector2f x1 = b1.getPosition();
      Vector2f p1 = MathUtil.mul(R1,joint.getAnchor1());
      p1.add(x1);
 
      ROVector2f x2 = b2.getPosition();
      Vector2f p2 = MathUtil.mul(R2,joint.getAnchor2());
      p2.add(x2);
     
      g.setColor(Color.red);
      g.drawLine((int) p1.getX(), (int) p1.getY(), (int) p2.x, (int) p2.y);
    }
    if (j instanceof SpringJoint) {
      SpringJoint joint = (SpringJoint) j;
     
      Body b1 = joint.getBody1();
      Body b2 = joint.getBody2();
 
      Matrix2f R1 = new Matrix2f(b1.getRotation());
      Matrix2f R2 = new Matrix2f(b2.getRotation());
 
      ROVector2f x1 = b1.getPosition();
      Vector2f p1 = MathUtil.mul(R1,joint.getLocalAnchor1());
      p1.add(x1);
 
      ROVector2f x2 = b2.getPosition();
      Vector2f p2 = MathUtil.mul(R2,joint.getLocalAnchor2());
      p2.add(x2);
     
      g.setColor(Color.red);
      g.drawLine((int) x1.getX(), (int) x1.getY(), (int) p1.x, (int) p1.y);
      g.drawLine((int) p1.x, (int) p1.y, (int) p2.getX(), (int) p2.getY());
View Full Code Here

Examples of net.phys2d.raw.DistanceJoint

      bodies[i] = body;
      world.add(body);
    }

    for (int i = 1; i < N; i++) {
      final DistanceJoint dj = new DistanceJoint(bodies[i - 1],
          bodies[i], new Vector2f(7, 0), new Vector2f(-7, 0), 6);
/*      Vector2f v1,v2;
      v1 = new Vector2f(bodies[i-1].getPosition());v1.x+=7;
      v2 = new Vector2f(bodies[i].getPosition());v2.x-=7;
      SpringJoint dj = new SpringJoint(bodies[i - 1],
          bodies[i], v1, v2);
      dj.setMinSpringSize(4);
      dj.setSpringSize(1);
      dj.setStretchedSpringConst(100);
      dj.setCompressedSpringConst(100);
      dj.setMaxSpringSize(6);*/
      world.add(dj);
    }
    {
      final DistanceJoint dj = new DistanceJoint(body1, bodies[0],
          anchor1, new Vector2f(-7, 0), 10);
      world.add(dj);
    }
    if (body2 != null) {
      final DistanceJoint dj = new DistanceJoint(body2, bodies[N - 1],
          anchor2, new Vector2f(7, 0), 10);
      world.add(dj);
    }
  }
View Full Code Here

Examples of net.phys2d.raw.DistanceJoint

    }
    for(int i=0;i<N;i++){
      if(i==0){
        SpringyAngleJoint saj1 = new SpringyAngleJoint(knot,balls1[i],new Vector2f(),new Vector2f(),1e6f,-(float)Math.PI/2.0f+0.45f);
        SpringyAngleJoint saj2 = new SpringyAngleJoint(balls1[i],knot,new Vector2f(),new Vector2f(),1e6f,(float)Math.PI/2.0f);
        DistanceJoint daj = new DistanceJoint(knot,balls1[i],new Vector2f(),new Vector2f(),50);

        world.add(daj);
        world.add(saj1);
        world.add(saj2);
      }else{
        SpringyAngleJoint saj1 = new SpringyAngleJoint(balls1[i-1],balls1[i],new Vector2f(),new Vector2f(),1e6f,-(float)Math.PI/2.0f);
        SpringyAngleJoint saj2 = new SpringyAngleJoint(balls1[i],balls1[i-1],new Vector2f(),new Vector2f(),1e6f,(float)Math.PI/2.0f);
        DistanceJoint daj = new DistanceJoint(balls1[i-1],balls1[i],new Vector2f(),new Vector2f(),50);

        world.add(daj);
        world.add(saj1);
        world.add(saj2);
      }
View Full Code Here

Examples of net.phys2d.raw.DistanceJoint

    world.add(socket);
   
    FixedAngleJoint angle = new FixedAngleJoint(leftAxis,socket,new Vector2f(),new Vector2f(),0);
    world.add(angle);
   
    DistanceJoint dist = new DistanceJoint(socket,wheel,new Vector2f(),new Vector2f(65,0),165);
    world.add(dist);
  }
View Full Code Here

Examples of net.phys2d.raw.DistanceJoint

      bodies[i]=b2;
    }
   
    final AngleJoint aj1 = new AngleJoint(b1,bodies[0],new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f,-0.0f);
    //AngleJoint aj1 = new AngleJoint(b1,bodies[0],new Vector2f(),new Vector2f(),0.0f,-0.0f);
    final DistanceJoint dj1 = new DistanceJoint(b1,bodies[0],new Vector2f(),new Vector2f(),30);
    final AngleJoint aja2 = new AngleJoint(bodies[0],b1,new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f+(float)Math.PI,(float)Math.PI);
    world.add(aja2);
    world.add(dj1);
    world.add(aj1);
    for(int i=1;i<N;i++){
      final AngleJoint aj = new AngleJoint(bodies[i-1],bodies[i],new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f,-0.0f);
      world.add(aj);
     
      final AngleJoint aj2 = new AngleJoint(bodies[i],bodies[i-1],new Vector2f(),new Vector2f(),-(float)Math.PI/9.0f+(float)(Math.PI+Math.sin(i/10.0f)),(float)(Math.PI+Math.sin(i/10.0f)));
      world.add(aj2);
     
      final DistanceJoint dj = new DistanceJoint(bodies[i-1],bodies[i],new Vector2f(),new Vector2f(),30);
      world.add(dj);
    }
  }
View Full Code Here

Examples of org.jbox2d.dynamics.joints.DistanceJoint

        builder.setMaxMotorForce(j.getMaxMotorForce());
        builder.setMotorSpeed(j.getMotorSpeed());
        break;
      }
      case DISTANCE: {
        DistanceJoint j = (DistanceJoint) joint;
        builder.setType(PbJointType.DISTANCE);
        builder.setLocalAnchorA(vecToPb(j.getLocalAnchorA()));
        builder.setLocalAnchorB(vecToPb(j.getLocalAnchorB()));
        builder.setLength(j.getLength());
        builder.setFrequency(j.getFrequency());
        builder.setDampingRatio(j.getDampingRatio());
        break;
      }
      case PULLEY: {
        PulleyJoint j = (PulleyJoint) joint;
        builder.setType(PbJointType.PULLEY);
        builder.setLocalAnchorA(vecToPb(j.getLocalAnchorA()));
        builder.setLocalAnchorB(vecToPb(j.getLocalAnchorB()));
        builder.setGroundAnchorA(vecToPb(j.getGroundAnchorA()));
        builder.setGroundAnchorB(vecToPb(j.getGroundAnchorB()));
        builder.setLengthA(j.getLengthA());
        builder.setLengthB(j.getLengthB());
        builder.setRatio(j.getRatio());
        break;
      }
      case MOUSE: {
        MouseJoint j = (MouseJoint) joint;
        builder.setType(PbJointType.MOUSE);
        builder.setTarget(vecToPb(j.getTarget()));
        builder.setMaxForce(j.getMaxForce());
        builder.setFrequency(j.getFrequency());
        builder.setDampingRatio(j.getDampingRatio());
        break;
      }
      case GEAR: {
        GearJoint j = (GearJoint) joint;
        builder.setType(PbJointType.GEAR);
        builder.setRatio(j.getRatio());
        if (!argJointIndexMap.containsKey(j.getJoint1())) {
          throw new IllegalArgumentException("Joint 1 not in map");
        }
        int j1 = argJointIndexMap.get(j.getJoint1());
        if (!argJointIndexMap.containsKey(j.getJoint2())) {
          throw new IllegalArgumentException("Joint 2 not in map");
        }
        int j2 = argJointIndexMap.get(j.getJoint2());

        builder.setJoint1(j1);
        builder.setJoint2(j2);
        break;
      }
      case FRICTION: {
        FrictionJoint j = (FrictionJoint) joint;
        builder.setType(PbJointType.FRICTION);
        builder.setLocalAnchorA(vecToPb(j.getLocalAnchorA()));
        builder.setLocalAnchorB(vecToPb(j.getLocalAnchorB()));
        builder.setMaxForce(j.getMaxForce());
        builder.setMaxTorque(j.getMaxTorque());
        break;
      }
      case CONSTANT_VOLUME: {
        ConstantVolumeJoint j = (ConstantVolumeJoint) joint;
        builder.setType(PbJointType.CONSTANT_VOLUME);

        for (int i = 0; i < j.getBodies().length; i++) {
          Body b = j.getBodies()[i];
          DistanceJoint djoint = j.getJoints()[i];
          if (!argBodyIndexMap.containsKey(b)) {
            throw new IllegalArgumentException("Body " + b + " is not present in the index map");
          }
          builder.addBodies(argBodyIndexMap.get(b));
          if (!argJointIndexMap.containsKey(djoint)) {
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.