Exemplo n.º 1
0
        internal GearJoint(GearJointDef def)
            : base(def)
        {
            JointType type1 = def.joint1.JointType;
            JointType type2 = def.joint2.JointType;

            Debug.Assert(type1 == JointType.Revolute || type1 == JointType.Prismatic);
            Debug.Assert(type2 == JointType.Revolute || type2 == JointType.Prismatic);
            Debug.Assert(def.joint1.GetBody1().IsStatic);
            Debug.Assert(def.joint2.GetBody1().IsStatic);

            _revolute1 = null;
            _prismatic1 = null;
            _revolute2 = null;
            _prismatic2 = null;

            float coordinate1, coordinate2;

            _ground1 = def.joint1.GetBody1();
            _bodyA = def.joint1.GetBody2();
            if (type1 == JointType.Revolute)
            {
                _revolute1 = (RevoluteJoint)def.joint1;
                _groundAnchor1 = _revolute1._localAnchor1;
                _localAnchor1 = _revolute1._localAnchor2;
                coordinate1 = _revolute1.GetJointAngle();
            }
            else
            {
                _prismatic1 = (PrismaticJoint)def.joint1;
                _groundAnchor1 = _prismatic1._localAnchor1;
                _localAnchor1 = _prismatic1._localAnchor2;
                coordinate1 = _prismatic1.GetJointTranslation();
            }

            _ground2 = def.joint2.GetBody1();
            _bodyB = def.joint2.GetBody2();
            if (type2 == JointType.Revolute)
            {
                _revolute2 = (RevoluteJoint)def.joint2;
                _groundAnchor2 = _revolute2._localAnchor1;
                _localAnchor2 = _revolute2._localAnchor2;
                coordinate2 = _revolute2.GetJointAngle();
            }
            else
            {
                _prismatic2 = (PrismaticJoint)def.joint2;
                _groundAnchor2 = _prismatic2._localAnchor1;
                _localAnchor2 = _prismatic2._localAnchor2;
                coordinate2 = _prismatic2.GetJointTranslation();
            }

            _ratio = def.ratio;

            _ant = coordinate1 + _ratio * coordinate2;

            _impulse = 0.0f;
        }
Exemplo n.º 2
0
        internal GearJoint(GearJointDef def)
            : base(def)
        {
            JointType type1 = def.joint1.JointType;
            JointType type2 = def.joint2.JointType;

            Debug.Assert(type1 == JointType.Revolute || type1 == JointType.Prismatic);
            Debug.Assert(type2 == JointType.Revolute || type2 == JointType.Prismatic);
            Debug.Assert(def.joint1.GetBody1().IsStatic);
            Debug.Assert(def.joint2.GetBody1().IsStatic);

            _revolute1  = null;
            _prismatic1 = null;
            _revolute2  = null;
            _prismatic2 = null;

            float coordinate1, coordinate2;

            _ground1 = def.joint1.GetBody1();
            _bodyA   = def.joint1.GetBody2();
            if (type1 == JointType.Revolute)
            {
                _revolute1     = (RevoluteJoint)def.joint1;
                _groundAnchor1 = _revolute1._localAnchor1;
                _localAnchor1  = _revolute1._localAnchor2;
                coordinate1    = _revolute1.GetJointAngle();
            }
            else
            {
                _prismatic1    = (PrismaticJoint)def.joint1;
                _groundAnchor1 = _prismatic1._localAnchor1;
                _localAnchor1  = _prismatic1._localAnchor2;
                coordinate1    = _prismatic1.GetJointTranslation();
            }

            _ground2 = def.joint2.GetBody1();
            _bodyB   = def.joint2.GetBody2();
            if (type2 == JointType.Revolute)
            {
                _revolute2     = (RevoluteJoint)def.joint2;
                _groundAnchor2 = _revolute2._localAnchor1;
                _localAnchor2  = _revolute2._localAnchor2;
                coordinate2    = _revolute2.GetJointAngle();
            }
            else
            {
                _prismatic2    = (PrismaticJoint)def.joint2;
                _groundAnchor2 = _prismatic2._localAnchor1;
                _localAnchor2  = _prismatic2._localAnchor2;
                coordinate2    = _prismatic2.GetJointTranslation();
            }

            _ratio = def.ratio;

            _ant = coordinate1 + _ratio * coordinate2;

            _impulse = 0.0f;
        }