Package org.jbox2d.collision.shapes

Examples of org.jbox2d.collision.shapes.EdgeShape


    m_polygons = new PolygonShape[4];
    {
      BodyDef bd = new BodyDef();
      Body ground = getWorld().createBody(bd);

      EdgeShape shape = new EdgeShape();
      shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
      ground.createFixture(shape, 0.0f);
    }

    {
      Vec2 vertices[] = new Vec2[3];
View Full Code Here


    {
      BodyDef bd = new BodyDef();
      bd.position.set(0.0f, 20.0f);
      ground = getWorld().createBody(bd);

      EdgeShape shape = new EdgeShape();

      FixtureDef sd = new FixtureDef();
      sd.shape = shape;
      sd.density = 0.0f;
      sd.restitution = k_restitution;

      // Left vertical
      shape.set(new Vec2(-20.0f, -20.0f), new Vec2(-20.0f, 20.0f));
      ground.createFixture(sd);

      // Right vertical
      shape.set(new Vec2(20.0f, -20.0f), new Vec2(20.0f, 20.0f));
      ground.createFixture(sd);

      // Top horizontal
      shape.set(new Vec2(-20.0f, 20.0f), new Vec2(20.0f, 20.0f));
      ground.createFixture(sd);

      // Bottom horizontal
      shape.set(new Vec2(-20.0f, -20.0f), new Vec2(20.0f, -20.0f));
      ground.createFixture(sd);
    }

    {
      Transform xf1 = new Transform();
      xf1.q.set(0.3524f * MathUtils.PI);
      Rot.mulToOutUnsafe(xf1.q, new Vec2(1.0f, 0.0f), xf1.p);

      Vec2 vertices[] = new Vec2[3];
      vertices[0] = Transform.mul(xf1, new Vec2(-1.0f, 0.0f));
      vertices[1] = Transform.mul(xf1, new Vec2(1.0f, 0.0f));
      vertices[2] = Transform.mul(xf1, new Vec2(0.0f, 0.5f));

      PolygonShape poly1 = new PolygonShape();
      poly1.set(vertices, 3);

      FixtureDef sd1 = new FixtureDef();
      sd1.shape = poly1;
      sd1.density = 4.0f;

      Transform xf2 = new Transform();
      xf2.q.set(-0.3524f * MathUtils.PI);
      Rot.mulToOut(xf2.q, new Vec2(-1.0f, 0.0f), xf2.p);

      vertices[0] = Transform.mul(xf2, new Vec2(-1.0f, 0.0f));
      vertices[1] = Transform.mul(xf2, new Vec2(1.0f, 0.0f));
      vertices[2] = Transform.mul(xf2, new Vec2(0.0f, 0.5f));

      PolygonShape poly2 = new PolygonShape();
      poly2.set(vertices, 3);

      FixtureDef sd2 = new FixtureDef();
      sd2.shape = poly2;
      sd2.density = 2.0f;

      BodyDef bd = new BodyDef();
      bd.type = BodyType.DYNAMIC;
      bd.angularDamping = 5.0f;
      bd.linearDamping = 0.1f;

      bd.position.set(0.0f, 2.0f);
      bd.angle = MathUtils.PI;
      bd.allowSleep = false;
      m_body = getWorld().createBody(bd);
      m_body.createFixture(sd1);
      m_body.createFixture(sd2);
    }

    {
      PolygonShape shape = new PolygonShape();
      shape.setAsBox(0.5f, 0.5f);

      FixtureDef fd = new FixtureDef();
      fd.shape = shape;
      fd.density = 1.0f;
      fd.friction = 0.3f;
View Full Code Here

          m_vertices[1].set(m_buffer[1]);
          m_count = 2;
          m_radius = chain.m_radius;
          break;
        case EDGE:
          EdgeShape edge = (EdgeShape) shape;
          m_vertices[0].set(edge.m_vertex1);
          m_vertices[1].set(edge.m_vertex2);
          m_count = 2;
          m_radius = edge.m_radius;
          break;
View Full Code Here

        m_debugDraw.drawSolidPolygon(vertices, vertexCount, color);
      }
        break;
      case EDGE: {
        EdgeShape edge = (EdgeShape) fixture.getShape();
        Transform.mulToOutUnsafe(xf, edge.m_vertex1, v1);
        Transform.mulToOutUnsafe(xf, edge.m_vertex2, v2);
        m_debugDraw.drawSegment(v1, v2, color);
      }
        break;
View Full Code Here

          m_vertices[1].set(m_buffer[1]);
          m_count = 2;
          m_radius = chain.m_radius;
          break;
        case EDGE:
          EdgeShape edge = (EdgeShape) shape;
          m_vertices[0].set(edge.m_vertex1);
          m_vertices[1].set(edge.m_vertex2);
          m_count = 2;
          m_radius = edge.m_radius;
          break;
View Full Code Here

          m_debugDraw.drawSolidPolygon(vertices, vertexCount, color);
        }
      }
        break;
      case EDGE: {
        EdgeShape edge = (EdgeShape) fixture.getShape();
        Transform.mulToOutUnsafe(xf, edge.m_vertex1, v1);
        Transform.mulToOutUnsafe(xf, edge.m_vertex2, v2);
        m_debugDraw.drawSegment(v1, v2, color);
      }
        break;
View Full Code Here

    {
      BodyDef bd = new BodyDef();
      Body ground = world.createBody(bd);

      EdgeShape shape = new EdgeShape();
      shape.set(new Vec2(-40.0f, 0f), new Vec2(40.0f, 0f));
      ground.createFixture(shape, 0.0f);
    }


    {
      float a = .5f;
      PolygonShape shape = new PolygonShape();
      shape.setAsBox(a, a);

      Vec2 x = new Vec2(-7.0f, 0.75f);
      Vec2 y = new Vec2();
      Vec2 deltaX = new Vec2(0.5625f, 1f);
      Vec2 deltaY = new Vec2(1.125f, 0.0f);
View Full Code Here

        m_vertices[1].set(m_buffer[1]);
        m_count = 2;
        m_radius = chain.m_radius;
        break;
      case EDGE:
        EdgeShape edge = (EdgeShape)shape;
        m_vertices[0].set(edge.m_vertex1);
        m_vertices[1].set(edge.m_vertex2);
        m_count = 2;
        m_radius = edge.m_radius;
        break;
View Full Code Here

        m_vertices[1].set(m_buffer[1]);
        m_count = 2;
        m_radius = chain.m_radius;
        break;
      case EDGE:
        EdgeShape edge = (EdgeShape)shape;
        m_vertices[0].set(edge.m_vertex1);
        m_vertices[1].set(edge.m_vertex2);
        m_count = 2;
        m_radius = edge.m_radius;
        break;
View Full Code Here

      m_debugDraw.drawSolidPolygon(vertices, vertexCount, color);
    }
      break;
    case EDGE: {
      EdgeShape edge = (EdgeShape)fixture.getShape();
      Transform.mulToOutUnsafe(xf, edge.m_vertex1, v1);
      Transform.mulToOutUnsafe(xf, edge.m_vertex2, v2);
      m_debugDraw.drawSegment(v1, v2, color);
    }
      break;
View Full Code Here

TOP

Related Classes of org.jbox2d.collision.shapes.EdgeShape

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.