pymultilame
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
pymultilame [2018/08/27 11:10] – serge | pymultilame [2021/08/21 15:47] – ↷ Liens modifiés en raison d'un déplacement. 216.244.66.228 | ||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
</ | </ | ||
+ | =====Les sources sur GitHub===== | ||
+ | * **[[https:// | ||
===== pymultilame ===== | ===== pymultilame ===== | ||
Ligne 10: | Ligne 12: | ||
==== Des scripts python pour les tâches répétitives. ==== | ==== Des scripts python pour les tâches répétitives. ==== | ||
- | < | + | Ce module propose les outils les plus courrant que j' |
- | Ce module propose les outils les plus courrant que j' | + | |
- | à utiliser en import ou en recopiant des bouts de code. | + | |
Ce module est une amélioration de | Ce module est une amélioration de | ||
- | [mylabotools](https:// | + | |
+ | * [[https:// | ||
qui n'est plus maintenu. | qui n'est plus maintenu. | ||
- | </ | + | |
- | === Comprend les rubriques | + | === Rubriques proposées |
* Blender: Des scripts spécifiques pour le Blender Game Engine 2.7x et qui ne peuvent tourner que dans Blender | * Blender: Des scripts spécifiques pour le Blender Game Engine 2.7x et qui ne peuvent tourner que dans Blender | ||
Ligne 29: | Ligne 31: | ||
=== Installation de Twisted pour python 3.x === | === Installation de Twisted pour python 3.x === | ||
- | * [[https:// | + | * [[archives: |
< | < | ||
sudo pip3 install twisted | sudo pip3 install twisted | ||
</ | </ | ||
+ | |||
=== Installation de pymultilame === | === Installation de pymultilame === | ||
- | * [[https:// | + | * [[creer_son_propre_package_python|Python: |
< | < | ||
sudo pip3 install -e git+https:// | sudo pip3 install -e git+https:// | ||
</ | </ | ||
+ | |||
Mise à jour: | Mise à jour: | ||
Ligne 46: | Ligne 50: | ||
sudo pip3 install --upgrade git+https:// | sudo pip3 install --upgrade git+https:// | ||
</ | </ | ||
+ | |||
==== Utilisation ==== | ==== Utilisation ==== | ||
<code python> | <code python> | ||
- | from pymultilame.blendertools import scene_change | + | # Imports en python3 |
from pymultilame import HttpDownload | from pymultilame import HttpDownload | ||
+ | from pymultilame import MyTools | ||
+ | from pymultilame import TcpClient3 | ||
+ | from pymultilame import MyConfig | ||
+ | from pymultilame import get_my_ip | ||
+ | from pymultilame import Multicast | ||
+ | from pymultilame import UdpClient | ||
+ | from pymultilame import PileFIFO | ||
+ | from pymultilame import Multicast | ||
+ | |||
+ | from pymultilame import Tempo | ||
+ | from pymultilame import EasyAudio | ||
+ | from pymultilame import TextureChange | ||
+ | |||
+ | from pymultilame import scene_change, | ||
+ | from pymultilame import get_all_objects, | ||
+ | |||
+ | |||
+ | # Imports en python2 | ||
+ | |||
+ | from pymultilame.myconfig2 import MyConfig2 | ||
+ | from pymultilame.tcpclient2 import TcpClient2 | ||
</ | </ | ||
+ | |||
==== Licence ==== | ==== Licence ==== | ||
Ligne 60: | Ligne 87: | ||
voir le fichier LICENSE | voir le fichier LICENSE | ||
- | ==== Documentation ==== | + | =====Documentation |
+ | Le script qui génère cette doc est dans le module pymultilame. | ||
+ | ====blendergetobject==== | ||
+ | <code txt> | ||
+ | FUNCTIONS | ||
+ | get_all_objects() | ||
+ | Trouve tous les objets des scènes actives | ||
+ | Retourne un dict {nom de l' | ||
+ | |||
+ | get_all_scenes() | ||
+ | Récupération des scènes | ||
+ | |||
+ | get_scene_with_name(scn) | ||
+ | Récupération de la scène avec le nom | ||
- | * [[https:// | + | </code> |
- | * [[https:// | + | |
- | ==== Conversion de README.md en dokuwiki ==== | + | ====blendersound==== |
- | ====blendertools==== | + | |
<code txt> | <code txt> | ||
+ | DESCRIPTION | ||
+ | Classe générique qui permet de gérer facilement le son | ||
+ | dans le Blender Game Engine BGE. | ||
+ | | ||
+ | gl est le GameLogic, get with : from bge import logic as gl | ||
+ | | ||
+ | Appel de cette classe où tous les sons sont dans une liste avec : | ||
+ | import aud | ||
+ | | ||
+ | soundList = [" | ||
+ | | ||
+ | Création de l' | ||
+ | | ||
+ | gl.sound = EasyAudio(soundList) | ||
+ | soit { " | ||
+ | Joue le son boum | ||
+ | gl.sound[" | ||
+ | Stop le son | ||
+ | gl.sound[" | ||
+ | Idem repeat, pause | ||
+ | |||
CLASSES | CLASSES | ||
- | | + | Factory |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
+ | | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | |||
+ | class Factory(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====blendertempo==== | ||
+ | <code txt> | ||
+ | CLASSES | ||
+ | TempoFactory | ||
+ | | ||
+ | class Tempo(builtins.dict) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | class TempoFactory(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | FUNCTIONS | ||
+ | test() | ||
+ | Tourne en dehors de Blender. | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====blendertexture==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Class générique qui permet de changer la texture d'un objet. | ||
+ | Ce script ne peut tourner que dans blender. | ||
+ | |||
+ | CLASSES | ||
+ | class TextureChange(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====blendertools==== | ||
+ | <code txt> | ||
FUNCTIONS | FUNCTIONS | ||
droiteAffine(x1, | droiteAffine(x1, | ||
Ligne 100: | Ligne 285: | ||
End of sceneOld, load sceneNew. | End of sceneOld, load sceneNew. | ||
Scene must be str: if scene = scene python object, name is scene.name | Scene must be str: if scene = scene python object, name is scene.name | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====blenderviewport==== | ||
+ | <code txt> | ||
+ | FUNCTIONS | ||
+ | disable_viewport(cam) | ||
+ | Disable | ||
+ | | ||
+ | enable_full_viewport(cam) | ||
+ | cam is blender object | ||
+ | | ||
+ | enable_half_viewport(cam1, | ||
+ | cam1 and 2 are blender objects | ||
+ | | ||
+ | enable_quad_viewport(cam1, | ||
+ | cam1 2 3 4 are blender objects | ||
+ | | ||
+ | enable_stereo_viewport(cam1, | ||
+ | cam1 and 2 are blender objects | ||
</ | </ | ||
Ligne 107: | Ligne 312: | ||
CLASSES | CLASSES | ||
class PileFIFO(builtins.object) | class PileFIFO(builtins.object) | ||
- | | + | |
+ | | ||
| | ||
| | ||
Ligne 123: | Ligne 329: | ||
| | ||
| | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====getmyip==== | ||
+ | <code txt> | ||
+ | FUNCTIONS | ||
+ | get_my_ip() | ||
+ | Retourne l' | ||
+ | Valable pour python 3.x | ||
+ | Non valable sur android | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====httpdownload==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Télécharge une url. | ||
+ | Peut aussi l' | ||
+ | |||
+ | CLASSES | ||
+ | class HttpDownload(builtins.object) | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | FUNCTIONS | ||
+ | save_data_in_file(data, | ||
+ | Mode ' | ||
+ | Mode ' | ||
+ | donc enregistre un fichier | ||
+ | w ecrase | ||
+ | a ajoute | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====multicast==== | ||
+ | <code txt> | ||
+ | CLASSES | ||
+ | class Multicast(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====myconfig==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Le fichier ini doit être défini avec son chemin absolu | ||
+ | |||
+ | Pour un projet python: | ||
+ | import os | ||
+ | dossier = os.path.dirname(os.path.abspath(__file__)) | ||
+ | ou | ||
+ | os.getcwd() | ||
+ | |||
+ | Pour un projet Blender, le chemin complet est trouvé avec: | ||
+ | bge.logic.expandPath() | ||
+ | |||
+ | CLASSES | ||
+ | class MyConfig(builtins.object) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====myconfig2==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Le fichier ini doit être défini avec son chemin absolu | ||
+ | |||
+ | Pour un projet python: | ||
+ | import os | ||
+ | dossier = os.path.dirname(os.path.abspath(__file__)) | ||
+ | ou | ||
+ | os.getcwd() | ||
+ | |||
+ | Pour un projet Blender, le chemin complet est trouvé avec: | ||
+ | bge.logic.expandPath() | ||
+ | |||
+ | CLASSES | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
</ | </ | ||
Ligne 161: | Ligne 514: | ||
| | ||
| | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
| | ||
Ligne 175: | Ligne 532: | ||
| | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
</ | </ | ||
- | ====http_download==== | + | ====tcpclient2==== |
<code txt> | <code txt> | ||
- | DESCRIPTION | ||
- | Télécharge une url. | ||
- | Peut aussi l' | ||
- | |||
CLASSES | CLASSES | ||
- | class HttpDownload(builtins.object) | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
+ | | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
+ | | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | + | ||
- | FUNCTIONS | + | |
- | save_data_in_file(data, fichier, mode) | + | |
- | Mode ' | + | |
- | Mode ' | + | |
- | donc enregistre un fichier | + | |
- | w ecrase | + | |
- | a ajoute | + | |
</ | </ | ||
- | ====tcpclient==== | + | ====tcpclient3==== |
<code txt> | <code txt> | ||
CLASSES | CLASSES | ||
- | class TcpClient(builtins.object) | + | class TcpClient3(builtins.object) |
+ | | ||
| | ||
| | ||
Ligne 266: | Ligne 591: | ||
| | ||
| | ||
+ | | ||
+ | | ||
| | ||
| | ||
Ligne 271: | Ligne 598: | ||
| | ||
| | ||
- | | ||
| | ||
| | ||
| | ||
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
| | ||
| | ||
Ligne 284: | Ligne 612: | ||
| | ||
| | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====udpclient==== | ||
+ | <code txt> | ||
+ | DESCRIPTION | ||
+ | Recréer un socket avant chaque envoi ou réception, résoud les problèmes | ||
+ | de réseau, ça se reconnecte tout seul. | ||
+ | Par contre, le port éphémère du recvfrom changera à chaque fois. | ||
+ | |||
+ | CLASSES | ||
+ | class UdpClient(builtins.object) | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
| | ||
- | | + | |
- | | + | |
- | FUNCTIONS | ||
- | sleep(...) | ||
- | sleep(seconds) | ||
- | | ||
- | Delay execution for a given number of seconds. | ||
- | a floating point number for subsecond precision. | ||
</ | </ | ||
- | | + | |
- | {{tag> | + | |
+ | {{tag> |