Froggy One
Nombre de messages : 598 Date d'inscription : 06/01/2012
| Sujet: C'est pas dans l'axe... Sam 19 Aoû 2023 - 9:13 | |
| Me revoilà ! avec un petit bout de programme qui fait tourner un solide, et surtout, arr$ete la rotation (bouton =) ou fait revenir à zéro (bouton 0). Petit problème : si je traite un axe à la fois tout va bien ; mais si j'agis sur deux ou trois axes (gérés par des TIMER différents), alors à l'arrivée la remise à zéro me donne un solide orienté bizarre, alors que relancer la rotation me donne un angle de 1 ou -1 (selon) ce qui prouve que pour la machine on était bien sur une position à zéro degrés. Mais pas sur l'écran !!! Voici le code pour ceux qui auraient l'envie de s'y plonger : - Code:
-
Caption 0, " Mission 24"
color 0,50,50,50 timer 1:timer 2:timer 3 dim i for i=1 to 3 timer_interval i,150 next i
dim var1,var2,var3,vit1,vit2,vit3 dim la_fin
label Tm1,Tm2,Tm3 label affichage_digit_XYZ,affichage_bttn_XYZ,The_END label deb1,debut1,deb2,debut2,deb3,debut3 label XRotG-,XRot2G-,XRotG+,XRot2G+,YRotG-,YRot2G-,YRotG+,YRot2G+ label ZRotG-,ZRot2G-,ZRotG+,ZRot2G+ label EgalX,ZeroX,EgalY,ZeroY,EgalZ,ZeroZ
on_close 0,The_END scene3D 100:color 100,0,0,0 left 100,150:top 100,100:width 100,250:height 100,250
shape 101:color 101,128,128,128 left 101,425:top 101,100
' DIGIT1 (102 à 125) gosub affichage_digit_XYZ ' BUTTn (131 à 157) gosub affichage_bttn_XYZ ' 3d_cylinder 300,1,1,1 ' on_timer 1,Tm1:on_timer 2,Tm2:on_timer 3,Tm3 while not(la_fin=1) ' end_while
END ' Affichage Tm1:
var1=mod(360+o3d_x_rotate(300),360) caption 103,int(var1/100) caption 104,mod(int(var1/10),10) caption 105,mod(mod(var1,100),10) 3d_x_rotate 300,o3d_x_rotate(300)+vit1 return Tm2:
var2=mod(360+o3d_y_rotate(300),360) caption 113,int(var2/100) caption 114,mod(int(var2/10),10) caption 115,mod(mod(var2,100),10) 3d_y_rotate 300,o3d_y_rotate(300)+vit2 return Tm3:
var3=mod(360+o3d_z_rotate(300),360) caption 123,int(var3/100) caption 124,mod(int(var3/10),10) caption 125,mod(mod(var3,100),10) 3d_z_rotate 300,o3d_z_rotate(300)+vit3 return
affichage_digit_XYZ: alpha 102:font_size 102,14:caption 102,"X_Rotation" left 102,4:top 102,4:color 102,128,128,128 digit1 103:top 103,4:left 103,100:height 103,24:width 103,16 digit1 104:top 104,4:left 104,116:height 104,24:width 104,16 digit1 105:top 105,4:left 105,133:height 105,24:width 105,16 alpha 112:font_size 112,14:caption 112,"Y_Rotation" left 112,4:top 112,30:color 112,128,128,128 digit1 113:top 113,30:left 113,100:height 113,24:width 113,16 digit1 114:top 114,30:left 114,116:height 114,24:width 114,16 digit1 115:top 115,30:left 115,133:height 115,24:width 115,16 alpha 122:font_size 122,14:caption 122,"Z_Rotation" left 122,4:top 122,56:color 122,128,128,128 digit1 123:top 123,56:left 123,100:height 123,24:width 123,16 digit1 124:top 124,56:left 124,116:height 124,24:width 124,16 digit1 125:top 125,56:left 125,133:height 125,24:width 125,16 return
affichage_bttn_XYZ: button 131:left 131,180:top 131,4:width 131,30:font_size 131,14:caption 131,"-" on_click 131,XRotG- button 132:left 132,220:top 132,4:width 132,50:font_size 132,14:caption 132,"--" on_click 132,XRot2G- button 133:left 133,280:top 133,4:width 133,50:font_size 133,14:caption 133,"++" on_click 133,XRot2G+ button 134:left 134,340:top 134,4:width 134,30:font_size 134,14:caption 134,"+" on_click 134,XRotG+ button 135:left 135,400:top 135,4:width 135,30:font_size 135,14:caption 135,"=" alpha 136: color 136,242,242,178:left 136,398:top 136,0:width 136,34:height 136,32 on_click 135,EgalX button 137:left 137,440:top 137,4:width 137,30:font_size 137,14:caption 137,"0" alpha 138: color 138,233,22,50:left 138,438:top 138,0:width 138,34:height 138,32 on_click 137,ZeroX
button 141:left 141,180:top 141,30:width 141,30:font_size 141,14:caption 141,"-" on_click 141,YRotG- button 142:left 142,220:top 142,30:width 142,50:font_size 142,14:caption 142,"--" on_click 142,YRot2G- button 143:left 143,280:top 143,30:width 143,50:font_size 143,14:caption 143,"++" on_click 143,YRot2G+ button 144:left 144,340:top 144,30:width 144,30:font_size 144,14:caption 144,"+" on_click 144,YRotG+ button 145:left 145,400:top 145,30:width 145,30:font_size 145,14:caption 145,"=" alpha 146: color 146,242,242,178:left 146,398:top 146,26:width 146,34:height 146,32 on_click 145,EgalY button 147:left 147,440:top 147,30:width 147,30:font_size 147,14:caption 147,"0" alpha 148: color 148,255,0,0:left 148,438:top 148,26:width 148,34:height 148,32 on_click 147,ZeroY
button 151:left 151,180:top 151,56:width 151,30:font_size 151,14:caption 151,"-" on_click 151,ZRotG- button 152:left 152,220:top 152,56:width 152,50:font_size 152,14:caption 152,"--" on_click 152,ZRot2G- button 153:left 153,280:top 153,56:width 153,50:font_size 153,14:caption 153,"++" on_click 153,ZRot2G+ button 154:left 154,340:top 154,56:width 154,30:font_size 154,14:caption 154,"+" on_click 154,ZRotG+ button 155:left 155,400:top 155,56:width 155,30:font_size 155,14:caption 155,"=" alpha 156: color 156,242,242,178:left 156,398:top 156,52:width 156,34:height 156,32 on_click 155,EgalZ button 157:left 157,440:top 157,56:width 157,30:font_size 157,14:caption 157,"0" alpha 158: color 158,255,0,0:left 158,438:top 158,52:width 158,34:height 158,32 on_click 157,ZeroZ return
' Routines d'incrément des 3 vitesses de rotation
XRotG-: timer_off 1:vit1=vit1-1:timer_on 1 return XRot2G-: timer_off 1:vit1=vit1-15:timer_on 1 return XRotG+: timer_off 1:vit1=vit1+1:timer_on 1 return XRot2G+: timer_off 1:vit1=vit1+15:timer_on 1 return EgalX: timer_off 1 deb1: gosub Tm1 if vit1<0 then vit1=vit1+1 if vit1>0 then vit1=vit1-1 if not(vit1=0) then wait 150:goto deb1 timer_on 1 return ZeroX: timer_off 1 debut1: if o3d_x_rotate(300)<0 then 3d_x_rotate 300,o3d_x_rotate(300)+1 if o3d_x_rotate(300)>0 then 3d_x_rotate 300,o3d_x_rotate(300)-1 caption 103,int(var1/100) caption 104,mod(int(var1/10),10) caption 105,mod(mod(var1,100),10) if not(o3d_x_rotate(300)=0) then wait 150:goto debut1 vit1=0 timer_on 1 return
YRotG-: timer_off 2:vit2=vit2-1:timer_on 2 return YRot2G-: timer_off 2:vit2=vit2-15:timer_on 2 return YRotG+: timer_off 2:vit2=vit2+1:timer_on 2 return YRot2G+: timer_off 2:vit2=vit2+15:timer_on 2 return EgalY: timer_off 2 deb2: gosub Tm2 if vit2<0 then vit2=vit2+1 if vit2>0 then vit2=vit2-1 if not(vit2=0) then wait 150:goto deb2 timer_on 2 return ZeroY: timer_off 2 debut2: if o3d_Y_rotate(300)<0 then 3d_Y_rotate 300,o3d_Y_rotate(300)+1 if o3d_Y_rotate(300)>0 then 3d_Y_rotate 300,o3d_Y_rotate(300)-1 caption 113,int(var2/100) caption 114,mod(int(var2/10),10) caption 115,mod(mod(var2,100),10) if not(o3d_Y_rotate(300)=0) then wait 150:goto debut2 vit2=0 timer_on 2 return
ZRotG-: timer_off 3:vit3=vit3-1:timer_on 3 return ZRot2G-: timer_off 3:vit3=vit3-15:timer_on 3 return ZRotG+: timer_off 3:vit3=vit3+1:timer_on 3 return ZRot2G+: timer_off 3:vit3=vit3+15:timer_on 3 return EgalZ: timer_off 3 deb3: gosub Tm3 if vit2<0 then vit3=vit3+1 if vit2>0 then vit3=vit3-1 if not(vit3=0) then wait 150:goto deb3 timer_on 3 return ZeroZ: timer_off 3 debut3: if o3d_Z_rotate(300)<0 then 3d_Z_rotate 300,o3d_Z_rotate(300)+1 if o3d_Z_rotate(300)>0 then 3d_Z_rotate 300,o3d_Z_rotate(300)-1 caption 123,int(var3/100) caption 124,mod(int(var3/10),10) caption 125,mod(mod(var3,100),10) if not(o3d_Z_rotate(300)=0) then wait 150:goto debut3 vit3=0 timer_on 3 return
' The_END: la_fin=1 return
Toute suggestion sera la bienvenue (même concernant la distance entre les yeux et l'écran ) | |
|