• Create Account

## graphics scales and the x, y, z, plain

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1guru  Members

122
Like
Likes
Like

Posted 29 October 1999 - 05:48 AM

I have been programming for about three years now but am new on the game scene. In many programming languages their is a statement which allows you to change the scale of the screen (x, y) what I need to know is how to implement a 3d scale so that their will be an x a y and a z value so that I can program 3d games. RSVP.

### #2Aldacron  GDNet+

4328
Like
Likes
Like

Posted 29 October 1999 - 05:48 AM

Not sure what you mean. If you're using a prebuilt 3D engine or API there will be calls to transform world coordinates into screen coordinates. Otherwise you have to do it yourself via a bit of math.

In other words, the screen will never be anything other than x & y axes. To get the Z axis figured in requires math.

All the objects in a 3D world have local coordinates which apply to their vertices (points). Prior to rendering, these local coordinates are converted to World coordinates, which are then converted to camera coordinates. All of these use x, y & z axes. When it comes time to render to the screen however, you can either drop the z value and render the final x & y coordinates
(parallel projection), in which case the object will always be the same size, or you can use Perspective projection, meaning the object will shrink or grow according to the z value, giving the illusion of depth.

The basic formula to get the correct x & y values for perspective projetcion is:

x_perspective = viewing_distance *x/z
y_perspective = viewing_distance *y/z

To actually use these coordinates you also need to figure the width & height of the screen. You may also need to figure in an aspect ratio. But they are ultimately derived from the objects local coordinates, which means you have to do all the conversions, too.

This comes from things I've studied. I've never programmed my own engine. I just use what's available (and rarely).

[This message has been edited by Aldacron (edited October 29, 1999).]

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.