Game Development Reference
In-Depth Information
// Connect CG of objects to each other
Springs[2].End1.ref = 0;
Springs[2].End1.pt.x = 0;
Springs[2].End1.pt.y = 0;
Springs[2].End2.ref = 1;
Springs[2].End2.pt.x = 0;
Springs[2].End2.pt.y = 0;
r = Objects[1].vPosition - Objects[0].vPosition;
Springs[2].InitialLength = r.Magnitude();
Springs[2].k = _SPRING_K;
Springs[2].d = _SPRING_D;
The rest of this simulation is the same as in the linked-chain example. There are no
other code modifications required. It's all in the setup.
Now, if you want to allow some amount of rotation or flexibility in the joint, you can
do so by tuning the spring constant for the rotation restraint spring. Using linear springs
creatively, you can model all sorts of joints very simply.
Search Nedrilad ::




Custom Search