• Advertisement


This topic is now archived and is closed to further replies.

graphics scales and the x, y, z, plain

This topic is 6695 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
Any advice is greatly appreciated.

Share this post

Link to post
Share on other sites
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).]

Share this post

Link to post
Share on other sites

  • Advertisement