Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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)

share|improve this question
    
Am I missing something, or could you just switch the Z coords and the Y coords? –  The Communist Duck Jan 31 '11 at 15:25
    
Added clarification to question. –  Jari Komppa Jan 31 '11 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 –  The Communist Duck Jan 31 '11 at 15:59
    
These are flat 4x4 matrices with translation, rotation and scale applied. –  Jari Komppa Jan 31 '11 at 17:09
1  
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. –  sarahm Mar 23 '13 at 20:25

5 Answers 5

up vote 2 down vote accepted

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

share|improve this answer
    
This might work - apply a 90' rotation matrix to everything at export time. –  Jari Komppa Feb 2 '11 at 10:56
    
Well, I asked for the simplest way.. –  Jari Komppa Feb 5 '11 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.

share|improve this answer
    
Now then, how to fix the matrices so that "the sign of the final z" is inverted.. –  Jari Komppa Jan 31 '11 at 20:45
1  
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. –  5ound Jan 31 '11 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. –  Jari Komppa Feb 2 '11 at 6:39

If your matrix is:

x
y
z
w

Then why not:

temp = y
y = z
z = temp

Or whatever swap method you want.

share|improve this answer

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 |
share|improve this answer

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.

share|improve this answer
    
Like I commented, animations get screwed up. –  Jari Komppa Jan 31 '11 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.