mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Comportement des capteurs de fin de course
This commit is contained in:
parent
fae3d690b9
commit
f42d194a74
Binary file not shown.
@ -39,15 +39,6 @@ def init(cont):
|
||||
twin.manip_init() # Manipulation du modèle 3D
|
||||
twin.cmd_init() # Commandes
|
||||
|
||||
# Mémorisation de la position et orientation des composants du système
|
||||
# FIXME : animation par keyframe
|
||||
# scene.objects['Portail']['init_lx']=scene.objects['Portail'].worldPosition.x
|
||||
# scene.objects['Portail']['init_ly']=scene.objects['Portail'].worldPosition.y
|
||||
# scene.objects['Portail']['init_lz']=scene.objects['Portail'].worldPosition.z
|
||||
# scene.objects['Engrenage']['init_rx']=scene.objects['Engrenage'].worldOrientation.to_euler().x
|
||||
# scene.objects['Engrenage']['init_ry']=scene.objects['Engrenage'].worldOrientation.to_euler().y
|
||||
# scene.objects['Engrenage']['init_rz']=scene.objects['Engrenage'].worldOrientation.to_euler().z
|
||||
|
||||
system_init() # Initialisation du système
|
||||
|
||||
###############################################################################
|
||||
@ -83,7 +74,7 @@ def voy_auto (cont):
|
||||
def mot (cont):
|
||||
if scene.objects['System']['run']:
|
||||
obj = cont.owner
|
||||
print (obj['frame_up'], obj['frame_down'])
|
||||
# print (obj['frame_up'], obj['frame_down'])
|
||||
layer = 0
|
||||
# bge.render.drawLine([0,0,0],[1,1,1], (0.8, 0.8, 0.8, 1)) # Redraw pour l'éclairage de la scène
|
||||
|
||||
@ -92,9 +83,9 @@ def mot (cont):
|
||||
if obj['frame_down']<105: # Volet pas cassé
|
||||
if obj['frame_up'] <0: # Réinit entre 0 et -4
|
||||
obj['frame_up']=0
|
||||
if obj['frame_up']<104 : # Cycle normal de 0 à 100 (buté en 105)
|
||||
if obj['frame_up']<110 : # Cycle normal de 0 à 100 (butée en 110)
|
||||
start = obj['frame_up']
|
||||
end = 105
|
||||
end = 111
|
||||
priority = 1
|
||||
blendin = 1.0
|
||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
@ -118,28 +109,39 @@ def mot (cont):
|
||||
scene.objects['Lame volet 13'].playAction('Lame volet 13-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
||||
else: # Tourner sans fin
|
||||
scene.objects['Axe enrouleur'].stopAction(layer)
|
||||
scene.objects['Axe fdc'].stopAction(layer)
|
||||
scene.objects['Lame volet 1'].stopAction(layer)
|
||||
scene.objects['Lame volet 2'].stopAction(layer)
|
||||
scene.objects['Lame volet 3'].stopAction(layer)
|
||||
scene.objects['Lame volet 4'].stopAction(layer)
|
||||
scene.objects['Lame volet 5'].stopAction(layer)
|
||||
scene.objects['Lame volet 6'].stopAction(layer)
|
||||
scene.objects['Lame volet 7'].stopAction(layer)
|
||||
scene.objects['Lame volet 8'].stopAction(layer)
|
||||
scene.objects['Lame volet 9'].stopAction(layer)
|
||||
scene.objects['Lame volet 10'].stopAction(layer)
|
||||
scene.objects['Lame volet 11'].stopAction(layer)
|
||||
scene.objects['Lame volet 12'].stopAction(layer)
|
||||
scene.objects['Lame volet 13'].stopAction(layer)
|
||||
vitesse = 0.015
|
||||
# vitesse = 0.015
|
||||
vitesse = 0.03
|
||||
pas_axe_enrouleur = 0.5
|
||||
pas_axe_fdc = 0.5/3
|
||||
scene.objects['Axe enrouleur'].applyRotation((pas_axe_enrouleur*vitesse, 0, 0), True)
|
||||
# scene.objects['Axe enrouleur'].applyRotation((pas_axe_enrouleur*vitesse, 0, 0), True)
|
||||
scene.objects['Axe fdc'].stopAction(layer)
|
||||
scene.objects['Axe fdc'].applyRotation((-pas_axe_fdc*vitesse, 0, 0), True)
|
||||
# scene.objects['Volet'].applyRotation((pas_axe_enrouleur*vitesse, 0, 0), True)
|
||||
obj['frame_up'] +=1
|
||||
if obj['frame_up'] ==170: # Réinit
|
||||
obj['frame_up']=110
|
||||
start = obj['frame_up']
|
||||
end = 171
|
||||
priority = 1
|
||||
blendin = 1.0
|
||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
||||
layerWeight = 0.0
|
||||
ipoFlags = 0
|
||||
speed = 0.4
|
||||
scene.objects['Axe enrouleur'].playAction('Axe enrouleur-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
# scene.objects['Axe fdc'].playAction('Axe fdc-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 1'].playAction('Lame volet 1-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 2'].playAction('Lame volet 2-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 3'].playAction('Lame volet 3-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 4'].playAction('Lame volet 4-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 5'].playAction('Lame volet 5-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 6'].playAction('Lame volet 6-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 7'].playAction('Lame volet 7-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 8'].playAction('Lame volet 8-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 9'].playAction('Lame volet 9-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 10'].playAction('Lame volet 10-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 11'].playAction('Lame volet 11-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 12'].playAction('Lame volet 12-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 13'].playAction('Lame volet 13-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
||||
obj['frame_down']= 100-obj['frame_up']
|
||||
|
||||
# Descendre
|
||||
@ -147,9 +149,9 @@ def mot (cont):
|
||||
if obj['frame_up']<105: # Volet pas cassé
|
||||
if obj['frame_down'] <0: # Réinit entre 0 et -4
|
||||
obj['frame_down']=0
|
||||
if obj['frame_down']<134 : # Cycle normal de 0 à 100 (buté en 135)
|
||||
if obj['frame_down']<135 : # Cycle normal de 0 à 100 (butée en 135)
|
||||
start = obj['frame_down']
|
||||
end = 135
|
||||
end = 136
|
||||
layer = 0
|
||||
priority = 1
|
||||
blendin = 1.0
|
||||
@ -189,7 +191,8 @@ def mot (cont):
|
||||
scene.objects['Lame volet 11'].stopAction(layer)
|
||||
scene.objects['Lame volet 12'].stopAction(layer)
|
||||
scene.objects['Lame volet 13'].stopAction(layer)
|
||||
vitesse = 0.015
|
||||
vitesse = 0.03
|
||||
# vitesse = 0.015
|
||||
pas_axe_enrouleur = 0.5
|
||||
pas_axe_fdc = 0.5/3
|
||||
pas_volet = 10
|
||||
@ -245,27 +248,11 @@ def fdc_h (cont):
|
||||
obj = cont.owner
|
||||
|
||||
# Etat capteur en fonction du volet
|
||||
if scene.objects['Moteur']['frame_up'] >= 95 and scene.objects['Moteur']['frame_up'] <= 105 and obj['activated'] == False :
|
||||
scene.objects['Axe fdc']['rx']= scene.objects['Axe fdc'].localOrientation.to_euler().x *(180/math.pi)
|
||||
if scene.objects['Axe fdc']['rx'] >= -175 and scene.objects['Axe fdc']['rx'] <= -155 and obj['activated'] == False :
|
||||
obj['activated'] = True
|
||||
if (scene.objects['Moteur']['frame_up'] < 95 or scene.objects['Moteur']['frame_up'] > 105) and obj['activated'] == True :
|
||||
if scene.objects['Axe fdc']['rx'] < -175 or scene.objects['Axe fdc']['rx'] > -155 and obj['activated'] == True :
|
||||
obj['activated'] = False
|
||||
# if scene.objects['Moteur']['frame_up'] >= 95 and obj['activated'] == False :
|
||||
# obj['activated'] = True
|
||||
# if scene.objects['Moteur']['frame_up'] < 95 and obj['activated'] == True :
|
||||
# obj['activated'] = False
|
||||
if scene.objects['Moteur']['frame_up']>105:
|
||||
frame = scene.objects['Moteur']['frame_up'] % 2500
|
||||
# print ("Frame modulo :", frame)
|
||||
if frame >= 0 and frame <= 100 and obj['activated'] == False :
|
||||
obj['activated'] = True
|
||||
if frame > 100 and obj['activated'] == True :
|
||||
obj['activated'] = False
|
||||
|
||||
# if frame >= 2295 and frame <= 2425 and obj['activated'] == False :
|
||||
# obj['activated'] = True
|
||||
# if frame < 2295 and frame > 2425 and obj['activated'] == True :
|
||||
# obj['activated'] = False
|
||||
|
||||
|
||||
# Forçage (click)
|
||||
if obj['click'] == True:
|
||||
@ -291,16 +278,9 @@ def fdc_b (cont):
|
||||
obj = cont.owner
|
||||
|
||||
# Etat capteur en fonction du volet
|
||||
if scene.objects['Moteur']['frame_down'] >= 95 and scene.objects['Moteur']['frame_down'] <= 105 and obj['activated'] == False :
|
||||
if scene.objects['Axe fdc']['rx'] >= -10 and scene.objects['Axe fdc']['rx'] <= 10 and obj['activated'] == False :
|
||||
obj['activated'] = True
|
||||
if (scene.objects['Moteur']['frame_down'] < 95 or scene.objects['Moteur']['frame_down'] > 105) and obj['activated'] == True :
|
||||
obj['activated'] = False
|
||||
if scene.objects['Moteur']['frame_down']>105:
|
||||
frame = scene.objects['Moteur']['frame_down'] % 2500
|
||||
# print ("Frame modulo :", frame)
|
||||
if frame >= 2295 and frame <= 2425 and obj['activated'] == False :
|
||||
obj['activated'] = True
|
||||
if frame < 2295 and frame > 2425 and obj['activated'] == True :
|
||||
if scene.objects['Axe fdc']['rx'] < -10 or scene.objects['Axe fdc']['rx'] > 10 and obj['activated'] == True :
|
||||
obj['activated'] = False
|
||||
|
||||
# Forçage (click)
|
||||
@ -405,7 +385,7 @@ def system_reset ():
|
||||
scene.objects['Lame volet 11'].playAction('Lame volet 11-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 12'].playAction('Lame volet 12-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
scene.objects['Lame volet 13'].playAction('Lame volet 13-Up', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||
print ("reset")
|
||||
# print ("reset")
|
||||
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
||||
obj['frame_down']= 100-obj['frame_up']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user