-
3D to 2D
I am presently working on a small pet project.. Rendering a 3D pyramid on the screen and the user can rotate zoom etc..
The pyramid has 4 points.. Now how do i convert the 3D point x,y and X axis to plain 2D x and y Axis on the screen.. I know the basic and even approximated.. but the transition does not seem natural.......... While turning the pyramid the 3rd point some times stretches etc etc...
so is there some kind of formulae by which i can calculate the X and Y axis(to give the user a 3d effect on 2d screen) of a point by takin X , Y and Z..
Learning this will help me code a game which involved 3d space... At lease experiment with it...
Thanx in Advance
-
Given that the origin is at the center of the screen (usually isnt, but extemely easy to compromise) divide both the X and Y by the Z.
NewX=X/Z;
NewY=Y/Z;
The rotation is just trig
-
The rotation is done by multiplying matrixes together... if you go to the tutorials section on this site and read the stuff by Denthor of Asphyxia, you'll learn how to do it. The stuff is really outdated when it comes to displaying on the screen and using lookup tables, but the math for rotating and lighting is still the same.
-
ok thank you...
well i think i will build a small library after learning this to plot Z axis (represented in X and Y)...
thanx