public PulleyJoint(PulleyJointDef def) : base(def) { this._ground = this._body1.GetWorld().GetGroundBody(); this._groundAnchor1 = def.GroundAnchor1 - this._ground.GetXForm().Position; this._groundAnchor2 = def.GroundAnchor2 - this._ground.GetXForm().Position; this._localAnchor1 = def.LocalAnchor1; this._localAnchor2 = def.LocalAnchor2; Box2DXDebug.Assert(def.Ratio != 0f); this._ratio = def.Ratio; this._constant = def.Length1 + this._ratio * def.Length2; this._maxLength1 = Box2DX.Common.Math.Min(def.MaxLength1, this._constant - this._ratio * PulleyJoint.MinPulleyLength); this._maxLength2 = Box2DX.Common.Math.Min(def.MaxLength2, (this._constant - PulleyJoint.MinPulleyLength) / this._ratio); this._impulse = 0f; this._limitImpulse1 = 0f; this._limitImpulse2 = 0f; }
public Pulleys() { Body ground = null; { PolygonDef sd = new PolygonDef(); sd.SetAsBox(50.0f, 10.0f); BodyDef bd = new BodyDef(); bd.Position.Set(0.0f, -10.0f); ground = _world.CreateBody(bd); ground.CreateShape(sd); } { float a = 2.0f; float b = 4.0f; float y = 16.0f; float L = 12.0f; PolygonDef sd = new PolygonDef(); sd.SetAsBox(a, b); sd.Density = 5.0f; BodyDef bd = new BodyDef(); bd.Position.Set(-10.0f, y); Body body1 = _world.CreateBody(bd); body1.CreateShape(sd); body1.SetMassFromShapes(); bd.Position.Set(10.0f, y); Body body2 = _world.CreateBody(bd); body2.CreateShape(sd); body2.SetMassFromShapes(); PulleyJointDef pulleyDef = new PulleyJointDef(); Vec2 anchor1 = new Vec2(-10.0f, y + b); Vec2 anchor2 = new Vec2(10.0f, y + b); Vec2 groundAnchor1 = new Vec2(-10.0f, y + b + L); Vec2 groundAnchor2 = new Vec2(10.0f, y + b + L); pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 2.0f); _joint1 = (PulleyJoint)_world.CreateJoint(pulleyDef); } }
public PulleyJoint(PulleyJointDef def) : base(def) { _groundAnchor1 = def.GroundAnchor1; _groundAnchor2 = def.GroundAnchor2; _localAnchor1 = def.LocalAnchor1; _localAnchor2 = def.LocalAnchor2; Box2DXDebug.Assert(def.Ratio != 0.0f); _ratio = def.Ratio; _constant = def.Length1 + _ratio * def.Length2; _maxLength1 = Common.Math.Min(def.MaxLength1, _constant - _ratio * PulleyJoint.MinPulleyLength); _maxLength2 = Common.Math.Min(def.MaxLength2, (_constant - PulleyJoint.MinPulleyLength) / _ratio); _impulse = 0.0f; _limitImpulse1 = 0.0f; _limitImpulse2 = 0.0f; }
public Pulleys() { Body ground = null; { BodyDef bd = new BodyDef(); ground = _world.CreateBody(bd); PolygonShape shape = new PolygonShape(); shape.SetAsEdge(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f)); ground.CreateFixture(shape, 0); } { float a = 2.0f; float b = 4.0f; float y = 16.0f; float L = 12.0f; PolygonShape shape = new PolygonShape(); shape.SetAsBox(a, b); BodyDef bd = new BodyDef(); bd.Position.Set(-10.0f, y); Body body1 = _world.CreateBody(bd); body1.CreateFixture(shape, 5.0f); bd.Position.Set(10.0f, y); Body body2 = _world.CreateBody(bd); body2.CreateFixture(shape, 5.0f); PulleyJointDef pulleyDef = new PulleyJointDef(); Vec2 anchor1 = new Vec2(-10.0f, y + b); Vec2 anchor2 = new Vec2(10.0f, y + b); Vec2 groundAnchor1 = new Vec2(-10.0f, y + b + L); Vec2 groundAnchor2 = new Vec2(10.0f, y + b + L); pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 2.0f); _joint1 = (PulleyJoint)_world.CreateJoint(pulleyDef); } }
public PulleyJoint(PulleyJointDef def) : base(def) { _ground = _body1.GetWorld().GetGroundBody(); _groundAnchor1 = def.GroundAnchor1 - _ground.GetTransform().position; _groundAnchor2 = def.GroundAnchor2 - _ground.GetTransform().position; _localAnchor1 = def.LocalAnchor1; _localAnchor2 = def.LocalAnchor2; Box2DXDebug.Assert(def.Ratio != 0.0f); _ratio = def.Ratio; _constant = def.Length1 + _ratio * def.Length2; _maxLength1 = Common.Math.Min(def.MaxLength1, _constant - _ratio * PulleyJoint.MinPulleyLength); _maxLength2 = Common.Math.Min(def.MaxLength2, (_constant - PulleyJoint.MinPulleyLength) / _ratio); _impulse = 0.0f; _limitImpulse1 = 0.0f; _limitImpulse2 = 0.0f; }
public PulleyJoint(PulleyJointDef def) : base(def) { _ground = _body1.GetWorld().GetGroundBody(); _groundAnchor1 = def.GroundAnchor1 - _ground.GetXForm().Position; _groundAnchor2 = def.GroundAnchor2 - _ground.GetXForm().Position; _localAnchor1 = def.LocalAnchor1; _localAnchor2 = def.LocalAnchor2; Box2DXDebug.Assert(def.Ratio != 0.0f); _ratio = def.Ratio; _constant = def.Length1 + _ratio * def.Length2; _maxLength1 = Common.Math.Min(def.MaxLength1, _constant - _ratio * PulleyJoint.MinPulleyLength); _maxLength2 = Common.Math.Min(def.MaxLength2, (_constant - PulleyJoint.MinPulleyLength) / _ratio); _impulse = 0.0f; _limitImpulse1 = 0.0f; _limitImpulse2 = 0.0f; }