Exemplo n.º 1
0
        public b2Joint(b2JointDef def)
        {
            Debug.Assert(def.BodyA != def.BodyB);

            m_type             = def.JointType;
            Prev               = null;
            Next               = null;
            m_bodyA            = def.BodyA;
            m_bodyB            = def.BodyB;
            m_index            = 0;
            m_collideConnected = def.CollideConnected;
            m_islandFlag       = false;
            m_userData         = def.UserData;
            m_edgeA            = new b2JointEdge();
            m_edgeB            = new b2JointEdge();
        }
Exemplo n.º 2
0
        public b2Joint(b2JointDef def)
        {
            Debug.Assert(def.BodyA != def.BodyB);

            m_type = def.JointType;
            Prev = null;
            Next = null;
            m_bodyA = def.BodyA;
            m_bodyB = def.BodyB;
            m_index = 0;
            m_collideConnected = def.CollideConnected;
            m_islandFlag = false;
            m_userData = def.UserData;

            m_edgeA.Joint = null;
            m_edgeA.Other = null;
            m_edgeA.Prev = null;
            m_edgeA.Next = null;

            m_edgeB.Joint = null;
            m_edgeB.Other = null;
            m_edgeB.Prev = null;
            m_edgeB.Next = null;
        }
Exemplo n.º 3
0
        public b2GearJoint(b2GearJointDef def)
            : base(def)
        {
            m_joint1 = def.joint1;
            m_joint2 = def.joint2;

            m_typeA = m_joint1.GetJointType();
            m_typeB = m_joint2.GetJointType();

            Debug.Assert(m_typeA == b2JointType.e_revoluteJoint || m_typeA == b2JointType.e_prismaticJoint);
            Debug.Assert(m_typeB == b2JointType.e_revoluteJoint || m_typeB == b2JointType.e_prismaticJoint);

            float coordinateA, coordinateB;

            // TODO_ERIN there might be some problem with the joint edges in b2Joint.

            m_bodyC = m_joint1.GetBodyA();
            m_bodyA = m_joint1.GetBodyB();

            // Get geometry of joint1
            b2Transform xfA = m_bodyA.XF;
            float       aA  = m_bodyA.Sweep.a;
            b2Transform xfC = m_bodyC.XF;
            float       aC  = m_bodyC.Sweep.a;

            if (m_typeA == b2JointType.e_revoluteJoint)
            {
                b2RevoluteJoint revolute = (b2RevoluteJoint)def.joint1;
                m_localAnchorC    = revolute.GetLocalAnchorA();
                m_localAnchorA    = revolute.GetLocalAnchorB();
                m_referenceAngleA = revolute.GetReferenceAngle();
                m_localAxisC.SetZero();

                coordinateA = aA - aC - m_referenceAngleA;
            }
            else
            {
                b2PrismaticJoint prismatic = (b2PrismaticJoint)def.joint1;
                m_localAnchorC    = prismatic.GetLocalAnchorA();
                m_localAnchorA    = prismatic.GetLocalAnchorB();
                m_referenceAngleA = prismatic.GetReferenceAngle();
                m_localAxisC      = prismatic.GetLocalXAxisA();

                b2Vec2 pC = m_localAnchorC;
                b2Vec2 pA = b2Math.b2MulT(xfC.q, b2Math.b2Mul(xfA.q, m_localAnchorA) + (xfA.p - xfC.p));
                coordinateA = b2Math.b2Dot(pA - pC, m_localAxisC);
            }

            m_bodyD = m_joint2.GetBodyA();
            m_bodyB = m_joint2.GetBodyB();

            // Get geometry of joint2
            b2Transform xfB = m_bodyB.XF;
            float       aB  = m_bodyB.Sweep.a;
            b2Transform xfD = m_bodyD.XF;
            float       aD  = m_bodyD.Sweep.a;

            if (m_typeB == b2JointType.e_revoluteJoint)
            {
                b2RevoluteJoint revolute = (b2RevoluteJoint)def.joint2;
                m_localAnchorD    = revolute.GetLocalAnchorA();
                m_localAnchorB    = revolute.GetLocalAnchorB();
                m_referenceAngleB = revolute.GetReferenceAngle();
                m_localAxisD.SetZero();

                coordinateB = aB - aD - m_referenceAngleB;
            }
            else
            {
                b2PrismaticJoint prismatic = (b2PrismaticJoint)def.joint2;
                m_localAnchorD    = prismatic.GetLocalAnchorA();
                m_localAnchorB    = prismatic.GetLocalAnchorB();
                m_referenceAngleB = prismatic.GetReferenceAngle();
                m_localAxisD      = prismatic.GetLocalXAxisA();

                b2Vec2 pD = m_localAnchorD;
                b2Vec2 pB = b2Math.b2MulT(xfD.q, b2Math.b2Mul(xfB.q, m_localAnchorB) + (xfB.p - xfD.p));
                coordinateB = b2Math.b2Dot(pB - pD, m_localAxisD);
            }

            m_ratio = def.ratio;

            m_constant = coordinateA + m_ratio * coordinateB;

            m_impulse = 0.0f;
        }
