diff --git a/ropy-32.blend b/ropy-32.blend index 80ea8b8..f0ce265 100644 Binary files a/ropy-32.blend and b/ropy-32.blend differ diff --git a/rp.py b/rp.py index 82d243a..62a717f 100644 --- a/rp.py +++ b/rp.py @@ -3,11 +3,11 @@ import bpy # Blender import aud # Sounds import math import mathutils -import numpy as np +# import numpy as np import time import sys import os -import webbrowser # Lien internet +# import webbrowser # Lien internet import threading # Multithreading import subprocess # Multiprocessus import xml.etree.ElementTree as ET # Creating/parsing XML file @@ -25,7 +25,7 @@ import rp_about # About # @project: Ropy (Blender-EduTech) # @lang: fr # @authors: Philippe Roy -# @copyright: Copyright (C) 2020-2022 Philippe Roy +# @copyright: Copyright (C) 2020-2023 Philippe Roy # @license: GNU GPL # # Ropy est destiné à la découverte de la programmation procédurale et du language Python. @@ -413,10 +413,17 @@ def cmd_init(cont): if cont.sensors['Init'].positive == False: # 1 seule fois return False - # Taille de la fenêtre - # Read config (screen size : data/config/screen/width-> [0][3][0].text) + # Configuration de l'écran bge.render.setWindowSize(int(rp_config_tree[0][3][0].text),int(rp_config_tree[0][3][1].text)) - + quality_eevee=('NOSMAA', 'LOW', 'MEDIUM','HIGH','ULTRA') + scene.objects['About']['quality'] = int(rp_config_tree[0][3][2].text) + if quality_eevee[scene.objects['About']['quality']] == 'NOSMAA': + eevee.smaa_quality= 'LOW' + eevee.use_eevee_smaa = False + else: + eevee.use_eevee_smaa = True + eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']] + # UI : Commands scene.objects['Run-Hl'].setVisible(False,False) scene.objects['Pause'].setVisible(False,False) @@ -708,10 +715,19 @@ def mode(cont): rp_config_tree[0][2][0].text=str(scene.objects['Camera']['current_lx']) rp_config_tree[0][2][1].text=str(scene.objects['Camera']['current_ly']) rp_config_tree[0][2][2].text=str(scene.objects['Camera']['current_lz']) - # print ("Fin :", scene.objects['Camera'].worldPosition.x, scene.objects['Camera'].worldPosition.y, scene.objects['Camera'].worldPosition.z) + + # Maj du fichier de config (screen size : data/config/screen/width, height, quality-> [0][3][0].text, [0][3][1].text, [0][3][2].text) + screen_width = bge.render.getWindowWidth() + screen_height = bge.render.getWindowHeight() + rp_config_tree[0][3][0].text=str(screen_width) + rp_config_tree[0][3][1].text=str(screen_height) + rp_config_tree[0][3][2].text=str(scene.objects['About']['quality']) + buffer_xml = ET.tostring(rp_config_tree) with open("rp_config.xml", "wb") as f: f.write(buffer_xml) + + # Sortir bge.logic.endGame() # Fenêtre modale (inhibition des touches hors ESC) @@ -1415,78 +1431,78 @@ def about_close_click(cont): sound_play (snd_close) about_close() -## -# Configuration de l'écran -## +# ## +# # Configuration de l'écran +# ## -def get_near_pos(array,value): - array = np.asarray(array) - idx = (np.abs(array-value)).argmin() - return idx +# def get_near_pos(array,value): +# array = np.asarray(array) +# idx = (np.abs(array-value)).argmin() +# return idx -def about_screen_up(cont): - if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : - screen_width_mode=[640, 960, 1280, 1920] - screen_height_mode=[360, 540, 720,1080] - screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"] - i = get_near_pos(screen_width_mode, bge.render.getWindowWidth()) - if i>=0 and i<3 : - screen_width=screen_width_mode[i+1] - screen_height=screen_height_mode[i+1] - scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(screen_width) +" x "+str(screen_height) - bge.render.setWindowSize(screen_width,screen_height) +# def about_screen_up(cont): +# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : +# screen_width_mode=[640, 960, 1280, 1920] +# screen_height_mode=[360, 540, 720,1080] +# screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"] +# i = get_near_pos(screen_width_mode, bge.render.getWindowWidth()) +# if i>=0 and i<3 : +# screen_width=screen_width_mode[i+1] +# screen_height=screen_height_mode[i+1] +# scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(screen_width) +" x "+str(screen_height) +# bge.render.setWindowSize(screen_width,screen_height) - # Boutons < et > - if screen_width <=640: - scene.objects['About_screen-down'].setVisible(False,True) - scene.objects['About_screen-down-colbox'].suspendPhysics (True) - else: - scene.objects['About_screen-down'].setVisible(True,True) - scene.objects['About_screen-down-colbox'].restorePhysics() - if screen_width >= 1920: - scene.objects['About_screen-up'].setVisible(False,True) - scene.objects['About_screen-up-colbox'].suspendPhysics (True) - else: - scene.objects['About_screen-up'].setVisible(True,True) - scene.objects['About_screen-up-colbox'].restorePhysics() +# # Boutons < et > +# if screen_width <=640: +# scene.objects['About_screen-down'].setVisible(False,True) +# scene.objects['About_screen-down-colbox'].suspendPhysics (True) +# else: +# scene.objects['About_screen-down'].setVisible(True,True) +# scene.objects['About_screen-down-colbox'].restorePhysics() +# if screen_width >= 1920: +# scene.objects['About_screen-up'].setVisible(False,True) +# scene.objects['About_screen-up-colbox'].suspendPhysics (True) +# else: +# scene.objects['About_screen-up'].setVisible(True,True) +# scene.objects['About_screen-up-colbox'].restorePhysics() - # Maj du fichier de config (screen size : data/config/screen/width-> [0][3][0].text) - rp_config_tree[0][3][0].text=str(screen_width) - rp_config_tree[0][3][1].text=str(screen_height) - buffer_xml = ET.tostring(rp_config_tree) - with open("rp_config.xml", "wb") as f: - f.write(buffer_xml) +# # Maj du fichier de config (screen size : data/config/screen/width-> [0][3][0].text) +# rp_config_tree[0][3][0].text=str(screen_width) +# rp_config_tree[0][3][1].text=str(screen_height) +# buffer_xml = ET.tostring(rp_config_tree) +# with open("rp_config.xml", "wb") as f: +# f.write(buffer_xml) -def about_screen_down(cont): - if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : - screen_width_mode=[640, 960, 1280, 1920] - screen_height_mode=[360, 540, 720,1080] - screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"] - i = get_near_pos(screen_width_mode, bge.render.getWindowWidth()) - if i>0 and i<=3 : - screen_width=screen_width_mode[i-1] - screen_height=screen_height_mode[i-1] - scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(screen_width) +" x "+str(screen_height) - bge.render.setWindowSize(screen_width,screen_height) +# def about_screen_down(cont): +# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : +# screen_width_mode=[640, 960, 1280, 1920] +# screen_height_mode=[360, 540, 720,1080] +# screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"] +# i = get_near_pos(screen_width_mode, bge.render.getWindowWidth()) +# if i>0 and i<=3 : +# screen_width=screen_width_mode[i-1] +# screen_height=screen_height_mode[i-1] +# scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(screen_width) +" x "+str(screen_height) +# bge.render.setWindowSize(screen_width,screen_height) - # Boutons < et > - if screen_width <=640: - scene.objects['About_screen-down'].setVisible(False,True) - scene.objects['About_screen-down-colbox'].suspendPhysics (True) - else: - scene.objects['About_screen-down'].setVisible(True,True) - scene.objects['About_screen-down-colbox'].restorePhysics() - if screen_width >= 1920: - scene.objects['About_screen-up'].setVisible(False,True) - scene.objects['About_screen-up-colbox'].suspendPhysics (True) - else: - scene.objects['About_screen-up'].setVisible(True,True) - scene.objects['About_screen-up-colbox'].restorePhysics() +# # Boutons < et > +# if screen_width <=640: +# scene.objects['About_screen-down'].setVisible(False,True) +# scene.objects['About_screen-down-colbox'].suspendPhysics (True) +# else: +# scene.objects['About_screen-down'].setVisible(True,True) +# scene.objects['About_screen-down-colbox'].restorePhysics() +# if screen_width >= 1920: +# scene.objects['About_screen-up'].setVisible(False,True) +# scene.objects['About_screen-up-colbox'].suspendPhysics (True) +# else: +# scene.objects['About_screen-up'].setVisible(True,True) +# scene.objects['About_screen-up-colbox'].restorePhysics() - # Maj du fichier de config (screen size : data/config/screen/width-> [0][3][0].text) - rp_config_tree[0][3][0].text=str(screen_width) - rp_config_tree[0][3][1].text=str(screen_height) - buffer_xml = ET.tostring(rp_config_tree) - with open("rp_config.xml", "wb") as f: - f.write(buffer_xml) +# # Maj du fichier de config (screen size : data/config/screen/width-> [0][3][0].text) +# rp_config_tree[0][3][0].text=str(screen_width) +# rp_config_tree[0][3][1].text=str(screen_height) +# buffer_xml = ET.tostring(rp_config_tree) +# with open("rp_config.xml", "wb") as f: +# f.write(buffer_xml) diff --git a/rp_about.py b/rp_about.py index 86edc0c..56d4142 100644 --- a/rp_about.py +++ b/rp_about.py @@ -1,4 +1,6 @@ import bge # Bibliothèque Blender Game Engine (UPBGE) +import bpy # Blender +import sys import webbrowser ############################################################################### @@ -7,11 +9,13 @@ import webbrowser # @project: Ropy (Blender-EduTech) # @lang: fr # @authors: Philippe Roy -# @copyright: Copyright (C) 2022 Philippe Roy +# @copyright: Copyright (C) 2022-2023 Philippe Roy # @license: GNU GPL ############################################################################### +# UPBGE scene scene = bge.logic.getCurrentScene() +eevee = bpy.context.scene.eevee # Colors color_link = (0, 1, 0.857,1) # Turquoise @@ -58,10 +62,19 @@ def open(): # Configuration scene.objects['About_screen-up'].color= color_link scene.objects['About_screen-down'].color= color_link - scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(bge.render.getWindowWidth()) +" x "+str(bge.render.getWindowHeight()) + 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=("Inconvenant", "Basse", "Moyenne", "Haute", "Épique") + scene.objects['About_quality']['Text']= "Qualité : "+quality_txt[scene.objects['About']['quality']] + + # # Configuration + # scene.objects['About_screen-up'].color= color_link + # scene.objects['About_screen-down'].color= color_link # scene.objects['About_screen']['Text']= "SCREEN SIZE : "+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 + # # scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(bge.render.getWindowWidth()) +" x "+str(bge.render.getWindowHeight()) # Liens scene.objects['About_link-git'].color= color_link @@ -74,7 +87,7 @@ def open(): scene.objects['About']['timer'] = 0 scene.objects['About']['anim'] = 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) @@ -88,6 +101,34 @@ 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']==4: + 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() + + # # 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) + # else: + # scene.objects['About_screen-down'].setVisible(True,True) + # scene.objects['About_screen-down-colbox'].restorePhysics() + # if bge.render.getWindowWidth() >= 1920: + # scene.objects['About_screen-up'].setVisible(False,True) + # scene.objects['About_screen-up-colbox'].suspendPhysics (True) + # else: + # scene.objects['About_screen-up'].setVisible(True,True) + # scene.objects['About_screen-up-colbox'].restorePhysics() + ## # Animation de l'ouverture ## @@ -193,3 +234,128 @@ def credits_link(cont): obj = cont.owner idx=int(obj.name[12:-7]) webbrowser.open(credits_description[list(credits_description)[idx-1]][2]) + +############################################################################### +# Configuration +############################################################################### + +## +# Taille de l'écran +## + +def get_near_pos(value_list,value): + delta=[] + for i in range (len(value_list)): + delta.append(abs(value-value_list[i])) + return delta.index(min(delta)) + +# Taille de l'écran + +def screen_up(cont): + if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : + screen_width_mode=[640, 960, 1280, 1920] + screen_height_mode=[360, 540, 720,1080] + screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"] + i = get_near_pos(screen_width_mode, bge.render.getWindowWidth()) + if i>=0 and i<3 : + if bge.render.getWindowWidth() + if screen_width <=640: + scene.objects['About_screen-down'].setVisible(False,True) + scene.objects['About_screen-down-colbox'].suspendPhysics (True) + else: + scene.objects['About_screen-down'].setVisible(True,True) + scene.objects['About_screen-down-colbox'].restorePhysics() + if screen_width >= 1920: + scene.objects['About_screen-up'].setVisible(False,True) + scene.objects['About_screen-up-colbox'].suspendPhysics (True) + else: + scene.objects['About_screen-up'].setVisible(True,True) + scene.objects['About_screen-up-colbox'].restorePhysics() + +# Taille de l'écran - +def screen_down(cont): + if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : + screen_width_mode=[640, 960, 1280, 1920] + screen_height_mode=[360, 540, 720,1080] + screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"] + i = get_near_pos(screen_width_mode, bge.render.getWindowWidth()) + if i>0 and i<=3 : + if bge.render.getWindowWidth()>screen_width_mode[i]: + screen_width=screen_width_mode[i] + screen_height=screen_height_mode[i] + else: + screen_width=screen_width_mode[i-1] + screen_height=screen_height_mode[i-1] + scene.objects['About_screen']['Text']= "Taille écran : "+str(screen_width) +" x "+str(screen_height) + bge.render.setWindowSize(screen_width,screen_height) + + # Boutons < et > + if screen_width <=640: + scene.objects['About_screen-down'].setVisible(False,True) + scene.objects['About_screen-down-colbox'].suspendPhysics (True) + else: + scene.objects['About_screen-down'].setVisible(True,True) + scene.objects['About_screen-down-colbox'].restorePhysics() + if screen_width >= 1920: + scene.objects['About_screen-up'].setVisible(False,True) + scene.objects['About_screen-up-colbox'].suspendPhysics (True) + else: + 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=("Inconvenant", "Basse", "Moyenne", "Haute", "Épique") + quality_eevee=('NOSMAA', 'LOW', 'MEDIUM','HIGH','ULTRA') + scene.objects['About']['quality'] +=1 + scene.objects['About_quality']['Text']= "Qualité : "+quality_txt[scene.objects['About']['quality']] + if quality_eevee[scene.objects['About']['quality']] == 'NOSMAA': + eevee.smaa_quality= 'LOW' + eevee.use_eevee_smaa = False + else: + eevee.use_eevee_smaa = True + # print (sys.platform) + if sys.platform=="linux": # Plantage sur Windows + eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']] + + # Boutons < et > + if scene.objects['About']['quality']==4: + 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=("Inconvenant", "Basse", "Moyenne", "Haute", "Épique") + quality_eevee=('NOSMAA', 'LOW', 'MEDIUM','HIGH','ULTRA') + scene.objects['About']['quality'] -=1 + scene.objects['About_quality']['Text']= "Qualité : "+quality_txt[scene.objects['About']['quality']] + if quality_eevee[scene.objects['About']['quality']] == 'NOSMAA': + eevee.smaa_quality= 'LOW' + eevee.use_eevee_smaa = False + else: + eevee.use_eevee_smaa = True + if sys.platform=="Linux": # Plantage sur Windows + 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']==3: + scene.objects['About_quality-up'].setVisible(True,True) + scene.objects['About_quality-up-colbox'].restorePhysics() diff --git a/rp_cmd-bak.py b/rp_cmd-bak.py new file mode 100644 index 0000000..80f7382 --- /dev/null +++ b/rp_cmd-bak.py @@ -0,0 +1,42 @@ +import time +from rp_lib import * # Bibliothèque Ropy + +############################################################################### +# rp_cmd.py +# @title: Commandes pour le Rover Ropy +# @project: Ropy (Blender-EduTech) +############################################################################### + +############################################################################### +# Initialisation du niveau : +# Niveau 1 : Les premiers pas de Ropy +# Niveau 2 : Ma première fonction +# Niveau 3 : Sécuriser Ropy +# Niveau 4 : Partir au bout du monde +# Niveau 5 : Faire face à l'inconnu +# Niveau 6 : Se rendre utile +############################################################################### + +############################################################################### +# Fonctions +############################################################################### + +############################################################################### +# Commandes +############################################################################### + +def commandes(): + + # Ecrire votre code ici ... + + rp_fin() # A garder + +############################################################################### +# En: External call << DONT CHANGE THIS SECTION >> +# Fr: Appel externe << NE PAS MODIFIER CETTE SECTION >> +############################################################################### + +if __name__=='start': + thread_cmd_start(commandes) +if __name__=='stop': + thread_cmd_stop() diff --git a/rp_cmd.py b/rp_cmd.py index c2e3779..2ff5b25 100644 --- a/rp_cmd.py +++ b/rp_cmd.py @@ -2,7 +2,7 @@ import time from rp_lib import * # Bibliothèque Ropy ############################################################################### -# rp_cmd-microbit.py +# rp_cmd.py # @title: Commandes pour le Rover Ropy # @project: Ropy (Blender-EduTech) ############################################################################### @@ -27,7 +27,6 @@ from rp_lib import * # Bibliothèque Ropy def commandes(): - # Ecrire votre code ici ... print ('okok') rp_gauche() rp_avancer() diff --git a/rp_config-bak.xml b/rp_config-bak.xml new file mode 100644 index 0000000..5d42556 --- /dev/null +++ b/rp_config-bak.xml @@ -0,0 +1,26 @@ + + + 1.0 + False + + 0.0057830810546875 + -26.440298080444336 + 20.22315788269043 + + + 1280 + 720 + 1 + + + + 1 + 1 + + + False + False + False + False + + diff --git a/rp_config.xml b/rp_config.xml index aae8bf8..670a9a1 100644 --- a/rp_config.xml +++ b/rp_config.xml @@ -8,8 +8,9 @@ 20.22315788269043 - 1280 - 720 + 1632 + 918 + 1 diff --git a/rp_doc.py b/rp_doc.py index 1293631..4b82ae5 100644 --- a/rp_doc.py +++ b/rp_doc.py @@ -8,7 +8,7 @@ import webbrowser # @project: Ropy (Blender-EduTech) # @lang: fr # @authors: Philippe Roy -# @copyright: Copyright (C) 2020-2022 Philippe Roy +# @copyright: Copyright (C) 2020-2023 Philippe Roy # @license: GNU GPL # # Ropy est destiné à la découverte de la programmation procédurale et du language Python. diff --git a/rp_lib.py b/rp_lib.py index a6e83b7..979f60c 100644 --- a/rp_lib.py +++ b/rp_lib.py @@ -19,7 +19,7 @@ import rp_map1 as rp_map # Map definition # @project: Ropy (Blender-EduTech) # @lang: fr # @authors: Philippe Roy -# @copyright: Copyright (C) 2020-2022 Philippe Roy +# @copyright: Copyright (C) 2020-2023 Philippe Roy # @license: GNU GPL # # Bibliothèque des actions du robot