lecteur-3d-cinematique/cine_doc.py

69 lines
2.2 KiB
Python

import bge # Bibliothèque Blender Game Engine (UPBGE)
###############################################################################
# cine_doc.py
# @title: Documentation du player 3D d'analyse de cinématique
# @project: Blender-EduTech
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2020-2022 Philippe Roy
# @license: GNU GPL
###############################################################################
# UPBGE scene
scene = bge.logic.getCurrentScene()
# Colors
color_link = [0.051, 0.270, 0.279,1] # Turquoise
# color_link = [0.024, 0.006, 0.8, 1] # Bleu
color_link_hl = [0.8, 0.005, 0.315, 1] # Magenta
# UPBGE constants
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
##
# Ouverture
##
def open():
scene.active_camera = scene.objects["Camera-Doc"]
scene.objects['Doc_close'].color= color_link
scene.objects['Doc'].setVisible(True,True)
def close(cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
if scene.objects['Doc']['anim'] == True:
start = scene.objects['Mecanism']['anim_frame']
end = 250
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 scene.objects['Mecanism']['objects_anim'] :
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
scene.objects['Mecanism']['anim'] = True
scene.objects['Doc']['anim'] == False
scene.active_camera = scene.objects["Camera"]
scene.objects['Doc'].setVisible(False,True)
##
# Highlight
##
def hl(cont):
if cont.sensors['MO'].status == JUST_ACTIVATED:
obj = cont.owner
name=obj.name[:-7]
scene.objects[name].color = color_link_hl
if cont.sensors['MO'].status == JUST_RELEASED:
obj = cont.owner
name=obj.name[:-7]
scene.objects[name].color = color_link