Hi,
I’m sure you have all seen the 3D wire frame boxes that can be rotated with the arrow keys? Does anybody know how to program it? If so I would love to see some code. Thanks
Printable View
Hi,
I’m sure you have all seen the 3D wire frame boxes that can be rotated with the arrow keys? Does anybody know how to program it? If so I would love to see some code. Thanks
here is some code I wrote, add 4 lines, 2 shapes(rectangles), and 2 timers, and set the form's keypreview property to true
Code:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then
Timer1.Enabled = True
Timer2.Enabled = False
ElseIf KeyCode = vbKeyRight Then
Timer2.Enabled = True
Timer1.Enabled = fale
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Timer1.Enabled = False
Timer2.Enabled = fale
End Sub
Private Sub Form_Load()
Shape1.Left = 1770
Shape1.Top = 1350
Shape2.Left = 2385
Shape2.Top = 1695
Line1.X1 = 2385
Line2.X1 = 3600
Line3.X1 = 2385
Line4.X1 = 3600
Line1.X2 = 1755
Line2.X2 = 3000
Line3.X2 = 1755
Line4.X2 = 3000
Line1.Y1 = 1695
Line2.Y1 = 1695
Line3.Y1 = 2610
Line4.Y1 = 2610
Line1.Y2 = 1350
Line2.Y2 = 1350
Line3.Y2 = 2265
Line4.Y2 = 2265
End Sub
Private Sub Timer1_Timer()
Shape1.Left = Shape1.Left + 10
Shape2.Left = Shape2.Left - 10
Line2.X2 = Line2.X2 + 10
Line2.X1 = Line2.X1 - 10
Line1.X2 = Line1.X2 + 10
Line1.X1 = Line1.X1 - 10
Line3.X2 = Line3.X2 + 10
Line3.X1 = Line3.X1 - 10
Line4.X2 = Line4.X2 + 10
Line4.X1 = Line4.X1 - 10
End Sub
Private Sub Timer2_Timer()
Shape1.Left = Shape1.Left - 10
Shape2.Left = Shape2.Left + 10
Line2.X2 = Line2.X2 - 10
Line2.X1 = Line2.X1 + 10
Line1.X2 = Line1.X2 - 10
Line1.X1 = Line1.X1 + 10
Line3.X2 = Line3.X2 - 10
Line3.X1 = Line3.X1 + 10
Line4.X2 = Line4.X2 - 10
Line4.X1 = Line4.X1 + 10
End Sub
oh yeah, set the timers interval to 100
if you want it to be smoother than set it to 1
Take a look at the ROTATE3D program at http://matthart.com
If you want, I can knock up an OpenGL version of this. (Simpler to understand).
Thanks for the help Guys! Parksie, an OpenGL Version would be nice.
Coming shortly...
Thanks Parksie, can't wait!
Okay...first, go to http://www.parksie.uklinux.net/simplegl/SimpleGL.html
This will give a short explanation, and a link to the type library. Then download http://www.parksie.uklinux.net/cube.zip for the project file.