Examples of PolygonShape


Examples of org.jbox2d.collision.shapes.PolygonShape

    private static void setUpObjects() {
        BodyDef boxDef = new BodyDef();
        boxDef.position.set(320 / 30 / 2, 240 / 30 / 2);
        boxDef.type = BodyType.DYNAMIC;
        PolygonShape boxShape = new PolygonShape();
        boxShape.setAsBox(0.75f, 0.75f);
        Body box = world.createBody(boxDef);
        FixtureDef boxFixture = new FixtureDef();
        boxFixture.density = 0.1f;
        boxFixture.shape = boxShape;
        box.createFixture(boxFixture);
        bodies.add(box);

        BodyDef groundDef = new BodyDef();
        groundDef.position.set(0, 0);
        groundDef.type = BodyType.STATIC;
        PolygonShape groundShape = new PolygonShape();
        groundShape.setAsBox(1000, 0);
        Body ground = world.createBody(groundDef);
        FixtureDef groundFixture = new FixtureDef();
        groundFixture.density = 1;
        groundFixture.restitution = 0.3f;
        groundFixture.shape = groundShape;
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

      double rCos15=radius*Math.cos(Math.PI/12);
      double hw=(radius*0.8+rSin15)/2;
     
      FixtureDef triFixD=new FixtureDef();
      FixtureDef recFixD=new FixtureDef();
      PolygonShape triShape=new PolygonShape();
      PolygonShape recShape=new PolygonShape();
     
      Vector[] verticesP=new Vector[]{new Vector(rSin15,rCos15),new Vector(radius,0),new Vector(rSin15,-rCos15)};
      Vec2[] verticesW=new Vec2[3];
      for(int i=0;i<3;i++){
        verticesW[i]=CoordinateConverter.vectorPixelToWorld(verticesP[i]);
      }
      triShape.set(verticesW, verticesW.length);
      recShape.setAsBox(CoordinateConverter.scalerPixelsToWorld(hw),
          CoordinateConverter.scalerPixelsToWorld(radius*0.6) ,
          CoordinateConverter.vectorPixelToWorld(new Vector(rSin15-hw,0)),0);
     
      triFixD.isSensor=true;
      recFixD.isSensor=true;
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

    if(isVerified()){
      this.vertices=vertices;
     
      this.body.setType(BodyType.DYNAMIC);
      this.body.setUserData(this);
      PolygonShape shape=new PolygonShape();
      FixtureDef fixtureDef=new FixtureDef();
     
      Vec2[] vs=new Vec2[vertices.length];
      for(int i=0;i<3;i++){
        vs[i]=CoordinateConverter.vectorPixelToWorld(vertices[i]);
      }
     
      shape.set(vs, 3);
     
      fixtureDef.shape=shape;
      fixtureDef.friction=0.8f;
      fixtureDef.density=3f;
      fixtureDef.restitution=0.3f;
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

    points=Point.getRotatedPoint(getPosition(), getAngle(),tlP,trP,crossP,bmP,blP,brP);
   
    Vec2 crossV=CoordinateConverter.vectorPixelToWorld(position.delta(crossP));
   
    BodyDef bodyD=new BodyDef();
    PolygonShape[] edges=new PolygonShape[]{new PolygonShape(),new PolygonShape(),new PolygonShape(),new PolygonShape()};
   
    bodyD.type=BodyType.STATIC;
    bodyD.angle=(float)-getAngle();
    bodyD.position.set(CoordinateConverter.coordPixelToWorld(getPosition()));
    this.body=creator.getWorld().getWorld().createBody(bodyD);
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

      this.body.setUserData(this);
      body.setBullet(true);
     
      FixtureDef fixD=new FixtureDef();
       
      PolygonShape lineP=new PolygonShape();
     
      this.hL=getWidth()/2;
       
      lineP.setAsBox(CoordinateConverter.scalerPixelsToWorld(getWidth())/2
          ,CoordinateConverter.scalerPixelsToWorld(1),new Vec2(),0);
           
      fixD.density=1.2f;
      fixD.shape=lineP;
      fixD.restitution=0.75f;
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

    seP.translate(getHeight(), getHeight());
    swP.translate(-getHeight(), getHeight());
    this.points=Point.getRotatedPoint(getPosition(),getAngle(),nwP,neP,seP,swP);
   
    BodyDef bodyD=new BodyDef();
    PolygonShape[] edges=new PolygonShape[]{new PolygonShape(),new PolygonShape(),new PolygonShape(),new PolygonShape()};
   
    bodyD.type=BodyType.STATIC;
    bodyD.angle=(float)-getAngle();
    bodyD.position.set(CoordinateConverter.coordPixelToWorld(getPosition()));
    this.body=creator.getWorld().getWorld().createBody(bodyD);
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

  private Polygon (int contentPower,ShapesController controller,Point p,double angle,Vector[] vertices,CssColor color){
    super(contentPower,controller, p, 0, 0, angle, color);
    if(this.isVerified()){
      this.vertices=vertices;
     
      PolygonShape shape=new PolygonShape();
      FixtureDef fixtureDef=new FixtureDef();
     
      Vec2[] vs=new Vec2[vertices.length];
      for(int i=0;i<vs.length;i++){
        vs[i]=CoordinateConverter.vectorPixelToWorld(vertices[i]);
      }
     
      shape.set(vs, vs.length);
     
      fixtureDef.shape=shape;
      fixtureDef.friction=0.7f;
      fixtureDef.density=1.5f;
      fixtureDef.restitution=0.6f;
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

      FixtureDef cirFixDA=new FixtureDef();
      FixtureDef cirFixDB=new FixtureDef();
     
      CircleShape cirShapeA=new CircleShape();
      CircleShape cirShapeB=new CircleShape();
      PolygonShape recShape=new PolygonShape();
     
      cirShapeA.m_radius=radius;
      cirShapeB.m_radius=radius;
      cirShapeA.m_p.set(CoordinateConverter.vectorPixelToWorld(position.delta(pointA)));
      cirShapeB.m_p.set(CoordinateConverter.vectorPixelToWorld(position.delta(pointB)));
      recShape.setAsBox(CoordinateConverter.scalerPixelsToWorld(getWidth()/2),radius, new Vec2(),(float)-getAngle());
     
      recFixD.isSensor=true;
      cirFixDA.isSensor=true;
      cirFixDB.isSensor=true;
     
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

   * @param color
   */
  private Rectangle(int contentPower,ShapesController controller, Point p,double angle,double width,double height,CssColor color){
    super(contentPower,controller, p, width, height, angle, color);
    if(this.isVerified()){
      PolygonShape shape=new PolygonShape();
      FixtureDef fixtureDef=new FixtureDef();
     
      shape.setAsBox(CoordinateConverter.scalerPixelsToWorld(width/2), CoordinateConverter.scalerPixelsToWorld(height/2));
     
      fixtureDef.shape=shape;
      fixtureDef.friction=0.6f;
      fixtureDef.density=1.2f;
      fixtureDef.restitution=0.6f;
View Full Code Here

Examples of org.jbox2d.collision.shapes.PolygonShape

  protected StaticLine(int contentPower,boolean beControlled,Point p1,Point p2, CssColor color){
    super(contentPower,beControlled, p1, p2, color);
    if(isVerified()){
      Vector rpA=position.delta(pointA);
      Vector rpB=position.delta(pointB);
      PolygonShape lineP=new PolygonShape();
      lineP.setAsEdge(CoordinateConverter.vectorPixelToWorld(rpA), CoordinateConverter.vectorPixelToWorld(rpB));
      fixture=body.createFixture(lineP, 0f);
      aabb=fixture.getAABB();
     
    }
  }
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.