Exemplo n.º 1
0
        public void DrawJoint(b2Joint joint)
        {
            b2Body      bodyA = joint.GetBodyA();
            b2Body      bodyB = joint.GetBodyB();
            b2Transform xf1   = bodyA.Transform;
            b2Transform xf2   = bodyB.Transform;
            b2Vec2      x1    = xf1.p;
            b2Vec2      x2    = xf2.p;
            b2Vec2      p1    = joint.GetAnchorA();
            b2Vec2      p2    = joint.GetAnchorB();

            b2Color color = new b2Color(0.5f, 0.8f, 0.8f);

            switch (joint.JointType)
            {
            case b2JointType.e_distanceJoint:
                m_debugDraw.DrawSegment(p1, p2, color);
                break;

            case b2JointType.e_pulleyJoint:
            {
                b2PulleyJoint pulley = (b2PulleyJoint)joint;
                b2Vec2        s1     = pulley.GetGroundAnchorA();
                b2Vec2        s2     = pulley.GetGroundAnchorB();
                m_debugDraw.DrawSegment(s1, p1, color);
                m_debugDraw.DrawSegment(s2, p2, color);
                m_debugDraw.DrawSegment(s1, s2, color);
            }
            break;

            case b2JointType.e_mouseJoint:
                // don't draw this
                break;

            default:
                m_debugDraw.DrawSegment(x1, p1, color);
                m_debugDraw.DrawSegment(p1, p2, color);
                m_debugDraw.DrawSegment(x2, p2, color);
            }
        }
Exemplo n.º 2
0
    internal static b2Joint Create(b2JointDef def)
    {
        b2Joint joint = null;

        switch (def.type)
        {
        case b2JointType.e_distanceJoint:
        {
            joint = new b2DistanceJoint((b2DistanceJointDef)def);
        }
        break;

        case b2JointType.e_mouseJoint:
        {
            joint = new b2MouseJoint((b2MouseJointDef)def);
        }
        break;

        case b2JointType.e_prismaticJoint:
        {
            joint = new b2PrismaticJoint((b2PrismaticJointDef)def);
        }
        break;

        case b2JointType.e_revoluteJoint:
        {
            joint = new b2RevoluteJoint((b2RevoluteJointDef)def);
        }
        break;

        case b2JointType.e_pulleyJoint:
        {
            joint = new b2PulleyJoint((b2PulleyJointDef)def);
        }
        break;

        case b2JointType.e_gearJoint:
        {
            joint = new b2GearJoint((b2GearJointDef)def);
        }
        break;

        case b2JointType.e_wheelJoint:
        {
            joint = new b2WheelJoint((b2WheelJointDef)def);
        }
        break;

        case b2JointType.e_weldJoint:
        {
            joint = new b2WeldJoint((b2WeldJointDef)def);
        }
        break;

        case b2JointType.e_frictionJoint:
        {
            joint = new b2FrictionJoint((b2FrictionJointDef)def);
        }
        break;

        case b2JointType.e_ropeJoint:
        {
            joint = new b2RopeJoint((b2RopeJointDef)def);
        }
        break;

        case b2JointType.e_motorJoint:
        {
            joint = new b2MotorJoint((b2MotorJointDef)def);
        }
        break;

        default:
            Debug.Assert(false);
            break;
        }

        return(joint);
    }
Exemplo n.º 3
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2PulleyJoint obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }