public PolyCollision() { { _polygonA.SetAsBox(0.2f, 0.4f); _transformA.Set(new Vector2(0.0f, 0.0f), 0.0f); } { _polygonB.SetAsBox(0.5f, 0.5f); _positionB.Set(19.345284f, 1.5632932f); _angleB = 1.9160721f; _transformB.Set(_positionB, _angleB); } }
protected override void Create() { { _polygonA.SetAsBox(0.2f, 0.4f); _transformA.Set(new Vector2(0.0f, 0.0f), 0.0f); } { _polygonB.SetAsBox(0.5f, 0.5f); _positionB.Set(19.345284f, 1.5632932f); _angleB = 1.9160721f; _transformB.Set(_positionB, _angleB); } }
protected override void Create() { { _transformA.SetIdentity(); _transformA.Position.Set(0.0f, -0.2f); _polygonA.SetAsBox(10.0f, 0.2f); } { _positionB.Set(12.017401f, 0.13678508f); _angleB = -0.0109265f; _transformB.Set(_positionB, _angleB); _polygonB.SetAsBox(2.0f, 0.1f); } }
public DistanceTest() { { _transformA.SetIdentity(); _transformA.Position.Set(0.0f, -0.2f); _polygonA.SetAsBox(10.0f, 0.2f); } { _positionB.Set(12.017401f, 0.13678508f); _angleB = -0.0109265f; _transformB.Set(_positionB, _angleB); _polygonB.SetAsBox(2.0f, 0.1f); } }
private void MoveAABB(ref AABB aabb) { Vector2 d; d.X = RandomFloat(-0.5f, 0.5f); d.Y = RandomFloat(-0.5f, 0.5f); //d.X = 2.0f; //d.Y = 0.0f; aabb.LowerBound += d; aabb.UpperBound += d; var c0 = 0.5f * (aabb.LowerBound + aabb.UpperBound); var min = new Vector2(); min.Set(-_worldExtent, 0.0f); var max = new Vector2(); max.Set(_worldExtent, 2.0f * _worldExtent); var c = Vector2.Clamp(c0, min, max); aabb.LowerBound += c - c0; aabb.UpperBound += c - c0; }
public TheoJansen() { _offset.Set(0.0f, 8.0f); _motorSpeed = 2.0f; _motorOn = true; var pivot = new Vector2(0.0f, 0.8f); // Ground { var bd = new BodyDef(); var ground = World.CreateBody(bd); var shape = new EdgeShape(); shape.SetTwoSided(new Vector2(-50.0f, 0.0f), new Vector2(50.0f, 0.0f)); ground.CreateFixture(shape, 0.0f); shape.SetTwoSided(new Vector2(-50.0f, 0.0f), new Vector2(-50.0f, 10.0f)); ground.CreateFixture(shape, 0.0f); shape.SetTwoSided(new Vector2(50.0f, 0.0f), new Vector2(50.0f, 10.0f)); ground.CreateFixture(shape, 0.0f); } // Balls for (var i = 0; i < 40; ++i) { var shape = new CircleShape(); shape.Radius = 0.25f; var bd = new BodyDef(); bd.BodyType = BodyType.DynamicBody; bd.Position.Set(-40.0f + 2.0f * i, 0.5f); var body = World.CreateBody(bd); body.CreateFixture(shape, 1.0f); } // Chassis { var shape = new PolygonShape(); shape.SetAsBox(2.5f, 1.0f); var sd = new FixtureDef(); sd.Density = 1.0f; sd.Shape = shape; sd.Filter.GroupIndex = -1; var bd = new BodyDef(); bd.BodyType = BodyType.DynamicBody; bd.Position = pivot + _offset; _chassis = World.CreateBody(bd); _chassis.CreateFixture(sd); } { var shape = new CircleShape(); shape.Radius = 1.6f; var sd = new FixtureDef(); sd.Density = 1.0f; sd.Shape = shape; sd.Filter.GroupIndex = -1; var bd = new BodyDef(); bd.BodyType = BodyType.DynamicBody; bd.Position = pivot + _offset; _wheel = World.CreateBody(bd); _wheel.CreateFixture(sd); } { var jd = new RevoluteJointDef(); jd.Initialize(_wheel, _chassis, pivot + _offset); jd.CollideConnected = false; jd.MotorSpeed = _motorSpeed; jd.MaxMotorTorque = 400.0f; jd.EnableMotor = _motorOn; _motorJoint = (RevoluteJoint)World.CreateJoint(jd); } Vector2 wheelAnchor; wheelAnchor = pivot + new Vector2(0.0f, -0.8f); CreateLeg(-1.0f, wheelAnchor); CreateLeg(1.0f, wheelAnchor); _wheel.SetTransform(_wheel.GetPosition(), 120.0f * (float)Math.PI / 180.0f); CreateLeg(-1.0f, wheelAnchor); CreateLeg(1.0f, wheelAnchor); _wheel.SetTransform(_wheel.GetPosition(), -120.0f * (float)Math.PI / 180.0f); CreateLeg(-1.0f, wheelAnchor); CreateLeg(1.0f, wheelAnchor); }