dessin d'1 cube en VB6

1 post / 0 new
jean sami
dessin d'1 cube en VB6

bonjour
je suis débutant en VB et j'ai téléchargé un programme qui dessine un cube en 3D..j'ai enlevé qlqs instructions...mais franchement j'arrive pas à comprendre comment je peux dessiner un cube...parcequ'il ya bcp de formules math et je ne comprend pas son role...voici le prg....si qlq'1 peut m'aider il me fera un grand plaisir

Private X(8) As Integer
Private y(8) As Integer
Private Const Pi = 3.14159265358979
Private CenterX As Integer
Private CenterY As Integer
Private Const SIZE = 250
Private Radius As Integer
Private CubeCorners(1 To 8, 1 To 3) As Integer
Private Sub Form_Load()

CenterX = ScaleWidth / 2
CenterY = ScaleHeight / 2

Radius = Sqr(2 * (SIZE / 2) ^ 2)
CubeCorners(1, 2) = SIZE / 2
CubeCorners(2, 2) = SIZE / 2
CubeCorners(3, 2) = -SIZE / 2
CubeCorners(4, 2) = -SIZE / 2
CubeCorners(5, 2) = SIZE / 2
CubeCorners(6, 2) = SIZE / 2
CubeCorners(7, 2) = -SIZE / 2
CubeCorners(8, 2) = -SIZE / 2
End Sub
Private Sub DrawCube()

For i = 1 To 8
X(i) = CenterX + CubeCorners(i, 1) + Sgn(CubeCorners(i, 1)) * CubeCorners(i, 3)
y(i) = CenterY + CubeCorners(i, 2) + Sgn(CubeCorners(i, 2)) * CubeCorners(i, 3) / 5

Next
Line (X(3), y(3))-(X(4), y(4))
Line (X(4), y(4))-(X(8), y(8))
Line (X(3), y(3))-(X(7), y(7))
Line (X(7), y(7))-(X(8), y(8))
Line (X(1), y(1))-(X(3), y(3))
Line (X(1), y(1))-(X(2), y(2))
Line (X(5), y(5))-(X(6), y(6))
Line (X(5), y(5))-(X(1), y(1))
Line (X(5), y(5))-(X(7), y(7))
Line (X(2), y(2))-(X(4), y(4))
Line (X(2), y(2))-(X(6), y(6))

DoEvents
End Sub

Private Sub Timer1_Timer()

For i = 1 To 3 Step 2
CubeCorners(i, 3) = Radius * Cos(Pi / 180)
CubeCorners(i, 1) = Radius * Sin((Angle) * Pi / 180)Next
For i = 2 To 4 Step 2
CubeCorners(i, 3) = Radius * Cos((2 * 45) * Pi / 180)
CubeCorners(i, 1) = Radius * Sin((2 * 45) * Pi / 180)
Next
For i = 5 To 7 Step 2
CubeCorners(i, 3) = Radius * Cos((6 * 45) * Pi / 180)
CubeCorners(i, 1) = Radius * Sin((6 * 45) * Pi / 180)
Next
For i = 6 To 8 Step 2
CubeCorners(i, 3) = Radius * Cos((4 * 45) * Pi / 180)
CubeCorners(i, 1) = Radius * Sin((4 * 45) * Pi / 180)
Next
DrawCube
End Sub