Ajout de la configuration de la qualité de rendu

This commit is contained in:
Philippe Roy 2022-12-24 04:43:14 +01:00
parent 587b600959
commit a58f98ced1
10 changed files with 77 additions and 12 deletions

Binary file not shown.

View File

@ -62,7 +62,6 @@ def commandes():
while fdc_f() ==False :
gyr(True)
mot_f(True)
print ("a")
mot_f(False)
gyr(False)

View File

@ -1,5 +1,5 @@
import bge # Bibliothèque Blender Game Engine (UPBGE)
from twin_threading import thread_cmd_start, thread_cmd_stop # Multithreading
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading
from twin_serial import jumeau # Liaison série
import time

View File

@ -69,6 +69,7 @@ def keyboard(cont):
screen_height = bge.render.getWindowHeight()
twin_config_tree[0][0].text=str(screen_width)
twin_config_tree[0][1].text=str(screen_height)
twin_config_tree[0][2].text=str(scene.objects['About']['quality'])
buffer_xml = ET.tostring(twin_config_tree)
with open("twin_config.xml", "wb") as f:
f.write(buffer_xml)
@ -122,6 +123,9 @@ def cmd_init():
# Fichier de config (screen size : data/config/screen/width-> [0][0].text, height-> [0][1].text)
bge.render.setWindowSize(int(twin_config_tree[0][0].text),int(twin_config_tree[0][1].text))
quality_eevee=('LOW', 'MEDIUM','HIGH','ULTRA')
scene.objects['About']['quality'] = int(twin_config_tree[0][2].text)
bpy.context.scene.eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
# Ajout du Hud
# scene.active_camera = scene.objects["Camera"]

View File

