Game Development Reference
In-Depth Information
Objects[0].vPosition;
r = pt - Springs[0].End1.pt;
Springs[0].InitialLength = r.Magnitude();
Springs[0].k = _SPRING_K;
Springs[0].d = _SPRING_D;
// Connect other end of first object to end of second object
i = 1;
Springs[i].End1.ref = i-1;
Springs[i].End1.pt.x = Objects[i-1].fLength/2;
Springs[i].End1.pt.y = 0;
Springs[i].End2.ref = i;
Springs[i].End2.pt.x = -Objects[i].fLength/2;
Springs[i].End2.pt.y = 0;
pt = VRotate2D(Objects[i].fOrientation, Springs[i].End2.pt) +
Objects[i].vPosition;
r = pt - (VRotate2D(Objects[i-1].fOrientation, Springs[i].End1.pt) +
Objects[i-1].vPosition);
Springs[i].InitialLength = r.Magnitude();
Springs[i].k = _SPRING_K;
Springs[i].d = _SPRING_D;
// 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 two Objects are positioned with the lines:
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;
Search Nedrilad ::




Custom Search