PDA

Click to See Complete Forum and Search --> : 3D graphics....??


AirScape17
Aug 21st, 2002, 06:49 PM
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!!)).

prog_tom
Aug 21st, 2002, 07:04 PM
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.

bugzpodder
Aug 21st, 2002, 07:23 PM
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.

hypnos
Aug 22nd, 2002, 03:52 AM
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.

sql_lall
Aug 22nd, 2002, 05:07 AM
Just wondering, how can you get the sin-1 and cos-1 functions in VB? is it possible??

hypnos
Aug 22nd, 2002, 05:37 AM
Just wondering, how can you get the sin-1 and cos-1 functions in VB? is it possible??

http://www.vbforums.com/showthread.php?s=&threadid=25184&highlight=inverse+sin

bugzpodder
Aug 22nd, 2002, 08:06 AM
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

hypnos
Aug 22nd, 2002, 08:11 AM
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.

Sameera_man
Aug 22nd, 2002, 08:15 AM
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. :p

hypnos
Aug 22nd, 2002, 08:43 AM
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 :D

Here you go:


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 :D