1. 3D math
- Posted by mwfch at MWEB.CO.ZA Apr 24, 2001
- 403 views
This is a multi-part message in MIME format. ------=_NextPart_000_0033_01C0CCF3.B76F0740 charset="iso-8859-1" Lo ! No , i`m not dead yet . Well , now i got a question . I dont understand = the stuff behind 3D . Like , I do know where the X and the Y is ( and I = know i to do calculations for them like x = x+1 and so on ) , but Z ? = I dont think so ! And I dont fully understand what i should do with this = : x = x/z and y=y/z . I know that that is the 2D form of the 3D . = Sorry , i dont even know wat i`m saying , but it all boils down to one = thing : I dont understand 3D code , and you are going to show me how . = You are going to show me how , dont you ? Please ? Thanks ! You da man/woman ! Well , read ya later ! Ferdinand Greyling (DukeFungus) I was there in the begining of code , and i will be there in the end of = code , but i still dont know what the hell is going on ! lol ! ------=_NextPart_000_0033_01C0CCF3.B76F0740 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV>Lo !</DIV> <DIV>No , i`m not dead yet . Well , now i got a question . I dont = understand the=20 stuff behind 3D . Like , I do know where the X and the Y is ( and I know = i to do=20 calculations for them like x =3D x+1 and so on ) , but Z ? I dont think = so !=20 And I dont fully understand what i should do with this : x =3D = x/z and=20 y=3Dy/z . I know that that is the 2D form of the 3D . Sorry , i dont = even know wat=20 i`m saying , but it all boils down to one thing : I dont understand = 3D code=20 , and you are going to show me how . You are going to show me how , dont = you ?=20 Please ? Thanks !</DIV> <DIV>You da man/woman !</DIV> <DIV> </DIV> <DIV>Well , read ya later !</DIV> <DIV>Ferdinand Greyling (DukeFungus)</DIV> <DIV>I was there in the begining of code , and i will be there in the = end of=20 code , but i still dont know what the hell is going on ! lol=20 ------=_NextPart_000_0033_01C0CCF3.B76F0740--
2. Re: 3D math
- Posted by mwfch at MWEB.CO.ZA Apr 26, 2001
- 426 views
Thanks a lot , that cleard it up a lot ! Read ya later ! Ferdinand Greyling(DukeFungus) ----- Original Message ----- From: Chris Bensler <bensler at mailops.com> To: <EUforum at topica.com> Subject: RE: 3D math > > > > Hi Ferdinand, > > Here is how it works.. (I may be mistaken, I haven't done 3d code in a > while) > > You start with your 3d point (X,Y,Z) > > the formula for converting to screen coordinates is.. > > X = (X * FOV)/Z + (screen_width/2) > Y = (Y * FOV)/Z + (screen_height/2) > > FOV is the Field Of View, which is just so your 3d objects arent very, > very small.. Usually FOV is 256 or something close to that. It's up to > you. > > Z is in the range >0 to FOV.. > a big Zvalue is closer , a small Zvalue is farther > > make sure you test to make sure Z is never 0, or you will get a divide > _by_zero error. > > I don't understand it very well myself.. I just get it to work and then > I'm happy . :P > > here is some example code in C some docs I have.... > I just draws a dot in 3d > > -- EXAMPLE > x = 1 > y = 1 > z = 256 > FOV = 256 > while (gx<320) and (gx>-1) and (gy<200) and (gy>-1) > gx = x * FOV / z + 160 ; center = the center of the screen > gy = y * FOV / z + 100 ; (mode 320x200) > putpixel(gx,gy,15) > z = z - 1 > if (z = 0) > z = -1 ; just to ensure... > endif > endwhile > -- END of EXAMPLE > > NOTE.. > You can get rid of the FOV if Z is in the range 0.1 to 1.0 > > Hope that helps.. > <snip> > > > >