@ -1,5 +1,5 @@
import bge # Bibliothèque Blender Game Engine (UPBGE)
# import bpy # Blender
import bpy # Blender
import webbrowser
import numpy as np
@ -15,22 +15,25 @@ import numpy as np
# UPBGE scene
scene = bge.logic.getCurrentScene()
eevee = bpy.context.scene.eevee
# Colors
color_link = (0.198, 0.109, 0.8, 1) # Violet
color_link_hl = (0.8, 0.005, 0.315, 1) # Magenta
# color_link = (0.051, 0.270, 0.279,1) # Turquoise
# color_link = (0.024, 0.006, 0.8, 1) # Bleu
# color_link = (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
###############################################################################
# Interface
###############################################################################
##
# Ouverture
##
@ -42,18 +45,24 @@ def open():
scene.objects['Twins-icon'].setVisible(False,True) # Crash de UPBGE sur la supression de l'Overlay
scene.objects['Twins-text'].setVisible(False,True) # Crash de UPBGE sur la supression de l'Overlay
scene.objects['About_close'].color= color_link
# Configuration
scene.objects['About_screen-up'].color= color_link
scene.objects['About_screen-down'].color= color_link
scene.objects['About_screen']['Text']= "Taille écran : "+str(bge.render.getWindowWidth()) +" x "+str(bge.render.getWindowHeight())
scene.objects['About_quality-up'].color= color_link
scene.objects['About_quality-down'].color= color_link
quality_txt=("Basse", "Moyenne", "Haute", "Ultra")
scene.objects['About_quality']['Text']= "Qualité rendu : "+quality_txt[scene.objects['About']['quality']]
# Liens
scene.objects['About_link-git'].color= color_link
scene.objects['About_link-git']['Text'] = "Dépôt des sources" # Pas de ô dans Blender
scene.objects['About_link-gpl'].color= color_link
scene.objects['About_link-upbge'].color= color_link
scene.objects['About'].setVisible(True,True)
# Boutons < et > ("640x360", "960x540", "1280x720", "1920x1080")
# Taille de l'écran : Boutons < et > ("640x360", "960x540", "1280x720", "1920x1080")
if bge.render.getWindowWidth() <=640:
scene.objects['About_screen-down'].setVisible(False,True)
scene.objects['About_screen-down-colbox'].suspendPhysics (True)
@ -67,6 +76,20 @@ def open():
scene.objects['About_screen-up'].setVisible(True,True)
scene.objects['About_screen-up-colbox'].restorePhysics()
# Qualité du rendu : Boutons < et >
if scene.objects['About']['quality']==3:
scene.objects['About_quality-up'].setVisible(False,True)
scene.objects['About_quality-up-colbox'].suspendPhysics (True)
else:
scene.objects['About_quality-up'].setVisible(True,True)
scene.objects['About_quality-up-colbox'].restorePhysics()
if scene.objects['About']['quality']==0:
scene.objects['About_quality-down'].setVisible(False,True)
scene.objects['About_quality-down-colbox'].suspendPhysics (True)
else:
scene.objects['About_quality-down'].setVisible(True,True)
scene.objects['About_quality-down-colbox'].restorePhysics()
##
# Fermer
##
@ -109,8 +132,12 @@ def link(cont):
'About_link-upbge' : 'https://www.upbge.org'}
webbrowser.open(link [name])
###############################################################################
# Configuration
###############################################################################
##
# Configuration de l'écran
# Taille de l'écran
##
def get_near_pos(array,value):
@ -172,3 +199,38 @@ def screen_down(cont):
scene.objects['About_screen-up'].setVisible(True,True)
scene.objects['About_screen-up-colbox'].restorePhysics()
##
# Qualité du rendu
##
def quality_up(cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
quality_txt=("Basse", "Moyenne", "Haute", "Ultra")
quality_eevee=('LOW', 'MEDIUM','HIGH','ULTRA')
scene.objects['About']['quality'] +=1
scene.objects['About_quality']['Text']= "Qualité rendu : "+quality_txt[scene.objects['About']['quality']]
bpy.context.scene.eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
# Boutons < et >
if scene.objects['About']['quality']==3:
scene.objects['About_quality-up'].setVisible(False,True)
scene.objects['About_quality-up-colbox'].suspendPhysics (True)
if scene.objects['About']['quality']==1:
scene.objects['About_quality-down'].setVisible(True,True)
scene.objects['About_quality-down-colbox'].restorePhysics()
def quality_down(cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
quality_txt=("Basse", "Moyenne", "Haute", "Ultra")
quality_eevee=('LOW', 'MEDIUM','HIGH','ULTRA')
scene.objects['About']['quality'] -=1
scene.objects['About_quality']['Text']= "Qualité rendu : "+quality_txt[scene.objects['About']['quality']]
bpy.context.scene.eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
# Boutons < et >
if scene.objects['About']['quality']==0:
scene.objects['About_quality-down'].setVisible(False,True)
scene.objects['About_quality-down-colbox'].suspendPhysics (True)
if scene.objects['About']['quality']==2:
scene.objects['About_quality-up'].setVisible(True,True)
scene.objects['About_quality-up-colbox'].restorePhysics()

View File

@ -1,6 +1,7 @@
<data>
<screen>
<width>1480</width>
<height>832</height>
<width>1458</width>
<height>820</height>
<quality>1</quality>
</screen>
</data>

View File

@ -163,7 +163,6 @@ card_python_text=""" Le Python est un langage de programmation \n interprété o
card_python_url=[["python.org","https://python.org"], ["AFPy","https://www.afpy.org"]]
card_description.update({"python-card" : [card_python_title, card_python_text, card_python_url]})
###############################################################################
# Interface
###############################################################################

Binary file not shown.

View File

@ -1,5 +1,5 @@
import bge # Bibliothèque Blender Game Engine (UPBGE)
from twin_threading import thread_cmd_start, thread_cmd_stop # Multithreading
from twin_threading import thread_cmd_start, thread_cmd_stop, fin # Multithreading
from twin_serial import jumeau # Liaison série
import time