jumeaux-numeriques/twin_doc.py

55 lines
1.6 KiB
Python
Raw Normal View History

import bge # Bibliothèque Blender Game Engine (UPBGE)
###############################################################################
2022-12-11 10:28:41 +01:00
# twin_doc.py
2022-12-11 04:59:00 +01:00
# @title: Documentation de l'environnement 3D des jumeaux numériques
# @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 :
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