Beispiel #1
0
        void DrawJoint(Joint joint)
        {
            Body  b1 = joint.GetBody1();
            Body  b2 = joint.GetBody2();
            XForm xf1, xf2;

            b1.GetXForm(out xf1);
            b2.GetXForm(out xf2);
            Vector2 x1 = xf1.Position;
            Vector2 x2 = xf2.Position;
            Vector2 p1 = joint.GetAnchor1();
            Vector2 p2 = joint.GetAnchor2();

            Color color = ColorEx.FromScRgb(0.5f, 0.8f, 0.8f);

            switch (joint.JointType)
            {
            case JointType.Distance:
                DebugDraw.DrawSegment(p1, p2, color);
                break;

            case JointType.Pulley:
            {
                PulleyJoint pulley = (PulleyJoint)joint;
                Vector2     s1     = pulley.GetGroundAnchor1();
                Vector2     s2     = pulley.GetGroundAnchor2();
                DebugDraw.DrawSegment(s1, p1, color);
                DebugDraw.DrawSegment(s2, p2, color);
                DebugDraw.DrawSegment(s1, s2, color);
            }
            break;

            case JointType.Mouse:
                // don't draw this
                break;

            default:
                DebugDraw.DrawSegment(x1, p1, color);
                DebugDraw.DrawSegment(p1, p2, color);
                DebugDraw.DrawSegment(x2, p2, color);
                break;
            }
        }
Beispiel #2
0
        void DrawJoint(Joint joint)
        {
            Body b1 = joint.GetBody1();
            Body b2 = joint.GetBody2();
            XForm xf1, xf2;
            b1.GetXForm(out xf1);
            b2.GetXForm(out xf2);
            Vector2 x1 = xf1.Position;
            Vector2 x2 = xf2.Position;
            Vector2 p1 = joint.GetAnchor1();
            Vector2 p2 = joint.GetAnchor2();

            Color color = ColorEx.FromScRgb(0.5f, 0.8f, 0.8f);

            switch (joint.JointType)
            {
            case JointType.Distance:
                DebugDraw.DrawSegment(p1, p2, color);
                break;

            case JointType.Pulley:
                {
                    PulleyJoint pulley = (PulleyJoint)joint;
                    Vector2 s1 = pulley.GetGroundAnchor1();
                    Vector2 s2 = pulley.GetGroundAnchor2();
                    DebugDraw.DrawSegment(s1, p1, color);
                    DebugDraw.DrawSegment(s2, p2, color);
                    DebugDraw.DrawSegment(s1, s2, color);
                }
                break;

            case JointType.Mouse:
                // don't draw this
                break;

            default:
                DebugDraw.DrawSegment(x1, p1, color);
                DebugDraw.DrawSegment(p1, p2, color);
                DebugDraw.DrawSegment(x2, p2, color);
                break;
            }
        }