public ChainShape () { super(new org.jbox2d.collision.shapes.ChainShape()); shape = (org.jbox2d.collision.shapes.ChainShape)super.shape; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public void initTest(boolean deserialized) { { BodyDef bd = new BodyDef(); Body ground = m_world.createBody(bd); ChainShape shape = new ChainShape(); Vec2[] vertices = new Vec2[] {new Vec2(-20, 0), new Vec2(20, 0), new Vec2(20, 40), new Vec2(-20, 40)}; shape.createLoop(vertices, 4); ground.createFixture(shape, 0.0f); } m_world.setParticleRadius(0.15f); m_world.setParticleDamping(0.2f); { PolygonShape shape = new PolygonShape(); shape.setAsBox(8, 10, new Vec2(-12, 10.1f), 0); ParticleGroupDef pd = new ParticleGroupDef(); pd.shape = shape; m_world.createParticleGroup(pd); } }
ChainShape weird = new ChainShape(); weird.createLoop( new float[]{vertice1x, vertice1y, vertice2x, ...});
ChainShape chain = new ChainShape(); createChain().Vec2[] vertices = new Vec2[2]; vertices[0] = box2d.coordPixelsToWorld(0,150); vertices[1] = box2d.coordPixelsToWorld(width,150); chain.createChain(vertices, vertices.length); FixtureDef fd = new FixtureDef(); fd.shape = chain; fd.density = 1; fd.friction = 0.3; fd.restitution = 0.5; body.createFixture(fd);
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
private void buildRoom() { Vector2[] roomCorners = new Vector2[]{new Vector2(0f, 0f), new Vector2(0f, ROOM_HEIGHT), new Vector2(ROOM_WIDTH, ROOM_HEIGHT), new Vector2(ROOM_WIDTH, 0f)}; ChainShape roomShape = new ChainShape(); try { roomShape.createLoop(roomCorners); BodyDef roomDef = new BodyDef(); roomDef.type = BodyDef.BodyType.StaticBody; Body room = world.createBody(roomDef); room.createFixture(roomShape, 0); } finally { roomShape.dispose(); } }
vs[2] = new Vec2(7.0f, 8.0f); vs[3] = new Vec2(8.0f, 7.0f); ChainShape shape = new ChainShape(); shape.createChain(vs, 4); ground.createFixture(shape, 0.0f); vs[2] = new Vec2(1.0f, 5.0f); vs[3] = new Vec2(-1.0f, 5.0f); ChainShape shape = new ChainShape(); shape.createLoop(vs, 4); ground.createFixture(shape, 0.0f); vs[8] = new Vec2(-6.0f, 2.0f); vs[9] = new Vec2(-6.0f, 0.0f); ChainShape shape = new ChainShape(); shape.createLoop(vs, 10); ground.createFixture(shape, 0.0f);
break; case CHAIN: { ChainShape chain = new ChainShape(); chain.m_count = s.getPointsCount(); chain.m_vertices = new Vec2[chain.m_count];
Body ground = m_world.createBody(bd); ChainShape shape = new ChainShape(); final Vec2[] vertices = new Vec2[] {new Vec2(-20, 0), new Vec2(20, 0), new Vec2(20, 40), new Vec2(-20, 40)};
ChainShape chain = new ChainShape(); chain.createChain(worldVertices); return chain;
vs[2] = new Vec2(7.0f, 8.0f); vs[3] = new Vec2(8.0f, 7.0f); ChainShape shape = new ChainShape(); shape.createChain(vs, 4); ground.createFixture(shape, 0.0f); vs[2] = new Vec2(1.0f, 5.0f); vs[3] = new Vec2(-1.0f, 5.0f); ChainShape shape = new ChainShape(); shape.createLoop(vs, 4); ground.createFixture(shape, 0.0f); vs[8] = new Vec2(-6.0f, 2.0f); vs[9] = new Vec2(-6.0f, 0.0f); ChainShape shape = new ChainShape(); shape.createLoop(vs, 10); ground.createFixture(shape, 0.0f);