예제 #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="PulleyJoint" /> class
        /// </summary>
        /// <param name="def">The def</param>
        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 = Math.Min(def.MaxLength1, Constant - Ratio * MinPulleyLength);
            MaxLength2 = Math.Min(def.MaxLength2, (Constant - MinPulleyLength) / Ratio);

            Impulse       = 0.0f;
            LimitImpulse1 = 0.0f;
            LimitImpulse2 = 0.0f;
        }