11
\$\begingroup\$

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)

\$\endgroup\$
5
  • \$\begingroup\$ Am I missing something, or could you just switch the Z coords and the Y coords? \$\endgroup\$ Jan 31, 2011 at 15:25
  • \$\begingroup\$ Added clarification to question. \$\endgroup\$ Jan 31, 2011 at 15:35
  • \$\begingroup\$ 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 \$\endgroup\$ Jan 31, 2011 at 15:59
  • \$\begingroup\$ These are flat 4x4 matrices with translation, rotation and scale applied. \$\endgroup\$ Jan 31, 2011 at 17:09
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Exilyth
    Mar 23, 2013 at 20:25

5 Answers 5

2
\$\begingroup\$

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).

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

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.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Now then, how to fix the matrices so that "the sign of the final z" is inverted.. \$\endgroup\$ Jan 31, 2011 at 20:45
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – 5ound
    Jan 31, 2011 at 21:10
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Feb 2, 2011 at 6:39
  • \$\begingroup\$ 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. \$\endgroup\$ Jun 4, 2020 at 6:23
  • \$\begingroup\$ 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. \$\endgroup\$ Jun 27, 2021 at 18:29
6
\$\begingroup\$

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 |
\$\endgroup\$
1
\$\begingroup\$

If your matrix is:

x
y
z
w

Then why not:

temp = y
y = z
z = temp

Or whatever swap method you want.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Like I commented, animations get screwed up. \$\endgroup\$ Jan 31, 2011 at 17:09
  • \$\begingroup\$ @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. \$\endgroup\$ Jun 4, 2020 at 6:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .