Modification de l'angle de rotation des modules

Dans la fonction rendu, nous allons encadrer le coefficient de rotation sur [-10 ; 10] qui détermine la vitesse de rotation.

obj2device_dessin_mesh(mtm_modulea->nbr_de_mat, mtm_modulea, &(*D3DD), &mtm_modulea->obj_mesh);

if (rp->coef_rotation_module<-10.0f) rp->coef_rotation_module=10.0f;
if (rp->coef_rotation_module>10) rp->coef_rotation_module=10;

Ensuite si l'on décide de tourner à gauche ou à droite on fait évoluer l'angle en fonction du coefficient de rotation.

if (etm->droite==1 && rp->coef_rotation_module>=0.0f) {
rp->module_rot+=.02*rp->coef_rotation_module;
rp->coef_rotation_module+=0.20f;
rp->rot_cam+=0.1f;
if(rp->rot_cam>_PI*4) rp->rot_cam=_PI*4;
}

if (etm->gauche==1 && rp->coef_rotation_module<=0.0f) {
rp->module_rot+=.02*rp->coef_rotation_module;
rp->coef_rotation_module-=0.20f;
rp->rot_cam-=0.1f;
if(rp->rot_cam<-_PI*4) rp->rot_cam=-_PI*4;
}

Lorsque la touche est levée, la rotation doit décroître progressivement.

if (etm->droite==2 && rp->coef_rotation_module>=0.0f) {
rp->module_rot+=.02*rp->coef_rotation_module;
rp->coef_rotation_module-=0.20f;
rp->rot_cam-=0.1f;
if(rp->rot_cam<0.0f) rp->rot_cam=0.0f;
}

if (etm->gauche==2 && rp->coef_rotation_module<=0.0f) {
rp->module_rot+=.02*rp->coef_rotation_module;
rp->coef_rotation_module+=0.20f;
rp->rot_cam+=0.1f;
if(rp->rot_cam>0.0f) rp->rot_cam=0.0f;
}

Téléchargez la source, cliquez ci-dessous :