Create a verlet ragdoll.
40 VerletPoint createPoint(
float mass,
float? radius =
null,
bool? visible =
null)
42 var point = world.CreatePoint(genPos(), mass: mass, radius: radius ?? pointRadius, visible: visible ?? drawIntermediatePoints);
43 point.GravityScale = gravityScale;
47 var headSize = pointRadius * 3;
48 var handSize = pointRadius * 2;
49 var footSize = pointRadius * 1.5f;
50 var headLength = height / 7.5f;
52 head = createPoint(4, radius: headSize, visible:
true);
53 shoulder = createPoint(26);
54 world.CreateLink(head, shoulder, restingDistance: 5 / 4 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
56 elbowLeft = createPoint(2);
57 elbowRight = createPoint(2);
58 world.CreateLink(elbowLeft, shoulder, restingDistance: 3 / 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
59 world.CreateLink(elbowRight, shoulder, restingDistance: 3 / 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
61 handLeft = createPoint(2, radius: handSize, visible:
true);
62 handRight = createPoint(2, radius: handSize, visible:
true);
63 world.CreateLink(handLeft, elbowLeft, restingDistance: 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
64 world.CreateLink(handRight, elbowRight, restingDistance: 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
66 pelvis = createPoint(15);
67 world.CreateLink(pelvis, shoulder, restingDistance: 3.5f * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 0.8f);
68 world.CreateLink(pelvis, head, restingDistance: 4.75f * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 0.02f, visible: drawSupportLinks, color: Colors.LightBlue.WithAlpha(64));
70 kneeLeft = createPoint(10);
71 kneeRight = createPoint(10);
72 world.CreateLink(kneeLeft, pelvis, restingDistance: 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
73 world.CreateLink(kneeRight, pelvis, restingDistance: 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
75 footLeft = createPoint(20, radius: footSize, visible:
true);
76 footRight = createPoint(20, radius: footSize, visible:
true);
77 world.CreateLink(footLeft, kneeLeft, restingDistance: 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
78 world.CreateLink(footRight, kneeRight, restingDistance: 2 * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 1);
79 world.CreateLink(footLeft, shoulder, restingDistance: 7.5f * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 0.001f, visible: drawSupportLinks, color: Colors.LightBlue.WithAlpha(64));
80 world.CreateLink(footRight, shoulder, restingDistance: 7.5f * headLength, tearSensitivityFactor: tearSensitivityFactor, stiffness: 0.001f, visible: drawSupportLinks, color: Colors.LightBlue.WithAlpha(64));
static Vector2 RandVector2(Vector2 rangeX, Vector2 rangeY)
Return a Vector with coordinates in a random range (vector limits).