mirror of
https://forge.apps.education.fr/blender-edutech/lecteur-3d-cinematique.git
synced 2024-01-27 09:43:12 +01:00
Migration de la pince schrader et finalisation du tube de colle
This commit is contained in:
parent
960c89583c
commit
645a2bb0f3
Binary file not shown.
32
cine.py
32
cine.py
@ -90,21 +90,9 @@ def keyboard(cont):
|
|||||||
|
|
||||||
# Touche Home -> Reset de la vue
|
# Touche Home -> Reset de la vue
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.HOMEKEY].queue:
|
if JUST_ACTIVATED in keyboard.inputs[bge.events.HOMEKEY].queue:
|
||||||
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['init_lx']
|
manip_reset()
|
||||||
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['init_ly']
|
print ("hihhi")
|
||||||
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz']
|
|
||||||
applyRotationTo(scene.objects['Mecanism'], 0, 0, 0)
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].setVisible(True,False)
|
|
||||||
if scene.objects['Mecanism']['exploded'] ==True:
|
|
||||||
scene.objects['Mecanism']['exploded'] = False
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].worldPosition.x =scene.objects[objet]['init_lx']
|
|
||||||
scene.objects[objet].worldPosition.y = scene.objects[objet]['init_ly']
|
|
||||||
scene.objects[objet].worldPosition.z = scene.objects[objet]['init_lz']
|
|
||||||
if scene.objects['Mecanism']['anim'] == False: # Play d'une frame
|
|
||||||
anim_play1frame()
|
|
||||||
|
|
||||||
# Touche Space -> Play et Pause
|
# Touche Space -> Play et Pause
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.SPACEKEY].queue:
|
if JUST_ACTIVATED in keyboard.inputs[bge.events.SPACEKEY].queue:
|
||||||
if scene.objects['Mecanism']['anim'] == True:
|
if scene.objects['Mecanism']['anim'] == True:
|
||||||
@ -426,6 +414,8 @@ def manip_reset():
|
|||||||
for objet in scene.objects['Mecanism']['objects'] :
|
for objet in scene.objects['Mecanism']['objects'] :
|
||||||
scene.objects[objet].setVisible(True,False)
|
scene.objects[objet].setVisible(True,False)
|
||||||
scene.objects[objet].restorePhysics()
|
scene.objects[objet].restorePhysics()
|
||||||
|
if objet+"_Lines.GP" in scene.objects:
|
||||||
|
scene.objects[objet+"_Lines.GP"].setVisible(True,False)
|
||||||
if scene.objects['Mecanism']['expld'] ==True:
|
if scene.objects['Mecanism']['expld'] ==True:
|
||||||
scene.objects['Mecanism']['expld'] = False
|
scene.objects['Mecanism']['expld'] = False
|
||||||
for objet in scene.objects['Mecanism']['objects'] :
|
for objet in scene.objects['Mecanism']['objects'] :
|
||||||
@ -655,6 +645,8 @@ def color_object(cont):
|
|||||||
if color_select == 8: # Couleur transparente -> disparition
|
if color_select == 8: # Couleur transparente -> disparition
|
||||||
hitObject.setVisible(False,False)
|
hitObject.setVisible(False,False)
|
||||||
hitObject.suspendPhysics (True)
|
hitObject.suspendPhysics (True)
|
||||||
|
if hitObject.name+"_Lines.GP" in scene.objects:
|
||||||
|
scene.objects[hitObject.name+"_Lines.GP"].setVisible(False,False)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Objets
|
# Objets
|
||||||
@ -712,14 +704,14 @@ def object_hl(cont):
|
|||||||
# Nomenclature
|
# Nomenclature
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Click sur la nomemclature
|
# Clic sur la nomenclature
|
||||||
def nom_click(cont):
|
def nom_click(cont):
|
||||||
name=cont.owner.name[:-7]
|
name=cont.owner.name[:-7]
|
||||||
obj = scene.objects[name]
|
obj = scene.objects[name]
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Mecanism']['manip_mode']==0:
|
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Mecanism']['manip_mode']==0:
|
||||||
color_select = scene.objects['Colors']['color_current']
|
color_select = scene.objects['Colors']['color_current']
|
||||||
|
|
||||||
# Colorisation de la pièce par la nomenclaturep
|
# Colorisation de la pièce par la nomenclature
|
||||||
if color_select != 0 and color_select != 8:
|
if color_select != 0 and color_select != 8:
|
||||||
colors = scene.objects['Mecanism']['colors']
|
colors = scene.objects['Mecanism']['colors']
|
||||||
obj.color = colors[color_select-1][1]
|
obj.color = colors[color_select-1][1]
|
||||||
@ -728,15 +720,21 @@ def nom_click(cont):
|
|||||||
if scene.objects[obj['Object']].visible==False:
|
if scene.objects[obj['Object']].visible==False:
|
||||||
scene.objects[obj['Object']].setVisible(True,False)
|
scene.objects[obj['Object']].setVisible(True,False)
|
||||||
scene.objects[obj['Object']].restorePhysics()
|
scene.objects[obj['Object']].restorePhysics()
|
||||||
|
if obj['Object']+"_Lines.GP" in scene.objects:
|
||||||
|
scene.objects[obj['Object']+"_Lines.GP"].setVisible(True,False)
|
||||||
|
|
||||||
# Couleur transparente -> disparition / apparition
|
# Couleur transparente -> disparition / apparition
|
||||||
if color_select == 8:
|
if color_select == 8:
|
||||||
if scene.objects[obj['Object']].visible==True:
|
if scene.objects[obj['Object']].visible==True:
|
||||||
scene.objects[obj['Object']].setVisible(False,False)
|
scene.objects[obj['Object']].setVisible(False,False)
|
||||||
scene.objects[obj['Object']].suspendPhysics (True)
|
scene.objects[obj['Object']].suspendPhysics (True)
|
||||||
|
if obj['Object']+"_Lines.GP" in scene.objects:
|
||||||
|
scene.objects[obj['Object']+"_Lines.GP"].setVisible(False,False)
|
||||||
else:
|
else:
|
||||||
scene.objects[obj['Object']].setVisible(True,False)
|
scene.objects[obj['Object']].setVisible(True,False)
|
||||||
scene.objects[obj['Object']].restorePhysics()
|
scene.objects[obj['Object']].restorePhysics()
|
||||||
|
if obj['Object']+"_Lines.GP" in scene.objects:
|
||||||
|
scene.objects[obj['Object']+"_Lines.GP"].setVisible(True,False)
|
||||||
|
|
||||||
# Highlight de la nomenclature
|
# Highlight de la nomenclature
|
||||||
def nom_hl(cont):
|
def nom_hl(cont):
|
||||||
|
BIN
pince_schrader/pince_schrader-07.blend
Normal file
BIN
pince_schrader/pince_schrader-07.blend
Normal file
Binary file not shown.
@ -1,17 +1,17 @@
|
|||||||
import bge # Bibliothèque Blender Game Engine (BGE)
|
import bge # Bibliothèque Blender Game Engine (BGE)
|
||||||
import webbrowser
|
|
||||||
import math
|
import math
|
||||||
|
import cine # Bibliothèque du player 3d d'analyse de cinématique
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# serrbio.py
|
# batoncolle.py
|
||||||
# @title: Commandes pour le player 3D de la pince schrader
|
# @title: Player 3D cinématique du baton de colle
|
||||||
# @project: Blender-EduTech
|
# @project: Blender-EduTech
|
||||||
# @lang: fr
|
# @lang: fr
|
||||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||||
# @copyright: Copyright (C) 2020-2022 Philippe Roy
|
# @copyright: Copyright (C) 2020-2022 Philippe Roy
|
||||||
# @license: GNU GPL
|
# @license: GNU GPL
|
||||||
#
|
#
|
||||||
# Commandes déclenchées par UPBGE pour le modèle de la pince schrader
|
# Commandes déclenchées par UPBGE pour le modèle du baton de colle
|
||||||
#
|
#
|
||||||
# Ce player 3D est un environnement léger et spécifique pour la colorisation des solides d'un mécanisme en mouvement.
|
# Ce player 3D est un environnement léger et spécifique pour la colorisation des solides d'un mécanisme en mouvement.
|
||||||
# Il sert principalement pour l'apprentissage de la détection des classes d'équivalence d'un mécanisme afin de pouvoir faire sa modélisation cinématique.
|
# Il sert principalement pour l'apprentissage de la détection des classes d'équivalence d'un mécanisme afin de pouvoir faire sa modélisation cinématique.
|
||||||
@ -22,17 +22,48 @@ import math
|
|||||||
scene = bge.logic.getCurrentScene()
|
scene = bge.logic.getCurrentScene()
|
||||||
# print("Objets de la scene : ", scene.objects)
|
# print("Objets de la scene : ", scene.objects)
|
||||||
|
|
||||||
# Objets 3D
|
# Mécanisme (objets 3D)
|
||||||
|
|
||||||
objets=['Axe biellette inf', 'Axe biellette sup', 'Axe doigt inf', 'Axe doigt sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Bouchon', 'Circlips 1', 'Circlips 2',
|
objects=['Corps', 'Piston', 'Doigt sup', 'Doigt inf', 'Biellette sup', 'Biellette inf', 'Bouchon','Axe piston', 'Axe doigt sup', 'Axe doigt inf',
|
||||||
'Circlips 3', 'Circlips 4', 'Circlips 5', 'Corps', 'Doigt inf', 'Doigt sup', 'Joint bouchon', 'Joint piston', 'Piston']
|
'Axe biellette sup', 'Axe biellette inf', 'Joint piston', 'Joint bouchon', 'Circlips 1', 'Circlips 2', 'Circlips 3', 'Circlips 4', 'Circlips 5']
|
||||||
objets_anim=['Axe biellette inf', 'Axe biellette sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Doigt inf', 'Doigt sup', 'Joint piston', 'Piston']
|
|
||||||
objets_couleur=['MagentaF', 'MagentaF', 'VioletF', 'VioletF', 'VertF', 'Couleur5', 'Couleur5', 'TurquoiseF', 'Gris', 'Gris', 'Gris', 'Gris', 'Gris',
|
objects_anim=['Axe biellette inf', 'Axe biellette sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Doigt inf', 'Doigt sup', 'Joint piston', 'Piston']
|
||||||
'Couleur1', 'Couleur7', 'Couleur7', 'Couleur2', 'Couleur6', 'Vert']
|
|
||||||
|
# objects=['Axe biellette inf', 'Axe biellette sup', 'Axe doigt inf', 'Axe doigt sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Bouchon', 'Circlips 1', 'Circlips 2',
|
||||||
|
# 'Circlips 3', 'Circlips 4', 'Circlips 5', 'Corps', 'Doigt inf', 'Doigt sup', 'Joint bouchon', 'Joint piston', 'Piston']
|
||||||
|
# objects_anim=['Axe biellette inf', 'Axe biellette sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Doigt inf', 'Doigt sup', 'Joint piston', 'Piston']
|
||||||
|
# objets_couleur=['MagentaF', 'MagentaF', 'VioletF', 'VioletF', 'VertF', 'Couleur5', 'Couleur5', 'TurquoiseF', 'Gris', 'Gris', 'Gris', 'Gris', 'Gris',
|
||||||
|
# 'Couleur1', 'Couleur7', 'Couleur7', 'Couleur2', 'Couleur6', 'Vert']
|
||||||
|
|
||||||
|
objects_dict={'Corps' : [1, '1 : Corps', 'Couleur1', []],
|
||||||
|
'Piston' : [2, '2 : Piston', 'Vert', []],
|
||||||
|
'Doigt sup' : [3, '3 : Doigt sup.', 'Couleur7', []],
|
||||||
|
'Doigt inf' : [4, '4 : Doigt inf.', 'Couleur7', []],
|
||||||
|
'Biellette sup' : [5, '5 : Biellette sup.', 'Couleur5', []],
|
||||||
|
'Biellette inf' : [6, '6 : Biellette inf.', 'Couleur5', []],
|
||||||
|
'Bouchon' : [7, '7 : Bouchon', 'TurquoiseF', []],
|
||||||
|
'Axe piston' : [8, '8 : Axe piston', 'VertF', []],
|
||||||
|
'Axe doigt sup' : [9, '9 : Axe doigt sup.', 'VioletF', []],
|
||||||
|
'Axe doigt inf': [10, '10 : Axe doigt inf.', 'VioletF', []],
|
||||||
|
'Axe biellette sup': [11, '11 : Axe biellette sup.', 'MagentaF', []],
|
||||||
|
'Axe biellette inf': [12, '12 : Axe biellette inf.', 'MagentaF', []],
|
||||||
|
'Joint piston': [13, '13 : Joint piston', 'Couleur6', []],
|
||||||
|
'Joint bouchon': [14, '14 : Joint bouchon', 'Couleur2', []],
|
||||||
|
'Circlips 1' : [15, '15 : Circlips 1', 'Gris', []],
|
||||||
|
'Circlips 2': [16, '16 : Circlips 2', 'Gris', []],
|
||||||
|
'Circlips 3': [17, '17 : Circlips 3', 'Gris', []],
|
||||||
|
'Circlips 4' : [18, '18 : Circlips 4', 'Gris', []],
|
||||||
|
'Circlips 5': [19, '19 : Circlips 5', 'Gris', []]}
|
||||||
|
|
||||||
|
# objects=['Axe biellette inf', 'Axe biellette sup', 'Axe doigt inf', 'Axe doigt sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Bouchon', 'Circlips 1', 'Circlips 2',
|
||||||
|
# 'Circlips 3', 'Circlips 4', 'Circlips 5', 'Corps', 'Doigt inf', 'Doigt sup', 'Joint bouchon', 'Joint piston', 'Piston']
|
||||||
|
# objects_anim=['Axe biellette inf', 'Axe biellette sup', 'Axe piston', 'Biellette inf', 'Biellette sup', 'Doigt inf', 'Doigt sup', 'Joint piston', 'Piston']
|
||||||
|
# objets_couleur=['MagentaF', 'MagentaF', 'VioletF', 'VioletF', 'VertF', 'Couleur5', 'Couleur5', 'TurquoiseF', 'Gris', 'Gris', 'Gris', 'Gris', 'Gris',
|
||||||
|
# 'Couleur1', 'Couleur7', 'Couleur7', 'Couleur2', 'Couleur6', 'Vert']
|
||||||
|
|
||||||
# Couleurs
|
# Couleurs
|
||||||
|
|
||||||
couleurs=[['Couleur1', [0.202, 0.114, 0.512, 1]],
|
colors=[['Couleur1', [0.202, 0.114, 0.512, 1]],
|
||||||
['Couleur2', [0.051, 0.270, 0.279, 1]],
|
['Couleur2', [0.051, 0.270, 0.279, 1]],
|
||||||
['Couleur3', [0.799, 0.031, 0.038, 1]],
|
['Couleur3', [0.799, 0.031, 0.038, 1]],
|
||||||
['Couleur4', [0.799, 0.130, 0.063, 1]],
|
['Couleur4', [0.799, 0.130, 0.063, 1]],
|
||||||
@ -41,7 +72,7 @@ couleurs=[['Couleur1', [0.202, 0.114, 0.512, 1]],
|
|||||||
['Couleur7', [0.800, 0.005, 0.315, 1]],
|
['Couleur7', [0.800, 0.005, 0.315, 1]],
|
||||||
['Couleur8', [0.75,0.75, 0.75, 0]]]
|
['Couleur8', [0.75,0.75, 0.75, 0]]]
|
||||||
|
|
||||||
couleurs_dict={'Couleur1' : [0.202, 0.114, 0.512, 1],
|
colors_dict={'Couleur1' : [0.202, 0.114, 0.512, 1],
|
||||||
'Couleur2' : [0.051, 0.270, 0.279, 1],
|
'Couleur2' : [0.051, 0.270, 0.279, 1],
|
||||||
'Couleur3' : [0.799, 0.031, 0.038, 1],
|
'Couleur3' : [0.799, 0.031, 0.038, 1],
|
||||||
'Couleur4' : [0.799, 0.130, 0.063, 1],
|
'Couleur4' : [0.799, 0.130, 0.063, 1],
|
||||||
@ -56,611 +87,18 @@ couleurs_dict={'Couleur1' : [0.202, 0.114, 0.512, 1],
|
|||||||
'Gris' : [0.258,0.275, 0.319, 1],
|
'Gris' : [0.258,0.275, 0.319, 1],
|
||||||
'VioletF' : [0.100,0.058, 0.254, 1]}
|
'VioletF' : [0.100,0.058, 0.254, 1]}
|
||||||
|
|
||||||
couleur_cmd = [0.8, 0.8, 0.8, 1] # blanc
|
###############################################################################
|
||||||
couleur_cmd_hl = [0.8, 0.619, 0.021, 1] # jaune
|
# Mécanisme
|
||||||
couleur_lien = [0.024, 0.006, 0.8, 1] # bleu
|
|
||||||
couleur_lien_hl = [0.8, 0.005, 0.315, 1] # bleu
|
|
||||||
|
|
||||||
# Constantes
|
|
||||||
|
|
||||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
|
||||||
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
|
|
||||||
ACTIVATE = bge.logic.KX_INPUT_ACTIVE
|
|
||||||
# JUST_DEACTIVATED = bge.logic.KX_SENSOR_JUST_DEACTIVATED
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Gestion du clavier
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Mode : Pan(1) avec Shift, Zoom (2) avec Ctrl, Orbit (0), Eclaté avec Shift
|
# Initialisation
|
||||||
def mode(cont):
|
def init(cont):
|
||||||
obj = cont.owner
|
scene.objects['Mecanism']['objects'] = objects
|
||||||
keyboard = bge.logic.keyboard
|
scene.objects['Mecanism']['objects_anim'] = objects_anim
|
||||||
|
scene.objects['Mecanism']['objects_dict'] = objects_dict
|
||||||
# Shift -> mode 1 : Pan (clic milieu) ou Eclaté (clic gauche)
|
scene.objects['Mecanism']['colors'] = colors
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.LEFTSHIFTKEY].queue:
|
scene.objects['Mecanism']['colors_dict'] = colors_dict
|
||||||
obj['manip_mode']=1
|
cine.manip_init() # Manipulation du modèle 3D
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.RIGHTSHIFTKEY].queue:
|
cine.objects_init() # Mécanisme
|
||||||
obj['manip_mode']=1
|
cine.cmd_init() # Commandes
|
||||||
|
cine.anim_init() # Animation
|
||||||
# Ctrl -> mode 2 : Zoom (clic milieu)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.LEFTCTRLKEY].queue:
|
|
||||||
obj['manip_mode']=2
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.RIGHTCTRLKEY].queue:
|
|
||||||
obj['manip_mode']=2
|
|
||||||
|
|
||||||
# Pas de modificateur -> mode 0 : Orbit (clic milieu)
|
|
||||||
if JUST_RELEASED in keyboard.inputs[bge.events.LEFTSHIFTKEY].queue:
|
|
||||||
obj['manip_mode']=0
|
|
||||||
if JUST_RELEASED in keyboard.inputs[bge.events.RIGHTSHIFTKEY].queue:
|
|
||||||
obj['manip_mode']=0
|
|
||||||
if JUST_RELEASED in keyboard.inputs[bge.events.LEFTCTRLKEY].queue:
|
|
||||||
obj['manip_mode']=0
|
|
||||||
if JUST_RELEASED in keyboard.inputs[bge.events.RIGHTCTRLKEY].queue:
|
|
||||||
obj['manip_mode']=0
|
|
||||||
|
|
||||||
# Touche Home -> Reset de la vue
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.HOMEKEY].queue:
|
|
||||||
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['init_lx']
|
|
||||||
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['init_ly']
|
|
||||||
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz']
|
|
||||||
applyRotationTo(scene.objects['Mecanisme'], 0, 0, 0)
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].setVisible(True,False)
|
|
||||||
scene.objects[objet+"_Lines.GP"].setVisible(True,False)
|
|
||||||
if scene.objects['Mecanisme']['eclate'] ==True:
|
|
||||||
scene.objects['Mecanisme']['eclate'] = False
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].worldPosition.x =scene.objects[objet]['init_lx']
|
|
||||||
scene.objects[objet].worldPosition.y = scene.objects[objet]['init_ly']
|
|
||||||
scene.objects[objet].worldPosition.z = scene.objects[objet]['init_lz']
|
|
||||||
if scene.objects['Mecanisme']['anim'] == False: # Play d'une frame
|
|
||||||
anim_play1frame()
|
|
||||||
|
|
||||||
# Touche Space -> Play et Pause
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.SPACEKEY].queue:
|
|
||||||
if scene.objects['Mecanisme']['anim'] == True:
|
|
||||||
anim_pause()
|
|
||||||
scene.objects['Pause'].setVisible(False,False)
|
|
||||||
scene.objects['Play'].setVisible(True,False)
|
|
||||||
else:
|
|
||||||
anim_play()
|
|
||||||
scene.objects['Play'].setVisible(False,False)
|
|
||||||
scene.objects['Pause'].setVisible(True,False)
|
|
||||||
|
|
||||||
# Touche H -> Cacher l'objet
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.HKEY].queue:
|
|
||||||
couleur_choix_num(8)
|
|
||||||
|
|
||||||
# Touche de 1 à 8 -> Couleur de 1 à 8
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.ONEKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD1].queue:
|
|
||||||
couleur_choix_num(1)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.TWOKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD2].queue:
|
|
||||||
couleur_choix_num(2)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.THREEKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD3].queue:
|
|
||||||
couleur_choix_num(3)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.FOURKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD4].queue:
|
|
||||||
couleur_choix_num(4)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.FIVEKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD5].queue:
|
|
||||||
couleur_choix_num(5)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.SIXKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD6].queue:
|
|
||||||
couleur_choix_num(6)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.SEVENKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD7].queue:
|
|
||||||
couleur_choix_num(7)
|
|
||||||
if JUST_ACTIVATED in keyboard.inputs[bge.events.EIGHTKEY].queue or JUST_ACTIVATED in keyboard.inputs[bge.events.PAD8].queue:
|
|
||||||
couleur_choix_num(8)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Commandes
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Init
|
|
||||||
def cmd_init():
|
|
||||||
scene.objects['Aide-cmd-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Play-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Raz-couleurs-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Raz-vue-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Orbit'].setVisible(False,False)
|
|
||||||
for i in range (1, 9):
|
|
||||||
scene.objects['Couleur'+str(i)+"-Hl"].setVisible(False,False)
|
|
||||||
|
|
||||||
# Le highlight des commandes
|
|
||||||
def cmd_hl(cont):
|
|
||||||
obj = cont.owner
|
|
||||||
|
|
||||||
# Activation
|
|
||||||
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
if obj.name!="Play" and obj.name!="Pause" and obj.name!="Play-Hl" and obj.name!="Pause-Hl":
|
|
||||||
obj.setVisible(False,True)
|
|
||||||
scene.objects[obj.name+'-Hl'].setVisible(True,True)
|
|
||||||
# obj.color = couleur_cmd_hl
|
|
||||||
|
|
||||||
# Play et pause
|
|
||||||
if obj.name=="Pause" or obj.name=="Play":
|
|
||||||
if scene.objects['Mecanisme']['anim'] == True:
|
|
||||||
scene.objects['Pause'].setVisible(False,False)
|
|
||||||
scene.objects['Pause-Hl'].setVisible(True,False)
|
|
||||||
else:
|
|
||||||
scene.objects['Play'].setVisible(False,False)
|
|
||||||
scene.objects['Play-Hl'].setVisible(True,False)
|
|
||||||
|
|
||||||
# Désactivation
|
|
||||||
if cont.sensors['MO'].status == JUST_RELEASED and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
if obj.name!="Play" and obj.name!="Pause" and obj.name!="Play-Hl" and obj.name!="Pause-Hl":
|
|
||||||
scene.objects[obj.name+'-Hl'].setVisible(False,True)
|
|
||||||
obj.setVisible(True,True)
|
|
||||||
|
|
||||||
# Play et pause
|
|
||||||
if obj.name=="Pause" or obj.name=="Play":
|
|
||||||
if scene.objects['Mecanisme']['anim'] == True:
|
|
||||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Pause'].setVisible(True,False)
|
|
||||||
else:
|
|
||||||
scene.objects['Play-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Play'].setVisible(True,False)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Animation
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Initialisation de l'animation -> Play
|
|
||||||
def anim_init(cont):
|
|
||||||
start = 1
|
|
||||||
end = 200
|
|
||||||
layer = 0
|
|
||||||
priority = 1
|
|
||||||
blendin = 1.0
|
|
||||||
mode = bge.logic.KX_ACTION_MODE_LOOP
|
|
||||||
layerWeight = 0.0
|
|
||||||
ipoFlags = 0
|
|
||||||
speed = 1.0
|
|
||||||
for objet in objets_anim :
|
|
||||||
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
||||||
scene.objects['Play'].setVisible(False,False)
|
|
||||||
scene.objects['Pause'].setVisible(True,False)
|
|
||||||
scene.objects['Mecanisme']['anim'] = True
|
|
||||||
|
|
||||||
# Animation en pause (bas niveau)
|
|
||||||
def anim_pause():
|
|
||||||
layer = 0
|
|
||||||
for objet in objets_anim :
|
|
||||||
scene.objects['Mecanisme']['anim_frame'] = scene.objects[objet].getActionFrame(layer)
|
|
||||||
scene.objects[objet].stopAction(layer)
|
|
||||||
scene.objects['Mecanisme']['anim'] = False
|
|
||||||
|
|
||||||
# Animation en pseudo-pause
|
|
||||||
# Play d'une frame pour remettre les pièces en place
|
|
||||||
def anim_play1frame():
|
|
||||||
start = scene.objects['Mecanisme']['anim_frame']
|
|
||||||
end = scene.objects['Mecanisme']['anim_frame']+1
|
|
||||||
layer = 0
|
|
||||||
priority = 1
|
|
||||||
blendin = 1.0
|
|
||||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
|
||||||
layerWeight = 0.0
|
|
||||||
ipoFlags = 0
|
|
||||||
speed = 1.0
|
|
||||||
for objet in objets_anim :
|
|
||||||
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
||||||
scene.objects['Mecanisme']['anim_frame'] = end
|
|
||||||
|
|
||||||
# Reprise de l'animation (bas niveau)
|
|
||||||
def anim_play():
|
|
||||||
start = scene.objects['Mecanisme']['anim_frame']
|
|
||||||
end = 200
|
|
||||||
layer = 0
|
|
||||||
priority = 1
|
|
||||||
blendin = 1.0
|
|
||||||
mode = bge.logic.KX_ACTION_MODE_PLAY
|
|
||||||
layerWeight = 0.0
|
|
||||||
ipoFlags = 0
|
|
||||||
speed = 1.0
|
|
||||||
for objet in objets_anim :
|
|
||||||
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
||||||
scene.objects['Mecanisme']['anim'] = True
|
|
||||||
|
|
||||||
# Pause et replay par les commandes
|
|
||||||
def anim_cmd(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
|
|
||||||
# Pause
|
|
||||||
if scene.objects['Mecanisme']['anim'] == True:
|
|
||||||
anim_pause()
|
|
||||||
scene.objects['Pause'].setVisible(False,False)
|
|
||||||
scene.objects['Pause-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Play-Hl'].setVisible(True,False)
|
|
||||||
else:
|
|
||||||
# Play
|
|
||||||
anim_play()
|
|
||||||
scene.objects['Play'].setVisible(False,False)
|
|
||||||
scene.objects['Play-Hl'].setVisible(False,False)
|
|
||||||
scene.objects['Pause-Hl'].setVisible(True,False)
|
|
||||||
|
|
||||||
# Play en continu
|
|
||||||
def anim_boucle(cont):
|
|
||||||
if scene.objects['Mecanisme']['anim'] == True and scene.objects['Piston'].isPlayingAction(0) == False:
|
|
||||||
start = 1
|
|
||||||
end = 200
|
|
||||||
layer = 0
|
|
||||||
priority = 1
|
|
||||||
blendin = 1.0
|
|
||||||
mode = bge.logic.KX_ACTION_MODE_LOOP
|
|
||||||
layerWeight = 0.0
|
|
||||||
ipoFlags = 0
|
|
||||||
speed = 1.0
|
|
||||||
for objet in objets_anim :
|
|
||||||
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Manipulation du mécanisme
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Mémorisation de la position et orientation initiales du modèle et de la caméra
|
|
||||||
def manip_init(cont):
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet]['init_lx']=scene.objects[objet].worldPosition.x
|
|
||||||
scene.objects[objet]['init_ly']=scene.objects[objet].worldPosition.y
|
|
||||||
scene.objects[objet]['init_lz']=scene.objects[objet].worldPosition.z
|
|
||||||
if 'init_rx' in scene.objects[objet]:
|
|
||||||
scene.objects[objet]['init_rx'] = scene.objects[objet].worldOrientation.to_euler().x
|
|
||||||
if 'init_ry' in scene.objects[objet]:
|
|
||||||
scene.objects[objet]['init_ry'] = scene.objects[objet].worldOrientation.to_euler().y
|
|
||||||
if 'init_rz' in scene.objects[objet]:
|
|
||||||
scene.objects[objet]['init_rz'] = scene.objects[objet].worldOrientation.to_euler().z
|
|
||||||
scene.objects['Camera']['init_lx']=scene.objects['Camera'].worldPosition.x
|
|
||||||
scene.objects['Camera']['init_ly']=scene.objects['Camera'].worldPosition.y
|
|
||||||
scene.objects['Camera']['init_lz']=scene.objects['Camera'].worldPosition.z
|
|
||||||
scene.objects['Mecanisme']['init_lx']=scene.objects['Mecanisme'].worldPosition.x
|
|
||||||
scene.objects['Mecanisme']['init_ly']=scene.objects['Mecanisme'].worldPosition.y
|
|
||||||
scene.objects['Mecanisme']['init_lz']=scene.objects['Mecanisme'].worldPosition.z
|
|
||||||
scene.objects['Mecanisme']['init_rx']=scene.objects['Mecanisme'].worldOrientation.to_euler().x
|
|
||||||
scene.objects['Mecanisme']['init_ry']=scene.objects['Mecanisme'].worldOrientation.to_euler().y
|
|
||||||
scene.objects['Mecanisme']['init_rz']=scene.objects['Mecanisme'].worldOrientation.to_euler().z
|
|
||||||
|
|
||||||
# def applyMovemenTo(obj, lx,ly,lz,rx,ry,rz):
|
|
||||||
# lres=0.001 # resolution location
|
|
||||||
# rres=0.001 # resolution rotation
|
|
||||||
# while (obj.worldPosition.x-lx > lres) or (obj.worldPosition.y-ly > lres) or (obj.worldPosition.z-lz > lres) or (obj.worldOrientation.to_euler().x-rx > rres) or (obj.worldOrientation.to_euler().y-ry > rres) or (obj.worldOrientation.to_euler().z-rz > rres):
|
|
||||||
# if obj.worldPosition.x-lx > lres:
|
|
||||||
# obj. applyMovement(lres,0,0)
|
|
||||||
# if obj.worldPosition.y-ly > lres:
|
|
||||||
# obj. applyMovement(0,lres,0 )
|
|
||||||
# if obj.worldPosition.z-lz > lres:
|
|
||||||
# obj. applyMovement(0,0,lres)
|
|
||||||
# if obj.worldOrientation.to_euler().x-rx > rres:
|
|
||||||
# obj.applyRotation(rres,0,0)
|
|
||||||
# if obj.worldOrientation.to_euler().y-ry > rres:
|
|
||||||
# obj.applyRotation(0,rres,0)
|
|
||||||
# if obj.worldOrientation.to_euler().z-ry > rres:
|
|
||||||
# obj.applyRotation(0,0,rres)
|
|
||||||
|
|
||||||
# def applyTranslationTo(obj, lx,ly,lz):
|
|
||||||
# lres=0.001 # resolution location
|
|
||||||
# while (obj.worldPosition.x-lx > lres) or (obj.worldPosition.y-ly > lres) or (obj.worldPosition.z-lz > lres):
|
|
||||||
# if obj.worldPosition.x-lx > lres:
|
|
||||||
# obj. applyMovement(lres,0,0)
|
|
||||||
# if obj.worldPosition.y-ly > lres:
|
|
||||||
# obj. applyMovement(0,lres,0 )
|
|
||||||
# if obj.worldPosition.z-lz > lres:
|
|
||||||
# obj. applyMovement(0,0,lres)
|
|
||||||
|
|
||||||
# Atteindre une orientation (bas niveau)
|
|
||||||
def applyRotationTo(obj, rx=None, ry=None, rz=None):
|
|
||||||
rres=0.001 # resolution rotation
|
|
||||||
|
|
||||||
# x
|
|
||||||
if rx is not None:
|
|
||||||
while (abs(rx-obj.worldOrientation.to_euler().x) > rres) :
|
|
||||||
if obj.worldOrientation.to_euler().x-rx > rres:
|
|
||||||
obj.applyRotation((-rres, 0, 0), True)
|
|
||||||
if rx-obj.worldOrientation.to_euler().x > rres:
|
|
||||||
obj.applyRotation((rres, 0, 0), True)
|
|
||||||
# print ("delta x ",rx-obj.worldOrientation.to_euler().x)
|
|
||||||
|
|
||||||
# y
|
|
||||||
if ry is not None:
|
|
||||||
while (abs(ry-obj.worldOrientation.to_euler().y) > rres) :
|
|
||||||
if obj.worldOrientation.to_euler().y-ry > rres:
|
|
||||||
obj.applyRotation((0, -rres, 0), True)
|
|
||||||
if ry-obj.worldOrientation.to_euler().y > rres:
|
|
||||||
obj.applyRotation((0, rres, 0), True)
|
|
||||||
# print ("delta y ",ry-obj.worldOrientation.to_euler().y)
|
|
||||||
|
|
||||||
# z
|
|
||||||
if rz is not None:
|
|
||||||
while (abs(rz-obj.worldOrientation.to_euler().z) > rres) :
|
|
||||||
if obj.worldOrientation.to_euler().z-rz > rres:
|
|
||||||
obj.applyRotation((0, 0, -rres), True)
|
|
||||||
if rz-obj.worldOrientation.to_euler().z > rres:
|
|
||||||
obj.applyRotation((0, 0, rres), True)
|
|
||||||
# print ("delta z ",rz-obj.worldOrientation.to_euler().z)
|
|
||||||
|
|
||||||
# Reset de la manipulation de la vue
|
|
||||||
def manip_reset(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['init_lx']
|
|
||||||
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['init_ly']
|
|
||||||
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz']
|
|
||||||
applyRotationTo(scene.objects['Mecanisme'], 0, 0, 0)
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].setVisible(True,False)
|
|
||||||
scene.objects[objet+"_Lines.GP"].setVisible(True,False)
|
|
||||||
if scene.objects['Mecanisme']['eclate'] ==True:
|
|
||||||
scene.objects['Mecanisme']['eclate'] = False
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].worldPosition.x =scene.objects[objet]['init_lx']
|
|
||||||
scene.objects[objet].worldPosition.y = scene.objects[objet]['init_ly']
|
|
||||||
scene.objects[objet].worldPosition.z = scene.objects[objet]['init_lz']
|
|
||||||
if scene.objects['Mecanisme']['anim'] == False: # Play d'une frame
|
|
||||||
anim_play1frame()
|
|
||||||
|
|
||||||
# Position de départ pour la manipulation de la vue
|
|
||||||
def manip_start(cont):
|
|
||||||
obj = cont.owner
|
|
||||||
obj['click_x']=cont.sensors['ClickM'].position[0]
|
|
||||||
obj['click_y']=cont.sensors['ClickM'].position[1]
|
|
||||||
|
|
||||||
# Cacher le cercle de la manipulation Orbit
|
|
||||||
def manip_stop(cont):
|
|
||||||
scene.objects['Orbit'].setVisible(False,False)
|
|
||||||
|
|
||||||
# Manipulation du modèle ou de la caméra
|
|
||||||
def manip(cont):
|
|
||||||
obj = cont.owner
|
|
||||||
sensibilite_orbit=0.0005
|
|
||||||
sensibilite_pan=0.005
|
|
||||||
sensibilite_zoom=0.01
|
|
||||||
delta_x=cont.sensors['DownM'].position[0]-obj['click_x']
|
|
||||||
delta_y=cont.sensors['DownM'].position[1]-obj['click_y']
|
|
||||||
|
|
||||||
# Orbit (1280 * 720 px)
|
|
||||||
if obj['manip_mode']==0:
|
|
||||||
scene.objects['Orbit'].color=couleur_cmd
|
|
||||||
scene.objects['Orbit'].setVisible(True,False)
|
|
||||||
dist_orbit = math.sqrt(((1280/2)-obj['click_x'])**2+((720/2)-obj['click_y'])**2)
|
|
||||||
if dist_orbit<235 : # Orbit sur x et z
|
|
||||||
n=10
|
|
||||||
pas_x=(delta_x*40*sensibilite_orbit)/n
|
|
||||||
pas_y=(((1280/2)-cont.sensors['DownM'].position[0])+((720/2)-cont.sensors['DownM'].position[1]))*0.005
|
|
||||||
pas_z=(delta_y*40*sensibilite_orbit)/n
|
|
||||||
for i in range (n):
|
|
||||||
bge.render.drawLine([scene.objects['Orbit'].worldPosition.x+pas_x*i, scene.objects['Orbit'].worldPosition.y+abs(pas_y*math.sin((3.14*i)/n)), scene.objects['Orbit'].worldPosition.z-pas_z*i],
|
|
||||||
[scene.objects['Orbit'].worldPosition.x+pas_x*(i+1), scene.objects['Orbit'].worldPosition.y+abs(pas_y*math.sin((3.14*(i+1))/n)), scene.objects['Orbit'].worldPosition.z-pas_z*(i+1)],
|
|
||||||
[0.8, 0.619, 0.021])
|
|
||||||
scene.objects['Mecanisme'].applyRotation((delta_y*sensibilite_orbit, 0, delta_x*sensibilite_orbit), True)
|
|
||||||
else: # Orbit sur y
|
|
||||||
scene.objects['Orbit'].color=couleur_cmd_hl
|
|
||||||
if abs(delta_x) >= abs(delta_y):
|
|
||||||
scene.objects['Mecanisme'].applyRotation((0, delta_x*sensibilite_orbit, 0), True)
|
|
||||||
else:
|
|
||||||
scene.objects['Mecanisme'].applyRotation((0, delta_y*sensibilite_orbit, 0), True)
|
|
||||||
|
|
||||||
# Pan
|
|
||||||
if obj['manip_mode']==1: # Shift
|
|
||||||
scene.objects['Camera'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True)
|
|
||||||
|
|
||||||
# Zoom
|
|
||||||
if obj['manip_mode']==2: # Ctrl
|
|
||||||
scene.objects['Camera'].applyMovement((0, 0, (delta_x+delta_y)*sensibilite_zoom), True)
|
|
||||||
|
|
||||||
# Zoom avec la molette
|
|
||||||
def manip_wheel(cont):
|
|
||||||
obj = cont.owner
|
|
||||||
sensibilite_wheel = 20
|
|
||||||
if cont.sensors['WheelUp'].positive:
|
|
||||||
scene.objects['Camera'].applyMovement((0, 0, -sensibilite_wheel), True)
|
|
||||||
if cont.sensors['WheelDown'].positive:
|
|
||||||
scene.objects['Camera'].applyMovement((0, 0, sensibilite_wheel), True)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Eclaté
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Position de départ pour l'éclatement de la vue
|
|
||||||
def eclate_start(cont):
|
|
||||||
if scene.objects['Mecanisme']['manip_mode']==1:
|
|
||||||
obj = cont.owner
|
|
||||||
obj['click_x']=cont.sensors['Click'].position[0]
|
|
||||||
obj['click_y']=cont.sensors['Click'].position[1]
|
|
||||||
|
|
||||||
# Déplacement des composants en vue éclatée
|
|
||||||
def eclate(cont):
|
|
||||||
obj = cont.owner
|
|
||||||
sensibilite=0.005
|
|
||||||
delta=(cont.sensors['Down'].position[0]-obj['click_x'])+(cont.sensors['Down'].position[1]-obj['click_y'])
|
|
||||||
if obj['manip_mode']==1: # Shift
|
|
||||||
scene.objects['Mecanisme']['eclate'] =True
|
|
||||||
for objet in objets :
|
|
||||||
ecla_x, ecla_y,ecla_z = 0,0,0
|
|
||||||
if 'ecla_x' in scene.objects[objet]:
|
|
||||||
ecla_x = scene.objects[objet]['ecla_x']
|
|
||||||
if 'ecla_y' in scene.objects[objet]:
|
|
||||||
ecla_y = scene.objects[objet]['ecla_y']
|
|
||||||
if 'ecla_z' in scene.objects[objet]:
|
|
||||||
ecla_z = scene.objects[objet]['ecla_z']
|
|
||||||
|
|
||||||
# Déplacement dans le repère du mécanisme
|
|
||||||
x_axis = scene.objects['Mecanisme'].orientation.col[0]
|
|
||||||
y_axis = scene.objects['Mecanisme'].orientation.col[1]
|
|
||||||
z_axis = scene.objects['Mecanisme'].orientation.col[2]
|
|
||||||
scene.objects[objet].applyMovement((delta*sensibilite*ecla_x*x_axis[0], delta*sensibilite*ecla_x*x_axis[1] , delta*sensibilite*ecla_x*x_axis[2]), False)
|
|
||||||
scene.objects[objet].applyMovement((delta*sensibilite*ecla_y*y_axis[0], delta*sensibilite*ecla_y*y_axis[1] , delta*sensibilite*ecla_y*y_axis[2]), False)
|
|
||||||
scene.objects[objet].applyMovement((delta*sensibilite*ecla_z*z_axis[0], delta*sensibilite*ecla_z*z_axis[1] , delta*sensibilite*ecla_z*z_axis[2]), False)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Couleur
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Initialisation des couleurs du mécanisme
|
|
||||||
def couleur_init():
|
|
||||||
i=0
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet].color = couleurs_dict[objets_couleur[i]]
|
|
||||||
scene.objects[objet].setVisible(True,False)
|
|
||||||
scene.objects[objet+"_Lines.GP"].setVisible(True,False)
|
|
||||||
scene.objects[objet+"-Nom"].color = couleurs_dict[objets_couleur[i]]
|
|
||||||
scene.objects[objet+"-Nom-Hl"].color = couleurs_dict[objets_couleur[i]]
|
|
||||||
scene.objects[objet+"-Nom-Hl"].setVisible(False,False)
|
|
||||||
i +=1
|
|
||||||
|
|
||||||
# Reset des couleurs du mécanisme
|
|
||||||
def couleur_reset(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
couleur_init()
|
|
||||||
|
|
||||||
# Sélection couleur dans la palette avec son numéro de couleur (bas niveau)
|
|
||||||
def couleur_choix_num(num):
|
|
||||||
for i in range (1, 9):
|
|
||||||
scene.objects['Couleur'+str(i)].worldScale=[3, 3, 3]
|
|
||||||
scene.objects['Couleur'+str(i)+"-Hl"].worldScale=[3, 3, 3]
|
|
||||||
scene.objects['Couleur'+str(num)].worldScale=[4, 4, 4]
|
|
||||||
scene.objects['Couleur'+str(num)+'-Hl'].worldScale=[4, 4, 4]
|
|
||||||
scene.objects['Couleurs']['couleur_select']=num
|
|
||||||
|
|
||||||
# Sélection couleur dans la palette
|
|
||||||
def couleur_choix(cont):
|
|
||||||
obj = cont.owner
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
hitObject = cont.sensors['MO'].hitObject
|
|
||||||
if hitObject is not None and "-Hl" not in hitObject .name:
|
|
||||||
couleur_choix_num(int(hitObject .name[7]))
|
|
||||||
|
|
||||||
# Le highlight de 'couleur_choix'
|
|
||||||
def couleur_choix_hl(cont):
|
|
||||||
if cont.sensors['MO'].positive and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
hitObject = cont.sensors['MO'].hitObject
|
|
||||||
if hitObject is not None and "-Hl" not in hitObject .name:
|
|
||||||
hitObject.setVisible(False,False)
|
|
||||||
scene.objects[hitObject.name+'-Hl'].setVisible(True,False)
|
|
||||||
if cont.sensors['MO'].status == JUST_RELEASED:
|
|
||||||
for i in range (1, 9):
|
|
||||||
scene.objects['Couleur'+str(i)].setVisible(True,False)
|
|
||||||
scene.objects['Couleur'+str(i)+"-Hl"].setVisible(False,False)
|
|
||||||
|
|
||||||
# Colorisation de la pièce
|
|
||||||
def couleur_objet(cont):
|
|
||||||
if cont.sensors['Click'].positive and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
hitObject = cont.sensors['MO'].hitObject
|
|
||||||
if hitObject is not None and hitObject.visible:
|
|
||||||
couleur_select = scene.objects['Couleurs']['couleur_select']
|
|
||||||
if couleur_select != 0 and couleur_select != 8:
|
|
||||||
hitObject.color = couleurs[couleur_select-1][1]
|
|
||||||
scene.objects[hitObject.name+"-Nom"].color = couleurs[couleur_select-1][1]
|
|
||||||
scene.objects[hitObject.name+"-Nom-Hl"].color = couleurs[couleur_select-1][1]
|
|
||||||
if couleur_select == 8: # Couleur transparente -> disparition
|
|
||||||
hitObject.setVisible(False,False)
|
|
||||||
scene.objects[hitObject.name+"_Lines.GP"].setVisible(False,False)
|
|
||||||
|
|
||||||
# Le highlight de 'couleur_objet'
|
|
||||||
def couleur_objet_hl(cont):
|
|
||||||
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
hitObject = cont.sensors['MO'].hitObject
|
|
||||||
if hitObject is not None and hitObject.visible:
|
|
||||||
scene.objects[hitObject.name+"-Nom"].setVisible(False,False)
|
|
||||||
scene.objects[hitObject.name+"-Nom-Hl"].setVisible(True,False)
|
|
||||||
if cont.sensors['MO'].status == JUST_RELEASED:
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet+"-Nom"].setVisible(True,False)
|
|
||||||
scene.objects[objet+"-Nom-Hl"].setVisible(False,False)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Nomenclature
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Click sur la nomeclature
|
|
||||||
def nom(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
hitObject = cont.sensors['MO'].hitObject
|
|
||||||
if hitObject is not None:
|
|
||||||
|
|
||||||
# Afficher/cacher les repères de la pièce
|
|
||||||
if "-Nom-Rep" in hitObject.name:
|
|
||||||
obj=hitObject.name[:len(hitObject.name)-8]
|
|
||||||
print (scene.objects[obj]['rep'])
|
|
||||||
if scene.objects[obj]['rep']==False:
|
|
||||||
scene.objects[obj]['rep']=True
|
|
||||||
hitObject.color=couleur_rep_actif
|
|
||||||
for rep in objets_rep_dict[obj]:
|
|
||||||
scene.objects[rep].setVisible(True,False)
|
|
||||||
else:
|
|
||||||
scene.objects[obj]['rep']=False
|
|
||||||
hitObject.color=couleur_rep_pasactif
|
|
||||||
for rep in objets_rep_dict[obj]:
|
|
||||||
scene.objects[rep].setVisible(False,False)
|
|
||||||
|
|
||||||
# Colorisation de la pièce par la nomenclature
|
|
||||||
else:
|
|
||||||
couleur_select = scene.objects['Couleurs']['couleur_select']
|
|
||||||
if couleur_select != 0 and couleur_select != 8:
|
|
||||||
hitObject.color = couleurs[couleur_select-1][1]
|
|
||||||
scene.objects[hitObject.name+"-Hl"].color = couleurs[couleur_select-1][1]
|
|
||||||
scene.objects[hitObject.name[0:len(hitObject.name)-4]].setVisible(True,False)
|
|
||||||
scene.objects[hitObject.name[0:len(hitObject.name)-4]].color = couleurs[couleur_select-1][1]
|
|
||||||
|
|
||||||
if couleur_select == 8: # Couleur transparente -> disparition / apparition
|
|
||||||
obj=scene.objects[hitObject.name[0:len(hitObject.name)-4]]
|
|
||||||
obj_GP=scene.objects[hitObject.name[0:len(hitObject.name)-4]+"_Lines.GP"]
|
|
||||||
if obj.visible==True:
|
|
||||||
obj.setVisible(False,False)
|
|
||||||
obj_GP.setVisible(False,False)
|
|
||||||
else:
|
|
||||||
obj.setVisible(True,False)
|
|
||||||
obj_GP.setVisible(True,False)
|
|
||||||
# if couleur_select == 8: # Couleur transparente -> disparition
|
|
||||||
# scene.objects[hitObject.name[0:len(hitObject.name)-4]].setVisible(False,False)
|
|
||||||
|
|
||||||
# Le highlight de la nomenclature
|
|
||||||
def nom_hl(cont):
|
|
||||||
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
hitObject = cont.sensors['MO'].hitObject
|
|
||||||
if hitObject is not None:
|
|
||||||
hitObject.setVisible(False,False)
|
|
||||||
scene.objects[hitObject.name+'-Hl'].setVisible(True,False)
|
|
||||||
# obj.color = couleur_cmd_hl
|
|
||||||
if cont.sensors['MO'].status == JUST_RELEASED and scene.objects['Mecanisme']['manip_mode']==0:
|
|
||||||
for objet in objets :
|
|
||||||
scene.objects[objet+"-Nom"].setVisible(True,False)
|
|
||||||
scene.objects[objet+"-Nom-Hl"].setVisible(False,False)
|
|
||||||
# for objet in objets_rep :
|
|
||||||
# scene.objects[objet+'-Nom-Rep'].setVisible(True,False)
|
|
||||||
# scene.objects[objet+'-Nom-Rep-Hl'].setVisible(False,False)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Aide
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Ouvrir la page d'aide
|
|
||||||
def aide(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
|
||||||
# scene.replace('Scene-Aide') # Bug Eevee -> même scene mais camera différente
|
|
||||||
scene.active_camera=scene.objects['Aide-Camera']
|
|
||||||
scene.objects['Apropos-Lien_projet'].color= couleur_lien
|
|
||||||
scene.objects['Apropos-Lien_blender'].color= couleur_lien
|
|
||||||
scene.objects['Apropos-Lien_upbge'].color= couleur_lien
|
|
||||||
|
|
||||||
# Fermer la page d'aide
|
|
||||||
def aide_fermer(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
|
||||||
# bge.logic.addScene('Scene') # Bug Eevee -> même scene mais camera différente
|
|
||||||
scene.active_camera=scene.objects['Camera']
|
|
||||||
|
|
||||||
# Aller sur les liens
|
|
||||||
def aide_apropos(cont):
|
|
||||||
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
|
|
||||||
obj = cont.owner
|
|
||||||
if obj.name == "Apropos-Lien_projet" :
|
|
||||||
webbrowser.open('https://gitlab.com/blender-edutech')
|
|
||||||
if obj.name == "Apropos-Lien_blender" :
|
|
||||||
webbrowser.open('https://blender.org')
|
|
||||||
if obj.name == "Apropos-Lien_upbge" :
|
|
||||||
webbrowser.open('https://upbge.org')
|
|
||||||
|
|
||||||
# Le highlight des liens
|
|
||||||
def aide_apropos_hl(cont):
|
|
||||||
if cont.sensors['MO'].status == JUST_ACTIVATED :
|
|
||||||
obj = cont.owner
|
|
||||||
obj.color = couleur_lien_hl
|
|
||||||
if cont.sensors['MO'].status == JUST_RELEASED :
|
|
||||||
obj = cont.owner
|
|
||||||
obj.color = couleur_lien
|
|
||||||
|
Loading…
Reference in New Issue
Block a user