Game Development Reference
In-Depth Information
Figure 13-4. Swinging links
As in the rope example, the topmost link is connected to a fixed point by a spring, such
that the linked chain pivots around and hangs from the fixed point. The rectangles
represent each rigid link, with the lines connecting the rectangles representing springs.
To model this linked chain, we need only make a few changes to the rope example to
address the fact that we're now dealing with rigid bodies that can rotate versus particles.
This requires us to specify the point on each body to which the springs are attached,
and in addition to computing the spring forces acting on each body, we must also com‐
pute the moments due to those forces. Aside from these spring force and moment
computations, the remainder of the simulation is the same as those discussed in Chap‐
ter 7 through Chapter 12 .
Basic structures and variables
We can use the Spring structure shown earlier in the rope example again here with one
small modification. Basically, we need to change the type of the endpoint references,
End1 and End2 , from integers to a new structure we'll call EndPoint . The new Spring
structure looks like this:
typedef struct _Spring {
EndPoint End1;
EndPoint End2;
float k;
 
Search Nedrilad ::




Custom Search