Exemplo n.º 4
0
        public b2GearJoint(b2GearJointDef def)
            : base(def)
        {
            m_joint1 = def.joint1;
            m_joint2 = def.joint2;

            m_typeA = m_joint1.GetJointType();
            m_typeB = m_joint2.GetJointType();

            Debug.Assert(m_typeA == b2JointType.e_revoluteJoint || m_typeA == b2JointType.e_prismaticJoint);
            Debug.Assert(m_typeB == b2JointType.e_revoluteJoint || m_typeB == b2JointType.e_prismaticJoint);

            float coordinateA, coordinateB;

            // TODO_ERIN there might be some problem with the joint edges in b2Joint.

            m_bodyC = m_joint1.GetBodyA();
            m_bodyA = m_joint1.GetBodyB();

            // Get geometry of joint1
            b2Transform xfA = m_bodyA.XF;
            float aA = m_bodyA.Sweep.a;
            b2Transform xfC = m_bodyC.XF;
            float aC = m_bodyC.Sweep.a;

            if (m_typeA == b2JointType.e_revoluteJoint)
            {
                b2RevoluteJoint revolute = (b2RevoluteJoint)def.joint1;
                m_localAnchorC = revolute.GetLocalAnchorA();
                m_localAnchorA = revolute.GetLocalAnchorB();
                m_referenceAngleA = revolute.GetReferenceAngle();
                m_localAxisC.SetZero();

                coordinateA = aA - aC - m_referenceAngleA;
            }
            else
            {
                b2PrismaticJoint prismatic = (b2PrismaticJoint)def.joint1;
                m_localAnchorC = prismatic.GetLocalAnchorA();
                m_localAnchorA = prismatic.GetLocalAnchorB();
                m_referenceAngleA = prismatic.GetReferenceAngle();
                m_localAxisC = prismatic.GetLocalXAxisA();

                b2Vec2 pC = m_localAnchorC;
                b2Vec2 pA = b2Math.b2MulT(xfC.q, b2Math.b2Mul(xfA.q, m_localAnchorA) + (xfA.p - xfC.p));
                coordinateA = b2Math.b2Dot(pA - pC, m_localAxisC);
            }

            m_bodyD = m_joint2.GetBodyA();
            m_bodyB = m_joint2.GetBodyB();

            // Get geometry of joint2
            b2Transform xfB = m_bodyB.XF;
            float aB = m_bodyB.Sweep.a;
            b2Transform xfD = m_bodyD.XF;
            float aD = m_bodyD.Sweep.a;

            if (m_typeB == b2JointType.e_revoluteJoint)
            {
                b2RevoluteJoint revolute = (b2RevoluteJoint)def.joint2;
                m_localAnchorD = revolute.GetLocalAnchorA();
                m_localAnchorB = revolute.GetLocalAnchorB();
                m_referenceAngleB = revolute.GetReferenceAngle();
                m_localAxisD.SetZero();

                coordinateB = aB - aD - m_referenceAngleB;
            }
            else
            {
                b2PrismaticJoint prismatic = (b2PrismaticJoint)def.joint2;
                m_localAnchorD = prismatic.GetLocalAnchorA();
                m_localAnchorB = prismatic.GetLocalAnchorB();
                m_referenceAngleB = prismatic.GetReferenceAngle();
                m_localAxisD = prismatic.GetLocalXAxisA();

                b2Vec2 pD = m_localAnchorD;
                b2Vec2 pB = b2Math.b2MulT(xfD.q, b2Math.b2Mul(xfB.q, m_localAnchorB) + (xfB.p - xfD.p));
                coordinateB = b2Math.b2Dot(pB - pD, m_localAxisD);
            }

            m_ratio = def.ratio;

            m_constant = coordinateA + m_ratio * coordinateB;

            m_impulse = 0.0f;
        }
Exemplo n.º 5
0
        public b2JointType GetType()
        {
            b2JointType ret = (b2JointType)Box2DPINVOKE.b2Joint_GetType(swigCPtr);

            return(ret);
        }