Package net.phys2d.raw.shapes

Examples of net.phys2d.raw.shapes.Circle


  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    // world.setGravity(0, 0);
    final Body b1 = new Body(new Circle(5), Body.INFINITE_MASS);
    b1.setPosition(100, 50);
    world.add(b1);

    final Body b2 = new Body(new Circle(5), Body.INFINITE_MASS);
    b2.setPosition(300, 250);
    world.add(b2);

    final Body b3 = new Body(new Circle(5), Body.INFINITE_MASS);
    b3.setPosition(450, 400);
    world.add(b3);

    final Body b4 = new Body(new Circle(5), Body.INFINITE_MASS);
    b4.setPosition(150, 380);
    world.add(b4);

    final Body b5 = new Body(new Circle(10), 130);
    b5.setDamping(0.1f);
    b5.setPosition(0, 350);
    world.add(b5);
    chain(b1, b2, new Vector2f(), new Vector2f(0, -5), 14, world, 0.3f);
    chain(b5, b3, new Vector2f(10, 0), new Vector2f(-5, 0), 20, world, 0f);


    final Body b6 = new Body(new Circle(5), Body.INFINITE_MASS);
    b6.setPosition(440, 50);
    world.add(b6);

    final Body b7 = new Body(new Circle(5), Body.INFINITE_MASS);
    b7.setPosition(440, 340);
    world.add(b7);

    chain(b6, b7, new Vector2f(), new Vector2f(), 15, world,
        (float) Math.PI / 2f);
   
    for (int i = 0; i < 30; i++) {
      final Body b = new Body(new Circle(10), 10);
      b.setPosition(110, -i * 30-50);
      world.add(b);
    }
    //world.setGravity(0, 100);
  }
View Full Code Here


    world.add(body1a);
    Body body1b = new StaticBody("Ground1", new Box(20.0f, 400.0f));
    body1b.setPosition(20.0f, 200);
    world.add(body1b);
   
    Body body2 = new Body("Mover1", new Circle(25), 100.0f);
    body2.setPosition(300.0f, 4.0f);
    world.add(body2);
    //Body body3 = new Body("Mover2", new Box(25,25), 10.0f);
    Body body3 = new Body("Mover2", new Circle(25), 10.0f);
    body3.setRotation(0.3f);
    body3.setPosition(380.0f, 100.0f);
    world.add(body3);
  }
View Full Code Here

    world.add(body1);
    Body body1b = new StaticBody("Ground1", new Box(20.0f, 400.0f));
    body1b.setPosition(20.0f, 200);
    world.add(body1b);

    Body body3 = new Body("Mover2", new Circle(25), 50.0f);
    body3.setPosition(225.0f, 365);
    world.add(body3);
    Body body2 = new Body("Mover1", new Circle(25), 50.0f);
    body2.setPosition(275.0f, 365);
    world.add(body2);
    Body body3a = new Body("Mover2", new Circle(25), 50.0f);
    body3a.setPosition(175.0f, 365);
    world.add(body3a);
    Body body2a = new Body("Mover1", new Circle(25), 50.0f);
    body2a.setPosition(325.0f, 365);
    world.add(body2a);
   
    Body faller = new Body("Faller", new Circle(25), 200.0f);
    faller.setPosition(250.0f, -20f);
    world.add(faller);
  }
View Full Code Here

 
  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body knot = new StaticBody(new Circle(10));
    knot.setPosition(100,400);
    knot.setRotation(0.5f);
    world.add(knot);
    int N=8;
    Body balls[] = new Body[N];
    for(int i=0;i<N;i++){
      Body ball = new Body(new Circle(5),10);
      ball.setPosition(100,400-(i+1)*50);
      ball.setDamping(0.01f);
      world.add(ball);
      balls[i]=ball;
    }
   
    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);
      }
    }
    Body balls1[] = new Body[N];
    for(int i=0;i<N;i++){
      Body ball = new Body(new Circle(5),10);
      ball.setPosition(100,400-(i+1)*50);
      ball.setDamping(0.01f);
      world.add(ball);
      balls1[i]=ball;
    }
 
View Full Code Here

   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    world.setGravity(0,0);
   
    circle1 = new Body("Circle 1", new Circle(20.0f), 1);
    circle1.setPosition(150,100);
    circle1.setRestitution(1.0f);
    circle1.setFriction(0.0f);
    circle1.adjustVelocity(new Vector2f(100,0));
    world.add(circle1);
    circle2 = new Body("Circle 2", new Circle(20.0f), 1);
    circle2.setPosition(250,100);
    circle2.setRestitution(1.0f);
    circle2.setFriction(0.0f);
    world.add(circle2);
  }
View Full Code Here

   */
  protected void keyHit(char c) {
    super.keyHit(c);
   
    if (c == ' ') {
      Body body2 = new Body("Mover1", new Circle(20), 300.0f);
      body2.setPosition(-50, (float) (((Math.random() * 50) + 150)));
      world.add(body2);
      body2.adjustAngularVelocity(1);
      body2.adjustVelocity(new Vector2f(200,(float) (Math.random() * 200)));
    }
 
View Full Code Here

    for (int y=0;y<5;y++) {
      int xbase = 250 - (y * 21);
      for (int x=0;x<y+1;x++) {
        DynamicShape shape = new Box(40,40);
        if ((x == 1) && (y == 2)) {
          shape = new Circle(19);
        }
        if ((x == 1) && (y == 4)) {
          shape = new Circle(19);
        }
        if ((x == 3) && (y == 4)) {
          shape = new Circle(19);
        }
        Body body2 = new Body("Mover1", shape, 100.0f);
        body2.setPosition(xbase + (x * 42), y*45);
        world.add(body2);
      }
 
View Full Code Here

    world.add(body1);
    body1 = new StaticBody("Ground1", new Box(20.0f, 400.0f));
    body1.setPosition(460.0f, 150);
    world.add(body1);
   
    Body body2 = new Body("Mover1", new Circle(15), 10.0f);
    body2.setPosition(200.0f, 30.0f);
    world.add(body2);
    Body body5 = new Body("Mover1", new Circle(15), 10.0f);
    body5.setPosition(-20.0f, 80.0f);
    world.add(body5);
    Body body3 = new Body("Mover2", new Circle(15), 10.0f);
    body3.setPosition(300.0f, 50.0f);
    world.add(body3);
    Body body4 = new Body("Mover3", new Circle(15), 10.0f);
    body4.setPosition(250.0f, 70.0f);
    world.add(body4);
   
    Joint j = new FixedJoint(body2,body3);
    world.add(j);
View Full Code Here

 
  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body leftAxis = new StaticBody(new Circle(10));
    leftAxis.setPosition(100,250);
    leftAxis.setRestitution(1);
    world.add(leftAxis);
   
    wheel = new Body(new Circle(70),400);
    wheel.setPosition(400, 250);
    wheel.setMoveable(false);
    wheel.setDamping(5f);
    world.add(wheel);
   
    Body socket = new Body(new Circle(10),50);
    socket.setPosition(300, 250);
    socket.setRestitution(1);
    world.add(socket);
   
    FixedAngleJoint angle = new FixedAngleJoint(leftAxis,socket,new Vector2f(),new Vector2f(),0);
View Full Code Here

 
  /**
   * @see net.phys2d.raw.test.AbstractDemo#init(net.phys2d.raw.World)
   */
  protected void init(World world) {
    Body knot = new StaticBody(new Circle(10));
    knot.setPosition(250,100);
    world.add(knot);
   
    int N=5;
    Body bodies[] = new Body[N];
    for(int i=0;i<N;i++){
      Body ball = new Body(new Circle(5),10);
      ball.setDamping(0.01f);
      ball.setPosition(280+i*30,100);
      world.add(ball);
      bodies[i]=ball;
    }
 
View Full Code Here

TOP

Related Classes of net.phys2d.raw.shapes.Circle

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.