private void create() { b2Body bodyB; if (connectedB2BodyObject == null) { bodyB = _world.GetGroundBody(); } else { bodyB = connectedB2BodyObject.body; } b2RopeJointDef jointDef = new b2RopeJointDef(); b2Vec2 anchorA = _bodyObject.body.GetWorldPoint(localAnchor1); b2Vec2 anchorB = bodyB.GetWorldPoint(localAnchor2); anchorA.x = (float)System.Math.Round(anchorA.x, 2); anchorA.y = (float)System.Math.Round(anchorA.y, 2); anchorB.x = (float)System.Math.Round(anchorB.x, 2); anchorB.y = (float)System.Math.Round(anchorB.y, 2); jointDef.Initialize(_bodyObject.body, bodyB, anchorA, anchorB, maxLength); jointDef.collideConnected = enableCollision; _joint = _world.CreateJoint(jointDef); _ropeJoint = _joint as b2RopeJoint; _ropeJoint.GetBodyA().SetAwake(true); _ropeJoint.GetBodyB().SetAwake(true); }
// friend class b2Joint; // Limit: // C = norm(pB - pA) - L // u = (pB - pA) / norm(pB - pA) // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA)) // J = [-u -cross(rA, u) u cross(rB, u)] // K = J * invM * JT // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2 internal b2RopeJoint(b2RopeJointDef def) : base(def) { m_localAnchorA = def.localAnchorA; m_localAnchorB = def.localAnchorB; m_maxLength = def.maxLength; m_mass = 0.0f; m_impulse = 0.0f; m_state = b2LimitState.e_inactiveLimit; m_length = 0.0f; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2RopeJointDef obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }