|
|
suppose you want to move an object from one point to another over a period of 1,000 milliseconds. The following code (processed once per frame) will accomplish this, continuously looping back from the end to the start of the path in an endless cycle.
// vecPoints[2] = path's starting and ending coordinate vectors
// Every frame, use the following code to position an object
// along the straight path based on the current time.
float Scalar = (float)(timeGetTime() % 1001) / 1000.0f;
/*上面的timeGetTime求余为什么要加1啊,我认为直接要1000就可以了??!*/
D3DXVECTOR3 vecPos = (vecPoints[1] − vecPoints[0]) *Scalar + vecPoints[0];
// Use vecPos.x, vecPos.y, and vecPos.z coordinates for object
|
|