Package net.phys2d.raw

Examples of net.phys2d.raw.SpringJoint


     
      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


    for(int i=0;i<N;i++){
      if(i==0){
        SpringyAngleJoint saj1 = new SpringyAngleJoint(knot,balls[i],new Vector2f(),new Vector2f(),1e6f,-(float)Math.PI/2.0f-0.15f);
        SpringyAngleJoint saj2 = new SpringyAngleJoint(balls[i],knot,new Vector2f(),new Vector2f(),1e6f,(float)Math.PI/2.0f);
        //DistantConstraint daj = new DistantConstraint(knot,balls[i],new Vector2f(),new Vector2f(),50);
        SpringJoint daj = new SpringJoint(knot,balls[i],new Vector2f(100,400),new Vector2f(balls[i].getPosition()));
        daj.setCompressedSpringConst(100);
        daj.setStretchedSpringConst(100);
        daj.setSpringSize(30);
        world.add(daj);
        world.add(saj1);
        world.add(saj2);
      }else{
        SpringyAngleJoint saj1 = new SpringyAngleJoint(balls[i-1],balls[i],new Vector2f(),new Vector2f(),1e6f,-(float)Math.PI/2.0f);
        SpringyAngleJoint saj2 = new SpringyAngleJoint(balls[i],balls[i-1],new Vector2f(),new Vector2f(),1e6f,(float)Math.PI/2.0f);
        //DistantConstraint daj = new DistantConstraint(balls[i-1],balls[i],new Vector2f(),new Vector2f(),50);
        SpringJoint daj = new SpringJoint(balls[i-1],balls[i],new Vector2f(balls[i-1].getPosition()),new Vector2f(balls[i].getPosition()));
        daj.setCompressedSpringConst(100);
        daj.setStretchedSpringConst(100);
        daj.setSpringSize(50);
        world.add(daj);
        world.add(saj1);
        world.add(saj2);
      }
    }
View Full Code Here

   
    Body body4 = new Body("Mover3", new Box(20.0f, 20.0f), 50.0f);
    body4.setPosition(200f, 200f);
    world.add(body4);
   
    SpringJoint joint1 = new SpringJoint(body1, body2, new Vector2f(150,60), new Vector2f(100, 90));
    joint1.setBrokenSpringConst(10);
    joint1.setCompressedSpringConst(0);
    joint1.setStretchedSpringConst(0);
    joint1.setMinSpringSize(0);
    joint1.setMaxSpringSize(joint1.getSpringSize());
    world.add(joint1);
   
    SpringJoint joint2 = new SpringJoint(body2, body3, new Vector2f(100,110), new Vector2f(160, 150));
    joint2.setBrokenSpringConst(10);
    joint2.setCompressedSpringConst(0);
    joint2.setStretchedSpringConst(0);
    //joint2.setSpringSize(100);
    joint2.setMinSpringSize(0);
    joint2.setMaxSpringSize(joint2.getSpringSize());
    world.add(joint2);
//   
    SpringJoint joint3 = new SpringJoint(body3, body4, new Vector2f(150,160), new Vector2f(200, 210));
    joint3.setBrokenSpringConst(100);
    joint3.setCompressedSpringConst(0);
    joint3.setStretchedSpringConst(0);
    joint3.setMinSpringSize(0);
    joint3.setMaxSpringSize(joint3.getSpringSize());
    world.add(joint3);
   
    SpringJoint joint5 = new SpringJoint(body4, body1, new Vector2f(190, 200), new Vector2f(400, 60));
    joint5.setBrokenSpringConst(1);
    joint5.setCompressedSpringConst(0.5f);
    joint5.setStretchedSpringConst(0.5f);
    joint5.setSpringSize(100);
    joint5.setMinSpringSize(50);
    joint5.setMaxSpringSize(200);
    world.add(joint5);
   
   
//    Body body5 = new Body("Mover4", new Box(20.0f, 20.0f), 100.0f);
//    body2.setPosition(400, 400);
View Full Code Here

TOP

Related Classes of net.phys2d.raw.SpringJoint

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.