Exemplo n.º 1
0
        void DrawJoint(Joint joint)
        {
            Body      b1 = joint.GetBodyA();
            Body      b2 = joint.GetBodyB();
            Transform xf1, xf2;

            b1.GetTransform(out xf1);
            b2.GetTransform(out xf2);
            Vector2 x1 = xf1.Position;
            Vector2 x2 = xf2.Position;
            Vector2 p1 = joint.GetAnchorA();
            Vector2 p2 = joint.GetAnchorB();

            Color color = new Color(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.GetGroundAnchorA();
                Vector2     s2     = pulley.GetGroundAnchorB();
                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;
            }
        }
Exemplo n.º 2
0
        internal static Joint Create(JointDef def)
        {
            Joint joint = null;

            switch (def.type)
            {
            case JointType.Distance:
                {
                    joint = new DistanceJoint((DistanceJointDef)def);
                }
                break;

            case JointType.Mouse:
                {
                    joint = new MouseJoint((MouseJointDef)def);
                }
                break;

            case JointType.Prismatic:
                {
                    joint = new PrismaticJoint((PrismaticJointDef)def);
                }
                break;

            case JointType.Revolute:
                {
                    joint = new RevoluteJoint((RevoluteJointDef)def);
                }
                break;

            case JointType.Pulley:
                {
                    joint = new PulleyJoint((PulleyJointDef)def);
                }
                break;

            case JointType.Gear:
                {
                    joint = new GearJoint((GearJointDef)def);
                }
                break;

            case JointType.Line:
                {
                    joint = new LineJoint((LineJointDef)def);
                }
                break;

            case JointType.Weld:
                {
                    joint = new WeldJoint((WeldJointDef)def);
                }
                break;
            case JointType.Friction:
                {
                    joint = new FrictionJoint((FrictionJointDef)def);
                }
                break;
            case JointType.MaxDistance:
                {
                    joint = new MaxDistanceJoint((MaxDistanceJointDef)def);
                }
                break;

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

            return joint;
        }
Exemplo n.º 3
0
Arquivo: Joint.cs Projeto: Bitsits/web
        internal static Joint Create(JointDef def)
        {
            Joint joint = null;

            switch (def.type)
            {
            case JointType.Distance:
            {
                joint = new DistanceJoint((DistanceJointDef)def);
            }
            break;

            case JointType.Mouse:
            {
                joint = new MouseJoint((MouseJointDef)def);
            }
            break;

            case JointType.Prismatic:
            {
                joint = new PrismaticJoint((PrismaticJointDef)def);
            }
            break;

            case JointType.Revolute:
            {
                joint = new RevoluteJoint((RevoluteJointDef)def);
            }
            break;

            case JointType.Pulley:
            {
                joint = new PulleyJoint((PulleyJointDef)def);
            }
            break;

            case JointType.Gear:
            {
                joint = new GearJoint((GearJointDef)def);
            }
            break;

            case JointType.Line:
            {
                joint = new LineJoint((LineJointDef)def);
            }
            break;

            case JointType.Weld:
            {
                joint = new WeldJoint((WeldJointDef)def);
            }
            break;

            case JointType.Friction:
            {
                joint = new FrictionJoint((FrictionJointDef)def);
            }
            break;

            case JointType.MaxDistance:
            {
                joint = new MaxDistanceJoint((MaxDistanceJointDef)def);
            }
            break;

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

            return(joint);
        }