Sign in to follow this  
foxbat

up axis convention

Recommended Posts

foxbat    122
I would like to know whether there is any particular convention in games for world coordinate setup; i.e which axis to use for 'up' and 'forward' directions. I've noticed that engines such as Quake, CryEngine 2, Unreal and Torque all seem to define the +ve Z axis as up, but I've also seen other engines where a Y axis up vector is used. I know that it makes no difference to the engine internally, but is there any particular standard which artists prefer or expect?

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by foxbat
I would like to know whether there is any particular convention in games for world coordinate setup; i.e which axis to use for 'up' and 'forward' directions.

I've noticed that engines such as Quake, CryEngine 2, Unreal and Torque all seem to define the +ve Z axis as up, but I've also seen other engines where a Y axis up vector is used. I know that it makes no difference to the engine internally, but is there any particular standard which artists prefer or expect?
There is no set, or even preferred, standard (at least as far as I'm aware). Different game engines and modeling packages use different conventions (a few even allow you to choose which axis is treated as up).

I've never seen 'x' used as up, but 'y' and 'z' seem to be treated as up with about equal frequency. Personally, for simulations with a strong 2-d component (e.g. an FPS), I prefer 'z-up', since that places many of the computations that you'll want to perform in the XY plane.

Share this post


Link to post
Share on other sites
swiftcoder    18437
Both z-up and y-up have decent rationales behind them:
  • z-up makes sense for architects, etc. because plans are 2d, and have an x and y axis already.
  • y-up makes sense from a traditional 2d graphics background, where x and y are the screen axes, and z is then into (or more often, out of) the screen.
For a 2d game, you probably want to use x and y as your primary axes, and then z becomes solely an artefact of the transition to 3d graphics.

For a 3d game it really doesn't matter, use whatever feels more comfortable - but don't piss off your team members: on a project I worked on a while back, the initial coders had not communicated well, so that the 2d component of the game used x and y coordinates, and the 3d component used a y-up, requiring a translation from x,y to x,z in the opposite handed-ness [grin]

Share this post


Link to post
Share on other sites
Iced_Eagle    349
Yup, there's no standard.

To add to the list, Valve uses Z as up as well.

At my school, we are taught 2D graphics, and then naturally we all took the Z as the depth value. It all works out the same, as long as you are consistent and make a conscious descision early with your team members! :)

Share this post


Link to post
Share on other sites
n00body    345
One other small advantage to having Z as up is that positive Y becomes forward. Thus, you use positive values for forward, without having to resort to a left-handed coordinate system.

Share this post


Link to post
Share on other sites
Fingers_    410
Heh, I just checked a couple of modelling tools.. Blender uses +Z up and Maya uses +Y up. I personally like the +Z up in any situation where you need the concept of an overhead map. In general if the game can be presented on a plane it makes sense to think of that plane as the XY.

Share this post


Link to post
Share on other sites
swiftcoder    18437
Quote:
Original post by Fingers_
Heh, I just checked a couple of modelling tools.. Blender uses +Z up and Maya uses +Y up. I personally like the +Z up in any situation where you need the concept of an overhead map. In general if the game can be presented on a plane it makes sense to think of that plane as the XY.
If you are writing an exporter/converter, the option to flip axes is a must [smile]

Share this post


Link to post
Share on other sites
Daivuk    413
Quote:
Original post by Fingers_
Heh, I just checked a couple of modelling tools.. Blender uses +Z up and Maya uses +Y up. I personally like the +Z up in any situation where you need the concept of an overhead map. In general if the game can be presented on a plane it makes sense to think of that plane as the XY.


3DS max is Z up too.
But it seams that most of game programmers I talk to prefer Y up. And I think this comes from maths courses at university. (I was doing 3d programming before that, so I didn't get assimilated hehehe)

Share this post


Link to post
Share on other sites
Ravyne    14300
Quote:
Original post by n00body
One other small advantage to having Z as up is that positive Y becomes forward. Thus, you use positive values for forward, without having to resort to a left-handed coordinate system.


But that assumes that the left-handed system is somehow more "right" than a right-handed one, which is wrong. Confusing eh?

The point is, as the OP alludes, its all a matter of convention whether Y/Z or even X is up -- you could call them A, Q and an unpronounceable alien vowel and it wouldn't make a lick of difference. Same goes for handedness, just be consistent and know how to convert between them as necessary.

Share this post


Link to post
Share on other sites
n00body    345
Let me clarify. I wasn't making a statement about how right or wrong left-handed systems are versus right-handed systems. I was merely making an FYI point about one reason he might consider such a system.

Share this post


Link to post
Share on other sites
BlackSeeds    156
I use MAX for models which is z-up and have to change this to y-up for my engine. I use y as up just because of my maths background and I consider the difference between 2d and 3d is the addition of depth.

I suppose as long as you know what your modelers are using and what you engine is using and compensate for it then its all good.

Share this post


Link to post
Share on other sites
KulSeran    3267
The only real benifit I can think of is Z-up means that your data structures:
Vec4 ( x,y,z,w )
Vec3 ( x,y,z )
Vec2 ( x,y )

All lay out in memory the same way, so you can cast a Vec4* as a Vec3* as a Vec2* without having to copy/move any values around. And this is expecially useful in the sense that you can now pass a Vec4 array as a Vec2 array with stride 2*sizeof(float). without having to re-swizzle your data around to the 2d format.

Share this post


Link to post
Share on other sites
swiftcoder    18437
Quote:
Original post by KulSeran
The only real benifit I can think of is Z-up means that your data structures:
Vec4 ( x,y,z,w )
Vec3 ( x,y,z )
Vec2 ( x,y )
All lay out in memory the same way, so you can cast a Vec4* as a Vec3* as a Vec2* without having to copy/move any values around.
Right, but this is exactly the same argument for y-up if you are converting a 2d platformer (with z as depth into the screen). The main idea is to be consistent, and know how to convert.

Share this post


Link to post
Share on other sites
Daivuk    413
Quote:
Original post by BlackSeeds
I use MAX for models which is z-up and have to change this to y-up for my engine. I use y as up just because of my maths background and I consider the difference between 2d and 3d is the addition of depth.


Ya, but that changes depending if 2D for you is side scrolling or top down :)

Viewing a map, like google maps, X,Y. Then Z is the altitude.

Share this post


Link to post
Share on other sites
Rockoon1    104
Given KulSeran's excellent observation, Z should always be the odd-man out if there is one.

The bounding box that holds the entire world, described as length, width, and height, typically has 2 large-valued dimensions and 1 small-valued dimension.

That small valued dimension should normally be your world-space Z. This fits very well with grid-based acceleration approaches without the need for swizzling.

(Some games, such as a truely 3D space game, would not fit this profile)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this