# pouët.net

## help with writing my own simple 3d engine

category: code [glöplog]
@zorke: Zed3D tutorial from 1996 gives a lot of info.
added on the 2013-08-04 11:59:54 by trc_wm
hmm... zed3d looks a bit complicated with math.
what are the prerequisites for this?
added on the 2013-08-04 13:49:26 by zorke
A book on vectors and matrices should provide the basics. It might seem complicated, but hang in there and take small steps at a time. Perhaps your math teacher can point you in the right direction.
added on the 2013-08-04 16:02:39 by trc_wm
i heard you do polygon calculations in baycentric space nowadays. however the oldschool way is just fun. there are several old papers on the subject. i recently started all over again writing a rasterizer since i lost all of my old source. i used an old paper on Digital Differential Analyzers (DDA's). Or you could write everything as a raytracer and integrate polygon rendering in that engine.

oh, and btw, where can one get the second reality source? ;)
added on the 2013-08-04 21:56:03 by rudi
Here you can learn How to make a vector cube. Amiiigaaaahh. In other news I think the 2nd Reality source was recently released.
added on the 2013-08-04 22:03:32 by StingRay
you dont even know how to make a vector cube if you know how to make a vector cube.
added on the 2013-08-04 22:13:10 by rudi
k.. ive got my triangle drawing function ready. heh. yes ive learnt matrices and two d vectors so it looks like i need to learn threed ones. just out of curiosity, would i be behind in my maths from an international standard? since the edu system where i live is crap. im currently doing quadratic, cubuc, quartic polynomials, and that stuff
added on the 2013-08-06 02:18:27 by zorke
You can "learn" vector math from books or Internet, it's plentyfull... but it won't replace practice for having a true, deep understanding of them. 3d engine is perfect way to put that into practice ;) I would say, you need those:

* Dot product, cross product, the various ways to compute them and their various interpretation.
* Matrix/vector product (one matrix => one linear transformation eg. combination of a rotation/scale/shear/symmetry)
* Homogeneous coordinates (how to have translations as a linear transformation, using a 4th coordinate)
zorke: Vector math started in 11th grade (age 17) for me, so your school is probably ok.

Some basic trigonometry and differentials are helpful, too, if you want to rotate stuff.
added on the 2013-08-06 12:10:06 by kb_
you can think to an abstration layer like mine libs (http://deaddeer.free.fr/) usefull to make cross-Platform engine.
added on the 2013-08-06 16:11:16 by Bartoshe
and also. what is the most hip way to define the z axes? should z be positive into the screen or negative into the screen?
added on the 2013-08-12 12:03:38 by zorke
The most hip way to define the z axis, is pointing along the axis of the hip-bone. Duh.
added on the 2013-08-12 20:02:27 by kusma
Z usually increases into the screen.
added on the 2013-08-12 21:08:36 by Gargaj
It decreases into the screen in OpenGL, and increases into the screen in Direct3D, no?
added on the 2013-08-12 21:47:18 by kusma
It goes up in OSG :P
added on the 2013-08-12 21:55:59 by Optimonk
Heightmaps ftw though :)
added on the 2013-08-12 21:56:10 by Optimonk
Surely you mean depthmaps?
added on the 2013-08-12 22:15:12 by revival
It's quite common to have the world-space Z-axis pointing up, indeed. But I suspect zorke was referring to the eye-space and/or clip-space Z-axis.
added on the 2013-08-13 01:01:45 by kusma
kusma: Quite possible that OpenGL is right-handed - haven't used it for a long time now. D3D is left-handed.
added on the 2013-08-13 01:14:19 by Gargaj
Of course it's right-handed; what else would it be? There's only one reasonable choice :-)
added on the 2013-08-13 01:43:49 by Sesse
Depends - would you describe walking forward as an action best described with an increasing or a decreasing number? :)
added on the 2013-08-13 01:58:35 by Gargaj
if gl depth is towards you they both right handed. d3d is just a handstand shooter and gl shooting back. ;)
added on the 2013-08-13 02:14:05 by yumeji
if you shoot ghetto style they're both left. d3d ownz that. and gl is a fallen hip shooter. :D
added on the 2013-08-13 02:21:00 by yumeji