Results 1 to 8 of 8

Thread: 3D wire frame box

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Smile

    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
    rino_2
    Visual Basic, HTML
    Please Visit my Site: Richard's VB Site

  2. #2
    Guest
    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

  3. #3
    Guest
    oh yeah, set the timers interval to 100
    if you want it to be smoother than set it to 1

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Talking

    Thanks for the help Guys! Parksie, an OpenGL Version would be nice.
    rino_2
    Visual Basic, HTML
    Please Visit my Site: Richard's VB Site

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Coming shortly...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Thumbs up

    Thanks Parksie, can't wait!
    rino_2
    Visual Basic, HTML
    Please Visit my Site: Richard's VB Site

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width