# Changing coordinate system from Z-up to Y-up

Blender's coordinate system is different from what I'm used to, in that Z points upwards instead of Y. What would be the simplest way of converting all the world data (so that all animations, texture coordinates, etc still work) so that Y points upwards?

Clarification:

Object positions are defined as matrices, so just switching translation/rotation/scale information in matrices is not a trivial task. (at least it does not seem like a trivial task to me)

• Am I missing something, or could you just switch the Z coords and the Y coords? Jan 31, 2011 at 15:25
• Added clarification to question. Jan 31, 2011 at 15:35
• Isn't an object positional matrix just a 1x4 column matrix? So wouldn't it be easy to switch the elements? I've covered matrices, but not in gamedev specific terms. :p Jan 31, 2011 at 15:59
• These are flat 4x4 matrices with translation, rotation and scale applied. Jan 31, 2011 at 17:09
• If you're witing your own python script, you can use bpy_extras.io_utils.axis_conversion (see: blender.org/documentation/blender_python_api_2_66a_release/…). Afaik, support for 'non Z up' Coordinate systems in blender is planned, but as of now (2.66a) not yet implemented. Mar 23, 2013 at 20:25

Why can't you just make the rotation matrix to orient it correctly the first part of your World matrix?

If you want to fix it when loading, create the rotation matrix to orient it correctly (i.e. 90 degrees around the X axis). Apply this to all vertices, then change all existing matrices to (rotation * existing).

• This might work - apply a 90' rotation matrix to everything at export time. Feb 2, 2011 at 10:56
• Well, I asked for the simplest way.. Feb 5, 2011 at 6:42

Downvote me if I am wrong, but I don't see why people are recommending swapping y and z. That would make your coordinate system from being right handed to left handed. Try this yourself, swap the y and z, and reorient the axis so that x points right and y points up. You will see that z points the opposite direction from its original (away from the screen). The proper way is to rotate around the x-axis, which is swap y and z, and then invert the sign of the final z.

I think the easier solution is to build your models with y value being up.

• Now then, how to fix the matrices so that "the sign of the final z" is inverted.. Jan 31, 2011 at 20:45
• You don't want to fix your matrices, you want to fix your data, which is to apply the transformation when you read the model data in. Jan 31, 2011 at 21:10
• But the animation data is stored as matrices, so they'll be moving in wrong directions. So, the objects point at correct directions, but animations won't. Feb 2, 2011 at 6:39
• All of 3D computer graphics uses coordinates in different spaces— converting between coordinate spaces happens routinely in scene graphics, and through a few coordinate spaces for every vertex rendered to the screen. “Just go back to Blender and fix it there” may be an easy enough solution for some people in some situations, but the alternative — recognizing there are different standards here with known non-lossy conversions — is a thoroughly solved problem. Jun 4, 2020 at 6:23
• This helped. I'm importing a very old MMO's assets into Unity using a ScriptedImporter but all of the assets are Z-up. Simply rotating them isn't really an option - I needed to fix it at import. Simply flipping Y and Z caused the face to be inverted - the secret was negating the Z: new Vector3(in.X, in.Z, -in.Y) worked perfectly. Jun 27, 2021 at 18:29

As Comrade Duck suggests, you can just swap Y and Z. If you need a matrix to do it, use this one:

| 1 0 0 |
| 0 0 1 |
| 0 1 0 |


or in homogeneous coordinates

| 1 0 0 0 |
| 0 0 1 0 |
| 0 1 0 0 |
| 0 0 0 1 |


x
y
z
w


Then why not:

temp = y
y = z
z = temp


Or whatever swap method you want.

When you load your meshes with whatever mesh loader code you're using, just switch the Z and Y values. The mesh will then be loaded in your game in the appropriate coordinate space and you can do whatever you like to it (apply rotations, translations, etc). It's a similar situation I had with 3DS Max.

• Like I commented, animations get screwed up. Jan 31, 2011 at 17:09
• @JariKomppa You animations have translation/rotation/scale or matrix data as well— they need to be swapped too. If you don't swap all coords in a consisten manner, you're going to have a mess. Jun 4, 2020 at 6:30