1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
' Fonction d'affichage
Public Sub MyDisplay()
Dim i As Long
' Passage en matrice de projection
glMatrixMode GL_PROJECTION
' Initialisation de la matrice
glLoadIdentity
' Définition de la perspective
gluPerspective AnglePerspective, 1, DistPlanProche, DistPlanEloigne
' Passage en matrice de modélisation-visualisation
glMatrixMode GL_MODELVIEW
' Initialisation de la matrice
glLoadIdentity
' Position de la caméra
gluLookAt TranslateX, TranslateY, DistCamera, TranslateX, TranslateY, 0, 0, 1, 0
' Vide les buffers couleur et profondeur
glClear GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT
' Sauvegarde la matrice
glPushMatrix
' Rotation à partir de la souris
glRotated AngleY, 1, 0, 0
glRotated AngleX, 0, 1, 0
'on va activer la transparence
glEnable GL_BLEND
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
' l'enveloppe de l'aile
glBegin GL_TRIANGLE_STRIP 'triangles en bande
'les points alternativement d'un côté et de l'autre
For i = 1 To UBound(Points3D_E)
glColor4d 1, 0, 0, 0.5
glVertex3d Points3D_E(i).x, Points3D_E(i).y, Points3D_E(i).z
glColor4d 0, 0, 1, 0.5
glVertex3d Points3D_S(i).x, Points3D_S(i).y, Points3D_S(i).z
Next i
glEnd
'Primitive pour les contours des profils
'Emplanture
glBegin GL_LINE_STRIP 'lignes connectées
For i = 1 To UBound(Points3D_E)
glColor4d 1, 0, 0, 1
glVertex3d Points3D_E(i).x, Points3D_E(i).y, Points3D_E(i).z
Next i
glEnd
'Saumon
glBegin GL_LINE_STRIP 'lignes connectées
For i = 1 To UBound(Points3D_S)
glColor4d 0, 0, 1, 1
glVertex3d Points3D_S(i).x, Points3D_S(i).y, Points3D_S(i).z
Next i
glEnd
glDisable GL_BLEND ' Désactive la transparence
glPopMatrix ' Restaure la matrice
' Echange les buffers pour valider l'affichage : on travaille en double buffer pour éviter le scintillement
glutSwapBuffers
End Sub
'gestion du zoom avec la molette de la souris
Public Sub MyMouseWheel(ByVal wheel As Long, ByVal direction As Long, ByVal x As Long, ByVal y As Long)
Select Case direction
Case 1
DistCamera = DistCamera + ProfilInitial.EcartementZ / 5
Case -1
DistCamera = DistCamera - ProfilInitial.EcartementZ / 5
End Select
glutPostRedisplay
End Sub
'gestion des rotations à la souris
'*** détermination de l'appui sur un bouton ***
Public Sub MyMouseButton(ByVal button As Long, ByVal state As Long, ByVal x As Long, ByVal y As Long)
Select Case button
Case GLUT_LEFT_BUTTON
QuelBouttonSouris = 0
If state = GLUT_DOWN Then
BouttonPresse = True
Xold = x
Yold = y
Else
BouttonPresse = False
End If
Case GLUT_RIGHT_BUTTON
QuelBouttonSouris = 2
If state = GLUT_DOWN Then
BouttonPresse = True
Xold = x
Yold = y
Else
BouttonPresse = False
End If
End Select
End Sub
'*** déplacement bouton appuyé ***
Public Sub MyMouseMoveWithButton(ByVal x As Long, ByVal y As Long)
If BouttonPresse = True Then
Select Case QuelBouttonSouris
Case 0 'bouton gauche
AngleX = AngleX + (x - Xold) / 5
AngleY = AngleY + (y - Yold) / 5
'on rafraichit l'affichage
glutPostRedisplay
'on mémorise la position
Xold = x
Yold = y
Case 2 'boutton droit
TranslateX = TranslateX - (x - Xold) / (500 / ProfilInitial.CordeE)
TranslateY = TranslateY + (y - Yold) / (500 / ProfilInitial.CordeE)
'on rafraichit l'affichage
glutPostRedisplay
'on mémorise la position
Xold = x
Yold = y
End Select
End If
End Sub |