Results 1 to 10 of 10

Thread: 3D graphics....??

  1. #1

    Thread Starter
    Member AirScape17's Avatar
    Join Date
    Aug 2002
    Location
    England
    Posts
    34

    3D graphics....??

    How can you draw a 3D line on a 2D screen?? And what's the math for rotating this line?? (Preferably in radians than degrees (for whatever that means!!)).

  2. #2
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810
    nothing is 3D.

    So-Called: "3D" is lines that parrallel each other to make our eyes think it's in 3 Dimensional.

    If you are referring a plane as a 2D Screen, simply draw lines that parrallel each other, or so ever to make it look 3D.

    to rotate a whole 3D Object, for instance a 3D box, you will have to rotate every polygon(line) in that figure.

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  3. #3
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    ppl usually use Direct3D and/or OpenGL to take care of your problem -- they are truely 3D Graphics Engine I believe, especially with the new video cards. the very original "3D" graphics that appeared in Wolfenstein and Doom series however uses a technique called "RayCasting Engine" (which is really 2D but appears 3D). if you want more info do a search on these topics.
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  4. #4
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    What you should learn here is some trigonometry, namely the sin and cos functions. Also learn about radians as radians are what's used for angles on the computer screen and not degrees.

    Mainly though just learn trigonometry and just about everything you need to know for graphics programming will be explained.

  5. #5
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking sin + cos in VB

    Just wondering, how can you get the sin-1 and cos-1 functions in VB? is it possible??
    sql_lall

  6. #6
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    Just wondering, how can you get the sin-1 and cos-1 functions in VB? is it possible??
    http://www.vbforums.com/showthread.p...ht=inverse+sin

  7. #7
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    Originally posted by hypnos
    What you should learn here is some trigonometry, namely the sin and cos functions. Also learn about radians as radians are what's used for angles on the computer screen and not degrees.

    Mainly though just learn trigonometry and just about everything you need to know for graphics programming will be explained.
    lol while i agree that trig is very useful in graphics programming, I am afraid that if you want to program in 3D it is a LOT more than that. here is some links to a direct 3D tutorials:

    http://www.drunkenhyena.com/docs/d3d_tutorial.phtml
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  8. #8
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    bugzpodder yes I agree with you that if you want to learn things like DirectX it's a lot more complex. I'm just talking about the theory though. If you know trig and the line command you can draw 3d which is what AirScape17 seemed to be talking about when he mentioned rotating lines etc. He never mentioned anything about directX. It's much better to learn how to program 3D yourself (i.e. the theory) before you go on to anything like directX.

  9. #9
    New Member
    Join Date
    Aug 2002
    Posts
    1

    Smile

    Originally posted by hypnos
    bugzpodder yes I agree with you that if you want to learn things like DirectX it's a lot more complex. I'm just talking about the theory though. If you know trig and the line command you can draw 3d which is what AirScape17 seemed to be talking about when he mentioned rotating lines etc. He never mentioned anything about directX. It's much better to learn how to program 3D yourself (i.e. the theory) before you go on to anything like directX.

  10. #10
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183

    rotating a 2D line

    AirScape17 I've just made a little example which seems to work fine...I say that 'cos I haven't done this for a long time. Change the forms scale mode to Pixels and make the form a little bigger. Add a timer and don't rename it but do change the interval to 1

    The best advice I can give is just play around with the values and watch the changes. Then you'll get a feel for how it's working. The DtoR section is converting degrees to radians. Read up a little on Trig - this is what I was told to do when asked a similar question a long time ago...and it was good advice

    Here you go:

    Code:
    Dim centreX As Integer
    Dim centreY As Integer
    Dim xAngle As Integer
    Dim yAngle As Integer
    Const radius = 200
    Const PI = 3.14159
    
    
    
    Private Sub Form_Load()
    
        'Initialize the variables
        centreX = Me.ScaleWidth / 2
        centreY = Me.ScaleHeight / 2
        
        xAngle = 0
        yAngle = 0
    
    End Sub
    
    Private Function DtoR(D As Integer)
    
        DtoR = (PI / 180) * D
    
    End Function
    
    Private Sub Timer1_Timer()
        
        If xAngle = 359 Then
            xAngle = 0
        Else
            xAngle = xAngle + 1
        End If
        
        If yAngle = 359 Then
            yAngle = 0
        Else
            yAngle = yAngle + 1
        End If
        
        Me.Cls
        Me.Line (centreX, centreY)-((Sin(DtoR(xAngle)) * radius) + centreX, (-Cos(DtoR(yAngle)) * radius) + centreY)
        
        
    End Sub
    btw, the -Cos determins the direction in which the line rotates...remove the '-' sign and be amazed
    Last edited by hypnos; Aug 22nd, 2002 at 08:53 AM.

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