Transform coordinates from 3d to 2d without matrix or built in methods
Posted
by
Thomas
on Game Development
See other posts from Game Development
or by Thomas
Published on 2012-03-14T20:10:57Z
Indexed on
2012/03/20
11:39 UTC
Read the original article
Hit count: 322
Not to long ago i started to create a small 3D engine in javascript to combine this with an html5 canvas.
One of the issues I run into is how can you transform 3d to 2d coords. Since I cannot use matrices or built in transformation methods I need another way.
I've tried implementing the next explanation + pseudo code: http://freespace.virgin.net/hugo.elias/routines/3d_to_2d.htm
Unfortunately no luck there. I've replace all the input variables with data from my own camera and object classes.
I have the following data: An object with a rotation, position vector and an array of 4 3d coords (its just a plane) a camera with a position and rotation vector the viewport -> a square 600 x 600 surface. The example uses a zoom factor which I've set as 1
Most hits on google use either matrix calculations or don't implement camera rotation. Basic transformation should be like this: screen.x = x / z * zoom screen.y = y / z * zoom
Can anyone point me in the right direction or explain to me howto achieve this?
edit: Thanks for all your posts, I haven't been able to apply all this to my project yet but I hope to do this soon.
© Game Development or respective owner