public override void initTest(bool deserialized) { { { PolygonShape shape = new PolygonShape(); Vec2[] vertices = new Vec2[] {new Vec2(-40, -10), new Vec2(40, -10), new Vec2(40, 0), new Vec2(-40, 0)}; shape.set(vertices, 4); getGroundBody().createFixture(shape, 0.0f); } { PolygonShape shape = new PolygonShape(); Vec2[] vertices = {new Vec2(-40, -1), new Vec2(-20, -1), new Vec2(-20, 20), new Vec2(-40, 30)}; shape.set(vertices, 4); getGroundBody().createFixture(shape, 0.0f); } { PolygonShape shape = new PolygonShape(); Vec2[] vertices = {new Vec2(20, -1), new Vec2(40, -1), new Vec2(40, 30), new Vec2(20, 20)}; shape.set(vertices, 4); getGroundBody().createFixture(shape, 0.0f); } } m_world.setParticleRadius(0.35f); m_world.setParticleDamping(0.2f); { CircleShape shape = new CircleShape(); shape.m_p.set(0, 30); shape.m_radius = 20; ParticleGroupDef pd = new ParticleGroupDef(); pd.flags = ParticleType.b2_waterParticle; pd.shape = shape; m_world.createParticleGroup(pd); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; Body body = m_world.createBody(bd); CircleShape shape = new CircleShape(); shape.m_p.set(0, 80); shape.m_radius = 5; body.createFixture(shape, 0.5f); } }
public override void initTest(bool deserialized) { { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.allowSleep = false; bd.position.set(0.0f, 10.0f); Body body = m_world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(0.5f, 10.0f, new Vec2(20.0f, 0.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(0.5f, 10.0f, new Vec2(-20.0f, 0.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(20.0f, 0.5f, new Vec2(0.0f, 10.0f), 0.0f); body.createFixture(shape, 5.0f); shape.setAsBox(20.0f, 0.5f, new Vec2(0.0f, -10.0f), 0.0f); body.createFixture(shape, 5.0f); RevoluteJointDef jd = new RevoluteJointDef(); jd.bodyA = getGroundBody(); jd.bodyB = body; jd.localAnchorA.set(0.0f, 10.0f); jd.localAnchorB.set(0.0f, 0.0f); jd.referenceAngle = 0.0f; jd.motorSpeed = 0.05f*MathUtils.PI; jd.maxMotorTorque = 1e7f; jd.enableMotor = true; m_joint = (RevoluteJoint) m_world.createJoint(jd); } m_world.setParticleRadius(0.15f); m_world.setParticleDamping(0.2f); { ParticleGroupDef pd = new ParticleGroupDef(); pd.flags = 0; PolygonShape shape = new PolygonShape(); shape.setAsBox(9.0f, 9.0f, new Vec2(0.0f, 10.0f), 0.0f); pd.shape = shape; m_world.createParticleGroup(pd); } m_time = 0; }
public override void initTest(bool 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); } }
public override void initTest(bool 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); { PolygonShape shape = new PolygonShape(); shape.setAsBox(20, 4, new Vec2(0, 36), 0); ParticleGroupDef pd = new ParticleGroupDef(); pd.flags = ParticleType.b2_tensileParticle | ParticleType.b2_viscousParticle; pd.shape = shape; m_world.createParticleGroup(pd); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-20, 32), new Vec2(-12, 32)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-11, 32), new Vec2(20, 32)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-12, 32), new Vec2(-12, 28)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-11, 32), new Vec2(-11, 28)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-16, 24), new Vec2(8, 20)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(16, 16), new Vec2(-8, 12)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-12, 8), new Vec2(-12, 0)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-4, 8), new Vec2(-4, 0)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(4, 8), new Vec2(4, 0)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(12, 8), new Vec2(12, 0)); body.createFixture(shape, 0.1f); } }
public override void initTest(bool deserialized) { { BodyDef bd = new BodyDef(); Body ground = m_world.createBody(bd); { PolygonShape shape = new PolygonShape(); Vec2[] vertices = new Vec2[] {new Vec2(-40, -10), new Vec2(40, -10), new Vec2(40, 0), new Vec2(-40, 0)}; shape.set(vertices, 4); ground.createFixture(shape, 0.0f); } { PolygonShape shape = new PolygonShape(); Vec2[] vertices = new Vec2[] {new Vec2(-40, -1), new Vec2(-20, -1), new Vec2(-20, 20), new Vec2(-40, 30)}; shape.set(vertices, 4); ground.createFixture(shape, 0.0f); } { PolygonShape shape = new PolygonShape(); Vec2[] vertices = new Vec2[] {new Vec2(20, -1), new Vec2(40, -1), new Vec2(40, 30), new Vec2(20, 20)}; shape.set(vertices, 4); ground.createFixture(shape, 0.0f); } } m_world.setParticleRadius(0.2f); { PolygonShape shape = new PolygonShape(); shape.setAsBox(20, 10, new Vec2(0, 10), 0); ParticleGroupDef pd = new ParticleGroupDef(); pd.flags = flags; pd.shape = shape; m_world.createParticleGroup(pd); } { BodyDef bd = new BodyDef(); bd.type = BodyType.KINEMATIC; Body body = m_world.createBody(bd); circle = body; CircleShape shape = new CircleShape(); shape.m_p.set(0, 5); shape.m_radius = 1; body.createFixture(shape, 0.1f); body.setLinearVelocity(new Vec2(-6, 0.0f)); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; Body body = m_world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(1, 1, new Vec2(-10, 5), 0); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; Body body = m_world.createBody(bd); PolygonShape shape = new PolygonShape(); shape.setAsBox(1, 1, new Vec2(10, 5), 0.5f); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(0, 20), new Vec2(1, 21)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(3, 20), new Vec2(4, 21)); body.createFixture(shape, 0.1f); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; Body body = m_world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vec2(-3, 21), new Vec2(-2, 20)); body.createFixture(shape, 0.1f); } }
/** * Create a particle group whose properties have been defined. No reference to the definition is * retained. * * @warning This function is locked during callbacks. */ public ParticleGroup createParticleGroup(ParticleGroupDef def) { Debug.Assert(isLocked() == false); if (isLocked()) { return null; } ParticleGroup g = m_particleSystem.createParticleGroup(def); return g; }