Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionint nb_ennemies=3; struct temps* Time = (struct temps*)malloc(nb_ennemies * sizeof *Time);
struct temps { float time, elapsedTime, lastTime; };
float ReturnCurrentTime(t3DModel *pModel, int nextFrame, int i) { // Get the current time in milliseconds Time[i].time = GetTickCount(); // Find the time that has elapsed since the last time that was stored Time[i].elapsedTime = Time[i].time - Time[i].lastTime; // To find the current t we divide the elapsed time by the ratio of 1 second / our anim speed. // Since we aren't using 1 second as our t = 1, we need to divide the speed by 1000 // milliseconds to get our new ratio, which is a 5th of a second. float t = Time[i].elapsedTime / (1000.0f / kAnimationSpeed); // If our elapsed time goes over a 5th of a second, we start over and go to the next key frame if (Time[i].elapsedTime >= (1000.0f / kAnimationSpeed) ) { // Set our current frame to the next key frame (which could be the start of the anim) pModel->currentFrame = nextFrame; // Set our last time to the current time just like we would when getting our FPS. Time[i].lastTime = Time[i].time; } // Return the time t so we can plug this into our interpolation. return t; }
AnimateMD2Model(&g_3DModel[i], i);
t = ReturnCurrentTime(pModel, nextFrame, i);
//du haut vers le bas à droite for (i=1;i<=nb_enemie;i++) { ...... AnimateMD2Model(&g_3DModel[i], i); }
while (1) { fscanf(fenemies,"%f %f %f",&ennemi[i].x, &ennemi[i].y, &ennemi[i].z); fscanf(fenemies,"%f %f %f %f",&ennemi[i].x1, &ennemi[i].x2, &ennemi[i].z1, &ennemi[i].z2); if (feof(fenemies)) break; i++; } fclose(fenemies); //nb_enemie=i;