Hud en mode overlay

This commit is contained in:
Philippe Roy 2022-07-17 14:50:46 +02:00
parent 1369bdf553
commit a338239e62
3 changed files with 60 additions and 29 deletions

BIN
codetower-33.blend Normal file

Binary file not shown.

87
ct.py
View File

@ -102,18 +102,18 @@ def cmd_tower_construct(cont):
sound_play (sndbuff_construct) sound_play (sndbuff_construct)
if scene.objects['Terrain']['construct_mode']==True: if scene.objects['Terrain']['construct_mode']==True:
scene.objects['Terrain']['construct_mode']=False scene.objects['Terrain']['construct_mode']=False
obj.worldScale=[1, 1, 1] obj.worldScale=[0.0135, 0.0135, 0.0135]
obj.color = color_cmd obj.color = color_cmd
obj_Hl.worldScale=[1, 1, 1] obj_Hl.worldScale=[0.0135, 0.0135, 0.0135]
obj_Hl.color = color_cmd obj_Hl.color = color_cmd
scene.objects['Tower_construc_mode'].setVisible(False,False) scene.objects['Tower_construc_mode'].setVisible(False,False)
scene.objects['Tower_construc_mode'].color = color_cmd scene.objects['Tower_construc_mode'].color = color_cmd
text_info ("") text_info ("")
else: else:
scene.objects['Terrain']['construct_mode']=True scene.objects['Terrain']['construct_mode']=True
obj.worldScale=[1.25, 1.25, 1.25] obj.worldScale=[0.0135*1.25, 0.0135*1.25, 0.0135*1.25]
obj.color = color_cmd_hl obj.color = color_cmd_hl
obj_Hl.worldScale=[1.25, 1.25, 1.25] obj_Hl.worldScale=[0.0135*1.25, 0.0135*1.25, 0.0135*1.25]
obj_Hl.color = color_cmd_hl obj_Hl.color = color_cmd_hl
scene.objects['Tower_construc_mode'].setVisible(True,False) scene.objects['Tower_construc_mode'].setVisible(True,False)
scene.objects['Tower_construc_mode'].color = color_cmd scene.objects['Tower_construc_mode'].color = color_cmd
@ -159,7 +159,7 @@ def points_maj (cont):
if scene.objects['Points-Map-text']['anim']: if scene.objects['Points-Map-text']['anim']:
if scene.objects['Points-Map-text']['timer']<120: if scene.objects['Points-Map-text']['timer']<120:
decal = 0.1 decal = 0.1
vect=scene.objects['Points-Map-text'].getVectTo(scene.objects['Camera'])[1] vect=scene.objects['Points-Map-text'].getVectTo(scene.objects['Camera-Hud'])[1]
scene.objects['Points-Map-text'].applyMovement((vect[0]*decal, vect[1]*decal, vect[2]*decal), False) scene.objects['Points-Map-text'].applyMovement((vect[0]*decal, vect[1]*decal, vect[2]*decal), False)
scene.objects['Points-Map-text']['timer']+=1 scene.objects['Points-Map-text']['timer']+=1
if int(scene.objects['Points-Map-text']['timer'])>=120: if int(scene.objects['Points-Map-text']['timer'])>=120:
@ -264,11 +264,16 @@ def scn_terrain_mo (cont):
# Initialisation lors du chargement du terrain # Initialisation lors du chargement du terrain
def terrain_init (): def terrain_init ():
# Cacher la bannière de fin # Cacher les fenêtres
scene.objects['End'].setVisible(False,True) scene.objects['End'].setVisible(False,True)
scene.objects['End']['timer']=0 scene.objects['End']['timer']=0
scene.objects['Doc'].setVisible(False,True) scene.objects['Doc'].setVisible(False,True)
# Ajout du Hud
scene.active_camera = scene.objects["Camera"]
scene.objects['Sun'].setVisible(True,True)
scene.addOverlayCollection(scene.cameras['Camera-Hud'], bpy.data.collections['Hud'])
# Pile des draws # Pile des draws
scene.objects['Terrain']['draw2d_process']=False scene.objects['Terrain']['draw2d_process']=False
scene.objects['Terrain']['draw2d_list']=[] scene.objects['Terrain']['draw2d_list']=[]
@ -582,7 +587,9 @@ def cmd_init():
scene.objects['Stop'].suspendPhysics() scene.objects['Stop'].suspendPhysics()
scene.objects['Stop-Hl'].setVisible(False,False) scene.objects['Stop-Hl'].setVisible(False,False)
scene.objects['Construc-Hl'].setVisible(False,False) scene.objects['Construc-Hl'].setVisible(False,False)
scene.objects['Construc-underlay'].setVisible(False,False)
scene.objects['Book-cmd-Hl'].setVisible(False,False) scene.objects['Book-cmd-Hl'].setVisible(False,False)
scene.objects['Book-cmd-underlay'].setVisible(False,False)
scene.objects['ResetView-Hl'].setVisible(False,False) scene.objects['ResetView-Hl'].setVisible(False,False)
scene.objects['About-cmd-Hl'].setVisible(False,False) scene.objects['About-cmd-Hl'].setVisible(False,False)
scene.objects['About'].setVisible(False,True) scene.objects['About'].setVisible(False,True)
@ -631,7 +638,7 @@ def cmd_hl(cont):
# Activation # Activation
if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['Terrain']['manip_mode']==0: if cont.sensors['MO'].status == JUST_ACTIVATED and scene.objects['Terrain']['manip_mode']==0:
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" : if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop":
obj.setVisible(False,True) obj.setVisible(False,True)
scene.objects[obj.name+'-Hl'].setVisible(True,True) scene.objects[obj.name+'-Hl'].setVisible(True,True)
@ -670,7 +677,7 @@ def cmd_hl(cont):
# Désactivation # Désactivation
if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9): if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9):
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd": if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd" and obj.name!="Book-cmd":
scene.objects[obj.name+'-Hl'].setVisible(False,True) scene.objects[obj.name+'-Hl'].setVisible(False,True)
obj.setVisible(True,True) obj.setVisible(True,True)
scene.objects['Cmd-text'].setVisible(False,False) scene.objects['Cmd-text'].setVisible(False,False)
@ -703,6 +710,16 @@ def cmd_hl(cont):
scene.objects['Sound-cmd'].setVisible(True,False) scene.objects['Sound-cmd'].setVisible(True,False)
scene.objects['Cmd-text'].setVisible(False,False) scene.objects['Cmd-text'].setVisible(False,False)
# Book
if obj.name=="Book-cmd" and scene.objects['Book'].visible==False:
scene.objects[obj.name+'-Hl'].setVisible(False,True)
obj.setVisible(True,True)
scene.objects['Cmd-text'].setVisible(False,False)
if obj.name=="Book-cmd" and scene.objects['Book'].visible==True:
scene.objects[obj.name+'-Hl'].setVisible(False,True)
scene.objects[obj.name].setVisible(False,True)
scene.objects['Cmd-text'].setVisible(False,False)
# Click sur les commandes # Click sur les commandes
def cmd_click (cont): def cmd_click (cont):
obj = cont.owner obj = cont.owner
@ -822,12 +839,6 @@ def manip_init(cont):
scene.objects['Terrain']['init_rx']=scene.objects['Terrain'].worldOrientation.to_euler().x scene.objects['Terrain']['init_rx']=scene.objects['Terrain'].worldOrientation.to_euler().x
scene.objects['Terrain']['init_ry']=scene.objects['Terrain'].worldOrientation.to_euler().y scene.objects['Terrain']['init_ry']=scene.objects['Terrain'].worldOrientation.to_euler().y
scene.objects['Terrain']['init_rz']=scene.objects['Terrain'].worldOrientation.to_euler().z scene.objects['Terrain']['init_rz']=scene.objects['Terrain'].worldOrientation.to_euler().z
scene.objects['Commands']['init_lx']=scene.objects['Commands'].worldPosition.x
scene.objects['Commands']['init_ly']=scene.objects['Commands'].worldPosition.y
scene.objects['Commands']['init_lz']=scene.objects['Commands'].worldPosition.z
scene.objects['Points']['init_lx']=scene.objects['Points'].worldPosition.x
scene.objects['Points']['init_ly']=scene.objects['Points'].worldPosition.y
scene.objects['Points']['init_lz']=scene.objects['Points'].worldPosition.z
scene.objects['Points-Map-text']['init_relativ_lx']=scene.objects['Points-Map-text'].worldPosition.x-scene.objects['Points'].worldPosition.x scene.objects['Points-Map-text']['init_relativ_lx']=scene.objects['Points-Map-text'].worldPosition.x-scene.objects['Points'].worldPosition.x
scene.objects['Points-Map-text']['init_relativ_ly']=scene.objects['Points-Map-text'].worldPosition.y-scene.objects['Points'].worldPosition.y scene.objects['Points-Map-text']['init_relativ_ly']=scene.objects['Points-Map-text'].worldPosition.y-scene.objects['Points'].worldPosition.y
scene.objects['Points-Map-text']['init_relativ_lz']=scene.objects['Points-Map-text'].worldPosition.z-scene.objects['Points'].worldPosition.z scene.objects['Points-Map-text']['init_relativ_lz']=scene.objects['Points-Map-text'].worldPosition.z-scene.objects['Points'].worldPosition.z
@ -868,12 +879,6 @@ def manip_reset():
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['init_lx'] scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['init_lx']
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['init_ly'] scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['init_ly']
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz'] scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz']
scene.objects['Commands'].worldPosition.x = scene.objects['Commands']['init_lx']
scene.objects['Commands'].worldPosition.y = scene.objects['Commands']['init_ly']
scene.objects['Commands'].worldPosition.z = scene.objects['Commands']['init_lz']
scene.objects['Points'].worldPosition.x = scene.objects['Points']['init_lx']
scene.objects['Points'].worldPosition.y = scene.objects['Points']['init_ly']
scene.objects['Points'].worldPosition.z = scene.objects['Points']['init_lz']
applyRotationTo(scene.objects['Terrain'], 0, 0, 0) applyRotationTo(scene.objects['Terrain'], 0, 0, 0)
scene.objects['Cmd-text']['Text']= "" scene.objects['Cmd-text']['Text']= ""
@ -901,8 +906,8 @@ def manip(cont):
# Pan # Pan
if obj['manip_mode']==1: # Shift if obj['manip_mode']==1: # Shift
scene.objects['Camera'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True) scene.objects['Camera'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True)
scene.objects['Commands'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan*math.cos(50*2*math.pi*(1/360)), delta_y*sensibilite_pan*math.sin(50*2*math.pi*(1/360))), True) # scene.objects['Commands-colbox'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True)
scene.objects['Points'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan*math.cos(50*2*math.pi*(1/360)), delta_y*sensibilite_pan*math.sin(50*2*math.pi*(1/360))), True) # scene.objects['Commands-colbox'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan*math.cos(50*2*math.pi*(1/360)), delta_y*sensibilite_pan*math.sin(50*2*math.pi*(1/360))), True)
if scene.objects['Mouse_main']['mouse_graphic']: if scene.objects['Mouse_main']['mouse_graphic']:
scene.objects['Mouse_main'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True) scene.objects['Mouse_main'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True)
@ -1039,6 +1044,21 @@ def doc (cont):
scene.objects['Terrain']['manip_mode']=9 # Fenêtre modale scene.objects['Terrain']['manip_mode']=9 # Fenêtre modale
sound_play (sndbuff_book_open) sound_play (sndbuff_book_open)
manip_reset() manip_reset()
# Overlay
scene.removeOverlayCollection(bpy.data.collections['Hud'])
scene.active_camera = scene.objects["Camera-Hud"]
scene.objects['Sun'].setVisible(False,False)
scene.objects['Book-cmd'].setVisible(False,False)
scene.objects['Book-cmd'].suspendPhysics()
scene.objects['Book-cmd-Hl'].setVisible(False,False)
scene.objects['Construc'].setVisible(False,False)
scene.objects['Construc'].suspendPhysics()
scene.objects['Construc-Hl'].setVisible(False,False)
scene.objects['Book-cmd-underlay'].setVisible(True,False)
scene.objects['Construc-underlay'].setVisible(True,False)
# Book
scene.objects['Book'].worldPosition = [0, -22, 16.5] scene.objects['Book'].worldPosition = [0, -22, 16.5]
scene.objects['Book_close'].color = color_doc_chap scene.objects['Book_close'].color = color_doc_chap
scene.objects['Book_chap-screen'].color = color_doc_chap scene.objects['Book_chap-screen'].color = color_doc_chap
@ -1060,9 +1080,9 @@ def doc (cont):
scene.objects['Book_text_title'].setVisible(False,True) scene.objects['Book_text_title'].setVisible(False,True)
scene.objects['Book_text'].setVisible(False,True) scene.objects['Book_text'].setVisible(False,True)
# Activer la page screen # Activer la page screen
scene.objects["Book"]['page_chap'] = "Book_chap-screen" scene.objects['Book']['page_chap'] = "Book_chap-screen"
scene.objects["Book_chap-screen"].color = color_doc_activate scene.objects['Book_chap-screen'].color = color_doc_activate
scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition
scene.objects['Book_page_screen'].setVisible(True,True) scene.objects['Book_page_screen'].setVisible(True,True)
@ -1072,9 +1092,21 @@ def doc_close ():
scene.objects['Terrain']['manip_mode']=0 # Fenêtre modale scene.objects['Terrain']['manip_mode']=0 # Fenêtre modale
scene.objects['Book_page_screen'].setVisible(False,True) scene.objects['Book_page_screen'].setVisible(False,True)
scene.objects['Book'].setVisible(False,True) scene.objects['Book'].setVisible(False,True)
scene.objects['Book'].worldPosition = [28, 0.84549, 1.53626] # Position dans Blender [28, 0.84549, 1.53626] # scene.objects['Book'].worldPosition = [28, 0.84549, 1.53626] # Position dans Blender [28, 0.84549, 1.53626]
scene.objects['Book'].worldPosition = [28, 15, 14] # Position dans Blender [28, 0.84549, 1.53626]
scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition scene.objects['Book_page_screen'].worldPosition = scene.objects['Book'].worldPosition
# Overlay
scene.active_camera = scene.objects["Camera"]
scene.addOverlayCollection(scene.cameras['Camera-Hud'], bpy.data.collections['Hud'])
scene.objects['Sun'].setVisible(True,False)
scene.objects['Book-cmd'].setVisible(True,False)
scene.objects['Book-cmd']. restorePhysics()
scene.objects['Construc'].setVisible(True,False)
scene.objects['Construc']. restorePhysics()
scene.objects['Book-cmd-underlay'].setVisible(False,False)
scene.objects['Construc-underlay'].setVisible(False,False)
# Click pour fermer le livre # Click pour fermer le livre
def doc_close_click (cont): def doc_close_click (cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
@ -1117,7 +1149,6 @@ def about_open():
scene.objects['About_copyright'].color = color_black scene.objects['About_copyright'].color = color_black
scene.objects['About_link-git'].color= color_link scene.objects['About_link-git'].color= color_link
scene.objects['About_link-gpl'].color= color_link scene.objects['About_link-gpl'].color= color_link
# scene.objects['About_link-blender'].color= color_link
scene.objects['About_link-upbge'].color= color_link scene.objects['About_link-upbge'].color= color_link
scene.objects['About_link-kay'].color= color_link scene.objects['About_link-kay'].color= color_link
scene.objects['About_link-kenney'].color= color_link scene.objects['About_link-kenney'].color= color_link

View File

@ -408,7 +408,7 @@ def scn_tower_near(cont):
target=sensor.hitObjectList[0] target=sensor.hitObjectList[0]
target_dist = target['dist'] target_dist = target['dist']
for obj_i in sensor.hitObjectList: for obj_i in sensor.hitObjectList:
if obj_i['dist']> target_dist: if obj_i['dist']> target_dist:
target=obj_i target=obj_i
target_dist = target['dist'] target_dist = target['dist']