Game Development Reference
In-Depth Information
Figure 13-7. Rotation restraint in action
The setup for this example is relatively straightforward and consists of setting the initial
positions and orientations of two rigid bodies and connecting three springs.
This example's Initialize function is as follows:
bool Initialize(void)
{
Vector r;
Vector pt;
int i;
// Position objects
Objects[0].vPosition.x = _WINWIDTH/2;
Objects[0].vPosition.y = _WINHEIGHT/8+Objects[0].fLength/2;
Objects[0].fOrientation = 90;
Objects[1].vPosition.x = _WINWIDTH/2+Objects[1].fLength/2;
Objects[1].vPosition.y = _WINHEIGHT/8+Objects[0].fLength;
Objects[1].fOrientation = 0;
// Connect end of the first object to the earth:
Springs[0].End1.ref = −1;
Springs[0].End1.pt.x = _WINWIDTH/2;
Springs[0].End1.pt.y = _WINHEIGHT/8;
Springs[0].End2.ref = 0;
Springs[0].End2.pt.x = -Objects[0].fLength/2;
Springs[0].End2.pt.y = 0;
pt = VRotate2D(Objects[0].fOrientation, Springs[0].End2.pt) +
 
Search Nedrilad ::




Custom Search