Readme update

This commit is contained in:
Philippe Roy 2022-04-12 01:45:23 +02:00
parent 70c49c0ae8
commit 9915374674
2 changed files with 62 additions and 42 deletions

Binary file not shown.

102
ct.py
View File

@ -467,12 +467,15 @@ def terrain_speed (obj):
# Page de fin # Page de fin
def endbanner_hl(cont): def endbanner_hl(cont):
if cont.sensors['MO'].status == JUST_ACTIVATED: if cont.sensors['MO'].status == JUST_ACTIVATED:
mouse_up() if scene.objects['Mouse_main']['mouse_graphic']:
mouse_up()
scene.objects['Endbanner'].color = color_white scene.objects['Endbanner'].color = color_white
scene.objects['Endbanner_wave'].color = color_white scene.objects['Endbanner_wave'].color = color_white
scene.objects['Endbanner_points'].color = color_white scene.objects['Endbanner_points'].color = color_white
scene.objects['Endbanner_ok'].color = color_white scene.objects['Endbanner_ok'].color = color_white
if cont.sensors['MO'].status == JUST_RELEASED: if cont.sensors['MO'].status == JUST_RELEASED:
if scene.objects['Mouse_main']['mouse_graphic']:
mouse_down()
scene.objects['Endbanner'].color = color_endbanner_bluelight scene.objects['Endbanner'].color = color_endbanner_bluelight
scene.objects['Endbanner_wave'].color = color_black scene.objects['Endbanner_wave'].color = color_black
scene.objects['Endbanner_points'].color = color_black scene.objects['Endbanner_points'].color = color_black
@ -516,13 +519,17 @@ def cmd_init():
# UI : Mouse # UI : Mouse
# Window size : 738.5 415.5 # Window size : 738.5 415.5
bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2)) if scene.objects['Mouse_main']['mouse_graphic']:
bge.render.showMouse(scene.objects['Commands']['debug_mouse']) bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2))
scene.objects['Mouse_main'].worldPosition = [0.07, -8.11, 4.71035] # Vielle version : [0.118161, -8.24305, 4.71035] ; [0, -3.5, 2], [0, -8, 6] bge.render.showMouse(scene.objects['Commands']['debug_mouse'])
scene.objects['Mouse_main'].worldScale=[30, 30, 30] scene.objects['Mouse_main'].worldPosition = [0.07, -8.11, 4.71035] # Vielle version : [0.118161, -8.24305, 4.71035] ; [0, -3.5, 2], [0, -8, 6]
scene.objects['Mouse_main']['past_x']=0 scene.objects['Mouse_main'].worldScale=[30, 30, 30]
scene.objects['Mouse_main']['past_y']=0 scene.objects['Mouse_main']['past_x']=0
scene.objects['Mouse_main']['mouse_up']=0 scene.objects['Mouse_main']['past_y']=0
scene.objects['Mouse_main']['mouse_up']=0
else:
scene.objects['Mouse_main'].setVisible(False,False)
bge.render.showMouse(True)
# scene.objects['Raz-vue-Hl'].setVisible(False,False) # scene.objects['Raz-vue-Hl'].setVisible(False,False)
# scene.objects['Aide-cmd-Hl'].setVisible(False,False) # scene.objects['Aide-cmd-Hl'].setVisible(False,False)
@ -645,11 +652,12 @@ def mode(cont):
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz'] scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['init_lz']
applyRotationTo(scene.objects['Terrain'], 0, 0, 0) applyRotationTo(scene.objects['Terrain'], 0, 0, 0)
bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2)) if scene.objects['Mouse_main']['mouse_graphic']:
scene.objects['Mouse_main'].worldPosition = [0.07, -8.11, 4.71035] # Vielle version : [0.118161, -8.24305, 4.71035] ; [0, -3.5, 2], [0, -8, 6] bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2))
scene.objects['Mouse_main'].worldScale=[30, 30, 30] scene.objects['Mouse_main'].worldPosition = [0.07, -8.11, 4.71035] # Vielle version : [0.118161, -8.24305, 4.71035] ; [0, -3.5, 2], [0, -8, 6]
scene.objects['Mouse_main']['past_x']=0 scene.objects['Mouse_main'].worldScale=[30, 30, 30]
scene.objects['Mouse_main']['past_y']=0 scene.objects['Mouse_main']['past_x']=0
scene.objects['Mouse_main']['past_y']=0
# Touche F5 -> Run et Pause # Touche F5 -> Run et Pause
if JUST_ACTIVATED in keyboard.inputs[bge.events.F5KEY].queue: if JUST_ACTIVATED in keyboard.inputs[bge.events.F5KEY].queue:
@ -748,20 +756,23 @@ 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['Mouse_main'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True) if scene.objects['Mouse_main']['mouse_graphic']:
scene.objects['Mouse_main'].applyMovement((delta_x*-sensibilite_pan, delta_y*sensibilite_pan, 0), True)
# Zoom FIXME : marche pas au niveau de la souris # Zoom FIXME : marche pas au niveau de la souris
if obj['manip_mode']==2: # Ctrl if obj['manip_mode']==2: # Ctrl
position_scale_x = 0.0005 if scene.objects['Mouse_main']['mouse_graphic']:
position_scale_y = position_scale_x position_scale_x = 0.0005
mouse_x=scene.objects['Mouse_main'].sensors["Mouse"].position[0]-int(bge.render.getWindowWidth() / 2) position_scale_y = position_scale_x
mouse_y=scene.objects['Mouse_main'].sensors["Mouse"].position[1]-int(bge.render.getWindowHeight() / 2) mouse_x=scene.objects['Mouse_main'].sensors["Mouse"].position[0]-int(bge.render.getWindowWidth() / 2)
distance_cam_past= math.sqrt(scene.objects['Camera']['past_ly']**2+scene.objects['Camera']['past_lz']**2) mouse_y=scene.objects['Mouse_main'].sensors["Mouse"].position[1]-int(bge.render.getWindowHeight() / 2)
distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2)) distance_cam_past= math.sqrt(scene.objects['Camera']['past_ly']**2+scene.objects['Camera']['past_lz']**2)
size_scale = (distance_cam/distance_cam_past) * 0.23 distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2))
size_scale = (distance_cam/distance_cam_past) * 0.23
scene.objects['Camera'].applyMovement((0, 0, (delta_x+delta_y)*sensibilite_zoom), True) scene.objects['Camera'].applyMovement((0, 0, (delta_x+delta_y)*sensibilite_zoom), True)
scene.objects['Mouse_main'].applyMovement((mouse_x*(delta_x+delta_y)*sensibilite_zoom*position_scale_x, -mouse_y*(delta_x+delta_y)*sensibilite_zoom*position_scale_y, 0), True) if scene.objects['Mouse_main']['mouse_graphic']:
scene.objects['Mouse_main'].worldScale *= (delta_x+delta_y)*sensibilite_zoom*size_scale scene.objects['Mouse_main'].applyMovement((mouse_x*(delta_x+delta_y)*sensibilite_zoom*position_scale_x, -mouse_y*(delta_x+delta_y)*sensibilite_zoom*position_scale_y, 0), True)
scene.objects['Mouse_main'].worldScale *= (delta_x+delta_y)*sensibilite_zoom*size_scale
scene.objects['Camera']['past_ly']=scene.objects['Camera'].worldPosition.y scene.objects['Camera']['past_ly']=scene.objects['Camera'].worldPosition.y
scene.objects['Camera']['past_lz']=scene.objects['Camera'].worldPosition.z scene.objects['Camera']['past_lz']=scene.objects['Camera'].worldPosition.z
@ -771,29 +782,34 @@ def manip_wheel(cont):
if scene.objects['Terrain']['manip_mode']!=9: # Fenêtre modale if scene.objects['Terrain']['manip_mode']!=9: # Fenêtre modale
obj = cont.owner obj = cont.owner
sensibilite_wheel = 5 # Base : 20 sensibilite_wheel = 5 # Base : 20
position_scale_x = 0.0005 if scene.objects['Mouse_main']['mouse_graphic']:
position_scale_y = position_scale_x position_scale_x = 0.0005
mouse_x=scene.objects['Mouse_main'].sensors["Mouse"].position[0]-int(bge.render.getWindowWidth() / 2) position_scale_y = position_scale_x
mouse_y=scene.objects['Mouse_main'].sensors["Mouse"].position[1]-int(bge.render.getWindowHeight() / 2) mouse_x=scene.objects['Mouse_main'].sensors["Mouse"].position[0]-int(bge.render.getWindowWidth() / 2)
distance_cam_past = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2)) mouse_y=scene.objects['Mouse_main'].sensors["Mouse"].position[1]-int(bge.render.getWindowHeight() / 2)
# size_scale = (distance_cam/distance_cam_past) * 0.23 distance_cam_past = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2))
size_scale = 0.2 # size_scale = (distance_cam/distance_cam_past) * 0.23
# size_scale = 0.23 size_scale = 0.2
# size_scale = 0.23
if cont.sensors['WheelUp'].positive: if cont.sensors['WheelUp'].positive:
scene.objects['Camera'].applyMovement((0, 0, -sensibilite_wheel), True) scene.objects['Camera'].applyMovement((0, 0, -sensibilite_wheel), True)
distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2)) if scene.objects['Mouse_main']['mouse_graphic']:
scene.objects['Mouse_main'].applyMovement((-mouse_x*sensibilite_wheel*position_scale_x, mouse_y*sensibilite_wheel*position_scale_y, 0), True) distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2))
scene.objects['Mouse_main'].worldScale *= sensibilite_wheel* (distance_cam/distance_cam_past) *size_scale scene.objects['Mouse_main'].applyMovement((-mouse_x*sensibilite_wheel*position_scale_x, mouse_y*sensibilite_wheel*position_scale_y, 0), True)
scene.objects['Mouse_main'].worldScale *= sensibilite_wheel* (distance_cam/distance_cam_past) *size_scale
elif cont.sensors['WheelDown'].positive: elif cont.sensors['WheelDown'].positive:
scene.objects['Camera'].applyMovement((0, 0, sensibilite_wheel), True) scene.objects['Camera'].applyMovement((0, 0, sensibilite_wheel), True)
distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2)) if scene.objects['Mouse_main']['mouse_graphic']:
scene.objects['Mouse_main'].applyMovement((mouse_x*sensibilite_wheel*position_scale_x, -mouse_y*sensibilite_wheel*position_scale_y, 0), True) distance_cam = math.sqrt((scene.objects['Camera'].worldPosition.y**2+scene.objects['Camera'].worldPosition.z**2))
scene.objects['Mouse_main'].worldScale /= sensibilite_wheel* (distance_cam_past/distance_cam) *size_scale scene.objects['Mouse_main'].applyMovement((mouse_x*sensibilite_wheel*position_scale_x, -mouse_y*sensibilite_wheel*position_scale_y, 0), True)
scene.objects['Mouse_main'].worldScale /= sensibilite_wheel* (distance_cam_past/distance_cam) *size_scale
else: else:
return return
# Icone de la souris # Icone de la souris
def mouse(cont): def mouse(cont):
if scene.objects['Mouse_main']['mouse_graphic']==False:
return
obj = cont.owner obj = cont.owner
# Ancienne version basée sur la position de la caméra # Ancienne version basée sur la position de la caméra
@ -896,7 +912,8 @@ def about_hl(cont):
# decal = 18 # decal = 18
# size_scale = 0.2 # size_scale = 0.2
if cont.sensors['MO'].status == JUST_ACTIVATED: if cont.sensors['MO'].status == JUST_ACTIVATED:
mouse_up() if scene.objects['Mouse_main']['mouse_graphic']:
mouse_up()
# # print (scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1]) # # print (scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1])
# vect=scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1] # vect=scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1]
# dist_past= scene.objects['Mouse_main'].getDistanceTo(scene.objects['Camera']) # dist_past= scene.objects['Mouse_main'].getDistanceTo(scene.objects['Camera'])
@ -911,7 +928,8 @@ def about_hl(cont):
if cont.sensors['MO'].status == JUST_RELEASED: if cont.sensors['MO'].status == JUST_RELEASED:
# print("about_hl R avant", scene.objects['Mouse_main'].worldPosition) # print("about_hl R avant", scene.objects['Mouse_main'].worldPosition)
mouse_down() if scene.objects['Mouse_main']['mouse_graphic']:
mouse_down()
# print (scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1]) # print (scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1])
# vect=scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1] # vect=scene.objects['Mouse_main'].getVectTo(scene.objects['Camera'])[1]
# dist_past= scene.objects['Mouse_main'].getDistanceTo(scene.objects['Camera']) # dist_past= scene.objects['Mouse_main'].getDistanceTo(scene.objects['Camera'])
@ -958,10 +976,12 @@ def about_link_hl(cont):
obj = cont.owner obj = cont.owner
name=obj.name[:-7] name=obj.name[:-7]
scene.objects[name].color = color_link_hl scene.objects[name].color = color_link_hl
mouse_up() if scene.objects['Mouse_main']['mouse_graphic']:
mouse_up()
if cont.sensors['MO'].status == JUST_RELEASED : if cont.sensors['MO'].status == JUST_RELEASED :
obj = cont.owner obj = cont.owner
name=obj.name[:-7] name=obj.name[:-7]
scene.objects[name].color = color_link scene.objects[name].color = color_link
mouse_down() if scene.objects['Mouse_main']['mouse_graphic']:
mouse_down()