Public Group

# How games usually use the 3 dimensions?

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

## Recommended Posts

Typically, how do games throw their models, terrains into a coordinate world system of x, y and z? Say for a game with character models and terrain with hills and mountains, they use x, y for positioning the character models and the z is used as height? Or x, z is used for positioning and y is used as height. Normally, I would think of the y-dimension as height, however, I noticed in 3ds max, height seems to be using the z dimension. So which is right?

##### Share on other sites
Quote:
 Original post by Zerox MillieniumSo which is right?

Both. Neither. It's just convention, people do what they feel like, and it causes pain all 'round.

##### Share on other sites
Usually, there's several 'spaces' objects go through to be rendered in games. This post'll be about DirectX, 'cause that's all I know about. :P

I'm assuming you know about the Cartesian system? Well, there's the left and right handed 'versions'. In a left-handed system, when X axis points to the right and Y axis points to up, Z axis points forward. In a right-handed system, with the same X and Y axes, Z axis points backward. DirectX is left handed, 'cause left handed people kick ass!

The funny thing is, you can flip these axis around as you like, it really doesn't matter, sense 'up' is really determined by the camera, and the observer.

About those several spaces... there's Object Space, World Space, View Space, Projection Space, and Screen Space. I won't cover exactly how these work, just the basics as far as what's 'up' and such... =] Also, you don't really need to be concerned if you don't get Projection Space and Screen Space... mostly 'cause my descriptions suck. ^.^

Object Space
This space is what you'd find in the model file. This space's 'up' is really determined by what application made it. This kind of goes into what Razor said. 'Up' can be Z, X, or Y! Usually, it's Z to my experience... I may be wrong, but it IS application specific after all... =] You have to either export the model using the correct axis or translate it.

World Space
This space is the 'world' of the game. As said above, in directx, it's 'up' is Y, X and Z are the horizontals. Which way they are to the observer is really dependant on where they're looking, but as said... Z+ would be 'north', and Y+ would be 'up'. =]

View Space
This space would be everything in relation to the camera. Z+ is always the direction you're looking. (even with rotations) X+ is always to your right, and Y+ is always 'up'. See how I mean world space doesn't really directly mean what's up? The actual location of the camera is in World Space, so if you do the math right, you could easily make a game that always uses Z as 'up', it's all how the models are in world space and how you 'point the camera'! =D

Projection Space
This space is a little bit different. To get exactly what the values in it mean, you gotta' know what it'd be like in World Space. You see, it has a Field of View, shaped like a cube with one end shrank down. It's the hunk of space you're lookin' at in a game, so to speak. X and Y are across and down, ranging from -1 to 1 for anything that will be displayed, and they're also dependant on Z, which ranges from 0 to 1. The reason they're dependant on Z is that, in world space, something closer to the viewing point (closer to 0 in the Z axis), would actually be smaller then something with a larger Z. Imagine two posts in real life. One closer then the next. If the closer is higher then your eyes, then the farther post would have to be higher then the first to 'look' the same hieght. It's so hard to explain in words, you'll just have to trust me on this one. :P

Screen Space
This space can be used to locate things in the frame buffer, because this space is esentially projection space 'smooshed' down into only X and Y. The origin is the 'top-left', and positive Y goes down. the location of things that would be displayed would be anything from (0,0) to (Width,Height).

If you read through it and understand, and leave out the fact that I didn't tell you a thing about the math... ^.^ you might understand how a game works, and how these things are related to eachother, and what 'up' actually ends up being... =]

##### Share on other sites
It all depends on your exact implementation and APIs.

In my experience, OpenGL usually has an UnitY Up vector.

To avoid confusion, it really depends on your exact implementation and APIs.
For example, you might use an engine that supports OpenGL and DirectX, except that the DirectX implementation is 'major', and the OpenGL implementation yields from the DirectX 'spaces'.

But really, it's whatever you want it to be. With any libaries/APIs, it's whatever the author(s) wanted it to be as well. So you have to be careful sometimes.

Aside from your engine/API, etc., there's 2 ways that most people usually look at the question:

1* In grade school, we are taught about the coordinate systems using graph-paper. First we are taught about 2D; we'd label the horizontal axis "X" and the vertical axis "Y". Likewise, we are often taught to associate "Y" with "Height". Thus, this concept sticks with us throughout our lifetime: +Y = Up. Later on in our early childhood studies, we become familiar with the concept of "Z" which we are also taught to associate with "Depth".

2* If you think about a terrain height-map image, where the height-values are stored amongst an XY grid of pixels; it really only makes sense to associate the actual "Height" of the geometry in world-space with the only missing component: Z. Thus, +Z = Up. No sense in switching components, it only leads to confusion. The only problem is that if you were taught the first viewpoint (Y=Up), this viewpoint(Z=Up) becomes rather hard to mingle with.

In other words: most people are taught the coordinate systems from a "camera view" perspective, rather than the "world view" perspective as it should be. How egotistic man is.

Personally, I go with Z=Up for OpenGL primarily because that's what standard 3DS models use. Also because that's what some of my "more important" 3rd party libraries use, and it becomes a hassle to think in both spaces. I'd say the biggest issue with Z=Up is when it comes to physics simulations, as much of the reference material out there uses Y=Up.

[Edited by - swordfish on October 23, 2006 2:36:31 AM]

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
12

• 9
• 21
• 13
• 9
• 17
• ### Forum Statistics

• Total Topics
632608
• Total Posts
3007391

×