Exemplo n.º 1
0
        /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
        public void Initialize(Body bodyA, Body bodyB,
                               Vec2 groundAnchorA, Vec2 groundAnchorB,
                               Vec2 anchorA, Vec2 anchorB,
                               float ratio)
        {
            BodyA          = bodyA;
            BodyB          = bodyB;
            _groundAnchorA = groundAnchorA;
            _groundAnchorB = groundAnchorB;
            _localAnchorA  = bodyA.GetLocalPoint(anchorA);
            _localAnchorB  = bodyB.GetLocalPoint(anchorB);
            Vec2 d1 = anchorA - groundAnchorA;

            _lengthA = d1.Length();
            Vec2 d2 = anchorB - groundAnchorB;

            _lengthB = d2.Length();
            _ratio   = ratio;

            if (!(ratio > float.Epsilon))
            {
                throw new ArgumentException("Ratio is too small");
            }

            float C = _lengthA + ratio * _lengthB;

            _maxLengthA = C - ratio * b2_minPulleyLength;
            _maxLengthB = (C - b2_minPulleyLength) / ratio;
        }
Exemplo n.º 2
0
        /// Initialize the bodies, anchors, and length using the world
        /// anchors.
        public void Initialize(Body bodyA, Body bodyB,
                               Vec2 anchorA, Vec2 anchorB)
        {
            BodyA         = bodyA;
            BodyB         = bodyB;
            _localAnchorA = bodyA.GetLocalPoint(anchorA);
            _localAnchorB = bodyB.GetLocalPoint(anchorB);
            Vec2 d = anchorB - anchorA;

            _length = d.Length();
        }