3d to 2d screen

hoi, Im currently working on a 3d engine, and Im about to convert my 3d coordinate system into 2d to display it on the screen. but my 3d book explanation was pretty corny ( or maybe I simply didnt understand it), so I couldnt figure it all out. Its supposed to look like this: x' = x*d/z y' = y*x/z

....or something, but my problem is that I dont know what 'd' is, so if you know what the D is or perhaps have another way of doing it, leave a msg please


sincerly

//Onionkid


Comments

  • : hoi, Im currently working on a 3d engine, and Im about to convert my 3d coordinate system into 2d to display it on the screen. but my 3d book explanation was pretty corny ( or maybe I simply didnt understand it), so I couldnt figure it all out. Its supposed to look like this: x' = x*d/z y' = y*x/z

    : ....or something, but my problem is that I dont know what 'd' is, so if you know what the D is or perhaps have another way of doing it, leave a msg please


    : sincerly

    : //Onionkid


    The theoretical approach would be the following:


    You've got your 3d space. You have got one point which is the eye of

    the person. You have a plane defined by the x and y axis.

    (assuming z is the 3rd dimension). Project each point you want to

    display to the plane by calculating a line from the point to your

    'eyepoint'. Now each point has only x/y coordinates (as the plane can

    as well be defined as z=0).


    This might not be the fastest way, but it's the explanation for what you

    are trying to do. In real-life [i.e. computer programs ;-)] this might be

    handled less complicated, going for a fast and easy estimation, but the

    above way is the theory.


    (btw: your viewpoint ('eypoint') should have a negative z coordinate,

    while your points have positive ones [or the other way round].

    if not, you will have to move your coordinate system accordingly)


    Posting code would be useless, either get the simply solution by waiting

    for someone to post an exact answer to what 'd' is, or get a book

    about 3d space, vectors and matrix theory.


    hth

    -nv




  • screen_x = 3d_x / z + HALF_SCREEN_WIDTH

    screen_y = 3d_y / z + HALF_SCREEN_WIDTH

    or something like that

    For books I would suggest The Black Art of 3D Game Programming. By Andrew Lamothe


  • To answer the actual question you posted, the 'd' is replaced by a number representing the distance from the user's eye to the screen surface, usually game programmers use 256 or -256 (depending on if your Z axis is into the screen = positive or negative Z).




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories