mirror of
https://forge.apps.education.fr/blender-edutech/lecteur-3d-cinematique.git
synced 2024-01-27 09:43:12 +01:00
Bugfix : Orbit quand la taille de l'écran change
This commit is contained in:
parent
c7f8362f67
commit
05aa24930c
18
README.md
18
README.md
@ -4,7 +4,7 @@
|
|||||||
**3D player for kinematic analysis**
|
**3D player for kinematic analysis**
|
||||||
|
|
||||||
Ce lecteur 3D est un environnement léger et spécifique pour l'analyse cinématique d'un mécanisme en mouvement ( [vidéo de
|
Ce lecteur 3D est un environnement léger et spécifique pour l'analyse cinématique d'un mécanisme en mouvement ( [vidéo de
|
||||||
présentation](https://nuage03.apps.education.fr/index.php/s/HiLe7JwgMGDnkaM) ).
|
présentation](http://www.phroy.org/cloud/index.php/s/meK9dgYEk4pKwC5 ) ).
|
||||||
|
|
||||||
Mécanismes :
|
Mécanismes :
|
||||||
* Baton de colle
|
* Baton de colle
|
||||||
@ -21,13 +21,19 @@ Les fonctionalités du lecteur sont :
|
|||||||
* l'exploration par la mise en transparence des composants et l'éclatement du mécanisme,
|
* l'exploration par la mise en transparence des composants et l'éclatement du mécanisme,
|
||||||
* l'entrée dans le mécanisme par la nomenclature.
|
* l'entrée dans le mécanisme par la nomenclature.
|
||||||
|
|
||||||
Les fichiers sources sont dans le groupe Blender-Edutech de Gitlab : https://gitlab.com/blender-edutech/kinematic-player .
|
|
||||||
|
|
||||||
Les binaires (Game Engine Runtime) sont hébergés sur [apps.education.fr](https://nuage03.apps.education.fr/index.php/s/g75WfrdXM4Gx35s).
|
|
||||||
|
|
||||||
Ce lecteur fait partie du projet open source [Blender-EduTech (Blender/UPBGE pour l'Enseignement Technologique)](https://gitlab.com/blender-edutech).
|
Ce lecteur fait partie du projet open source [Blender-EduTech (Blender/UPBGE pour l'Enseignement Technologique)](https://gitlab.com/blender-edutech).
|
||||||
|
|
||||||
|
## Téléchargement
|
||||||
|
|
||||||
|
Les binaires (Game Engine Runtime) sont hébergés sur [phroy.org](http://www.phroy.org/cloud/index.php/s/54RWNAeMYpFAR5E).
|
||||||
|
|
||||||
|
## Documents pédagogiques
|
||||||
|
|
||||||
|
Les applications pédagogique se trouvent dans le [dépôt des documents pédagogiques du projet Blender-EduTech](https://gitlab.com/blender-edutech/blender-edutech-oer-french) .
|
||||||
|
|
||||||
|
## Développement
|
||||||
|
|
||||||
L'environnement de développement est basé sur : la plateforme de modélisation et d'animation 3D Blender ( https://blender.org ), le langage Python
|
L'environnement de développement est basé sur : la plateforme de modélisation et d'animation 3D Blender ( https://blender.org ), le langage Python
|
||||||
(https://python.org ) et le moteur de jeu 3D UPBGE ( https://upbge.org ).
|
(https://python.org ) et le moteur de jeu 3D UPBGE ( https://upbge.org ).
|
||||||
|
|
||||||
Les applications pédagogique se trouvent dans le [dépôt des documents pédagogiques du projet Blender-EduTech](https://gitlab.com/blender-edutech/blender-edutech-oer-french) .
|
Les fichiers sources sont dans le groupe Blender-Edutech de Gitlab : https://gitlab.com/blender-edutech/kinematic-player .
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import bge # Bibliothèque Blender Game Engine (BGE)
|
import bge # Bibliothèque Blender Game Engine (BGE)
|
||||||
import math
|
|
||||||
import cine # Bibliothèque du player 3d d'analyse de cinématique
|
import cine # Bibliothèque du player 3d d'analyse de cinématique
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
45
cine.py
45
cine.py
@ -262,7 +262,7 @@ def anim_pause():
|
|||||||
scene.objects['Mecanism']['anim'] = False
|
scene.objects['Mecanism']['anim'] = False
|
||||||
|
|
||||||
# Animation en pseudo-pause
|
# Animation en pseudo-pause
|
||||||
# Play d'une frame pour remettre les pièces en place
|
# Play d'une frame pour remettre les pièces en place (après-écltement)
|
||||||
def anim_play1frame():
|
def anim_play1frame():
|
||||||
start = scene.objects['Mecanism']['anim_frame']
|
start = scene.objects['Mecanism']['anim_frame']
|
||||||
end = scene.objects['Mecanism']['anim_frame']+1
|
end = scene.objects['Mecanism']['anim_frame']+1
|
||||||
@ -275,6 +275,8 @@ def anim_play1frame():
|
|||||||
speed = 1.0
|
speed = 1.0
|
||||||
for objet in scene.objects['Mecanism']['objects_anim'] :
|
for objet in scene.objects['Mecanism']['objects_anim'] :
|
||||||
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
scene.objects[objet].playAction(objet+'-Action', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||||
|
scene.objects['Axe 2'].playAction('Axe 2-Action_init', start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
|
||||||
|
|
||||||
scene.objects['Mecanism']['anim_frame'] = end
|
scene.objects['Mecanism']['anim_frame'] = end
|
||||||
|
|
||||||
# Reprise de l'animation (bas niveau)
|
# Reprise de l'animation (bas niveau)
|
||||||
@ -319,15 +321,29 @@ def circle (center, radius, color):
|
|||||||
ang = 0
|
ang = 0
|
||||||
ang_step = 0.1
|
ang_step = 0.1
|
||||||
while ang< 2 * math.pi:
|
while ang< 2 * math.pi:
|
||||||
x0 = center[0]+float(radius*math.cos(ang))
|
x0 = center[0]+float(radius*math.cos(ang)*0.95)
|
||||||
y0 = center[1]
|
y0 = center[1]
|
||||||
z0 = center[2]+float(radius*math.sin(ang))
|
z0 = center[2]+float(radius*math.sin(ang))
|
||||||
x1 = center[0]+float(radius*math.cos(ang+ang_step))
|
x1 = center[0]+float(radius*math.cos(ang+ang_step)*0.95)
|
||||||
y1 = center[1]
|
y1 = center[1]
|
||||||
z1 = center[2]+float(radius*math.sin(ang+ang_step))
|
z1 = center[2]+float(radius*math.sin(ang+ang_step))
|
||||||
bge.render.drawLine([x0,y0,z0],[x1,y1,z1],color)
|
bge.render.drawLine([x0,y0,z0],[x1,y1,z1],color)
|
||||||
ang += ang_step
|
ang += ang_step
|
||||||
|
|
||||||
|
# def circle (center, radius, color):
|
||||||
|
# ang = 0
|
||||||
|
# ang_step = 0.1
|
||||||
|
# ang_cam = (25.1 * 2 * math.pi)*(1/360)
|
||||||
|
# while ang< 2 * math.pi:
|
||||||
|
# x0 = center[0]+float(radius*math.cos(ang))
|
||||||
|
# y0 = center[1] +float(radius*math.sin(ang_cam)*math.cos(ang))
|
||||||
|
# z0 = center[2]+float(radius*math.sin(ang) - y0*math.tan(ang_cam))
|
||||||
|
# x1 = center[0]+float(radius*math.cos(ang+ang_step))
|
||||||
|
# y1 = center[1] +float(radius*math.sin(ang_cam)*math.cos(ang+ang_step))
|
||||||
|
# z1 = center[2]+float(radius*math.sin(ang+ang_step) - y1*math.tan(ang_cam))
|
||||||
|
# bge.render.drawLine([x0,y0,z0],[x1,y1,z1],color)
|
||||||
|
# ang += ang_step
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Initialisation de la vue 3D
|
# Initialisation de la vue 3D
|
||||||
@ -341,12 +357,14 @@ def manip_init():
|
|||||||
|
|
||||||
# Fenêtres
|
# Fenêtres
|
||||||
scene.objects['About'].setVisible(False,True)
|
scene.objects['About'].setVisible(False,True)
|
||||||
|
scene.objects['Doc'].setVisible(False,True)
|
||||||
|
|
||||||
# Mémorisation de la position des composants
|
# Mémorisation de la position des composants
|
||||||
for objet in scene.objects['Mecanism']['objects'] :
|
for objet in scene.objects['Mecanism']['objects'] :
|
||||||
scene.objects[objet]['init_lx']=scene.objects[objet].worldPosition.x
|
scene.objects[objet]['init_lx']=scene.objects[objet].worldPosition.x
|
||||||
scene.objects[objet]['init_ly']=scene.objects[objet].worldPosition.y
|
scene.objects[objet]['init_ly']=scene.objects[objet].worldPosition.y
|
||||||
scene.objects[objet]['init_lz']=scene.objects[objet].worldPosition.z
|
scene.objects[objet]['init_lz']=scene.objects[objet].worldPosition.z
|
||||||
|
|
||||||
if 'init_rx' in scene.objects[objet]:
|
if 'init_rx' in scene.objects[objet]:
|
||||||
scene.objects[objet]['init_rx'] = scene.objects[objet].worldOrientation.to_euler().x
|
scene.objects[objet]['init_rx'] = scene.objects[objet].worldOrientation.to_euler().x
|
||||||
if 'init_ry' in scene.objects[objet]:
|
if 'init_ry' in scene.objects[objet]:
|
||||||
@ -410,18 +428,23 @@ def manip_reset():
|
|||||||
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']
|
||||||
applyRotationTo(scene.objects['Mecanism'], 0, 0, 0)
|
applyRotationTo(scene.objects['Mecanism'], 0, 0, 0)
|
||||||
|
scene.objects['Mecanism'].worldPosition.x = scene.objects['Mecanism']['init_lx']
|
||||||
|
scene.objects['Mecanism'].worldPosition.y = scene.objects['Mecanism']['init_ly']
|
||||||
|
scene.objects['Mecanism'].worldPosition.z = scene.objects['Mecanism']['init_lz']
|
||||||
for objet in scene.objects['Mecanism']['objects'] :
|
for objet in scene.objects['Mecanism']['objects'] :
|
||||||
scene.objects[objet].setVisible(True,False)
|
scene.objects[objet].setVisible(True,False)
|
||||||
scene.objects[objet].restorePhysics()
|
scene.objects[objet].restorePhysics()
|
||||||
if objet+"_Lines.GP" in scene.objects:
|
if objet+"_Lines.GP" in scene.objects:
|
||||||
scene.objects[objet+"_Lines.GP"].setVisible(True,False)
|
scene.objects[objet+"_Lines.GP"].setVisible(True,False)
|
||||||
|
|
||||||
|
# FIXME : retour pas bon pour tous les composants
|
||||||
if scene.objects['Mecanism']['expld'] ==True:
|
if scene.objects['Mecanism']['expld'] ==True:
|
||||||
scene.objects['Mecanism']['expld'] = False
|
scene.objects['Mecanism']['expld'] = False
|
||||||
for objet in scene.objects['Mecanism']['objects'] :
|
for objet in scene.objects['Mecanism']['objects'] :
|
||||||
scene.objects[objet].worldPosition.x =scene.objects[objet]['init_lx']
|
scene.objects[objet].worldPosition.x =scene.objects[objet]['init_lx']
|
||||||
scene.objects[objet].worldPosition.y = scene.objects[objet]['init_ly']
|
scene.objects[objet].worldPosition.y = scene.objects[objet]['init_ly']
|
||||||
scene.objects[objet].worldPosition.z = scene.objects[objet]['init_lz']
|
scene.objects[objet].worldPosition.z = scene.objects[objet]['init_lz']
|
||||||
if scene.objects['Mecanism']['anim'] == False: # Play d'une frame
|
# if scene.objects['Mecanism']['anim'] == False: # Play d'une frame
|
||||||
anim_play1frame()
|
anim_play1frame()
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -452,9 +475,17 @@ def manip(cont):
|
|||||||
z0 =scene.objects['Orbit'].worldPosition.z
|
z0 =scene.objects['Orbit'].worldPosition.z
|
||||||
width = bge.render.getWindowWidth()
|
width = bge.render.getWindowWidth()
|
||||||
height = bge.render.getWindowHeight()
|
height = bge.render.getWindowHeight()
|
||||||
|
dist_orbit_y_base=200 # Pour 1280 x 720
|
||||||
|
radius_orbit_y_base=5
|
||||||
|
diag_base= math.sqrt(1280**2+720**2)
|
||||||
|
diag= math.sqrt(width**2+height**2)
|
||||||
|
dist_orbit_y = dist_orbit_y_base*(diag/diag_base)
|
||||||
|
radius_orbit_y=radius_orbit_y_base*(diag/diag_base)
|
||||||
dist_orbit = math.sqrt(((width/2)-obj['click_x'])**2+((height/2)-obj['click_y'])**2)
|
dist_orbit = math.sqrt(((width/2)-obj['click_x'])**2+((height/2)-obj['click_y'])**2)
|
||||||
if dist_orbit<215 : # Orbit sur x et z (150 valeur déterminée visuellement, anciennement 235)
|
if obj['click_y']> height/2 :
|
||||||
circle ([x0,y0,z0], 5, color_cmd)
|
dist_orbit = dist_orbit+((math.sqrt(((height/2)-obj['click_y'])**2)/175)*25) # Correction des Y sous le centre ?
|
||||||
|
if dist_orbit<dist_orbit_y : # Orbit sur xz
|
||||||
|
circle ([x0,y0,z0], radius_orbit_y_base, color_cmd)
|
||||||
n=10
|
n=10
|
||||||
pas_x=(delta_x*40*sensibilite_orbit)/n
|
pas_x=(delta_x*40*sensibilite_orbit)/n
|
||||||
pas_y=(((width/2)-cont.sensors['DownM'].position[0])+((height/2)-cont.sensors['DownM'].position[1]))*0.005
|
pas_y=(((width/2)-cont.sensors['DownM'].position[0])+((height/2)-cont.sensors['DownM'].position[1]))*0.005
|
||||||
@ -470,6 +501,8 @@ def manip(cont):
|
|||||||
scene.objects['Mecanism'].applyRotation((0, delta_x*sensibilite_orbit, 0), False)
|
scene.objects['Mecanism'].applyRotation((0, delta_x*sensibilite_orbit, 0), False)
|
||||||
else:
|
else:
|
||||||
scene.objects['Mecanism'].applyRotation((0, delta_y*sensibilite_orbit, 0), False)
|
scene.objects['Mecanism'].applyRotation((0, delta_y*sensibilite_orbit, 0), False)
|
||||||
|
|
||||||
|
|
||||||
# FIXME : Détecter le sens (trigo ou horaire)
|
# FIXME : Détecter le sens (trigo ou horaire)
|
||||||
# print ("cont.sensors['DownM'].position[0]", cont.sensors['DownM'].position[0])
|
# print ("cont.sensors['DownM'].position[0]", cont.sensors['DownM'].position[0])
|
||||||
# print ("cont.sensors['DownM'].position[1]", cont.sensors['DownM'].position[1])
|
# print ("cont.sensors['DownM'].position[1]", cont.sensors['DownM'].position[1])
|
||||||
|
@ -50,6 +50,7 @@ def close(cont):
|
|||||||
scene.objects['Mecanism']['anim'] = True
|
scene.objects['Mecanism']['anim'] = True
|
||||||
scene.objects['Doc']['anim'] == False
|
scene.objects['Doc']['anim'] == False
|
||||||
scene.active_camera = scene.objects["Camera"]
|
scene.active_camera = scene.objects["Camera"]
|
||||||
|
print ("hoho")
|
||||||
scene.objects['Doc'].setVisible(False,True)
|
scene.objects['Doc'].setVisible(False,True)
|
||||||
|
|
||||||
##
|
##
|
||||||
|
BIN
hemomixer/hemomixer-13.blend1
Normal file
BIN
hemomixer/hemomixer-13.blend1
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user