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; } }
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); }
internal static Joint Create(JointDef def){ Joint joint = null; switch (def.type) { case JointType.e_distanceJoint: { joint = new DistanceJoint((DistanceJointDef)def); } break; case JointType.e_mouseJoint: { joint = new MouseJoint((MouseJointDef)def); } break; case JointType.e_prismaticJoint: { joint = new PrismaticJoint((PrismaticJointDef)def); } break; case JointType.e_revoluteJoint: { joint = new RevoluteJoint((RevoluteJointDef)def); } break; case JointType.e_pulleyJoint: { joint = new PulleyJoint((PulleyJointDef)def); } break; case JointType.e_gearJoint: { joint = new GearJoint((GearJointDef)def); } break; case JointType.e_wheelJoint: { joint = new WheelJoint((WheelJointDef)def); } break; case JointType.e_weldJoint: { joint = new WeldJoint((WeldJointDef)def); } break; case JointType.e_frictionJoint: { joint = new FrictionJoint((FrictionJointDef)def); } break; case JointType.e_ropeJoint: { throw new NotImplementedException(); //joint = new RopeJoint((RopeJointDef)def); } break; case JointType.e_motorJoint: { joint = new MotorJoint((MotorJointDef)def); } break; default: Utilities.Assert(false); break; } return joint; }
internal static Joint Create(JointDef def) { Joint joint = null; switch (def.type) { case JointType.e_distanceJoint: { joint = new DistanceJoint((DistanceJointDef)def); } break; case JointType.e_mouseJoint: { joint = new MouseJoint((MouseJointDef)def); } break; case JointType.e_prismaticJoint: { joint = new PrismaticJoint((PrismaticJointDef)def); } break; case JointType.e_revoluteJoint: { joint = new RevoluteJoint((RevoluteJointDef)def); } break; case JointType.e_pulleyJoint: { joint = new PulleyJoint((PulleyJointDef)def); } break; case JointType.e_gearJoint: { joint = new GearJoint((GearJointDef)def); } break; case JointType.e_wheelJoint: { joint = new WheelJoint((WheelJointDef)def); } break; case JointType.e_weldJoint: { joint = new WeldJoint((WeldJointDef)def); } break; case JointType.e_frictionJoint: { joint = new FrictionJoint((FrictionJointDef)def); } break; case JointType.e_ropeJoint: { throw new NotImplementedException(); //joint = new RopeJoint((RopeJointDef)def); } break; case JointType.e_motorJoint: { joint = new MotorJoint((MotorJointDef)def); } break; default: Utilities.Assert(false); break; } return(joint); }