.OBJ exporter axis conversion "fix".

I’m working on some game art, and this early into engine development, I am using OBJ files just to get something on screen. The game I’m developing uses a top-down perspective, which is Blender’s bottom view (keypad 7). While loading the exporter files into my engine, I was perplexed by how the models are the correct orientation in Blender’s 3D view and I had set the forward and up menus to the correct values in the exporter, but the models were a strange orientation in the engine. Looking at the python code, it turns out that even when the values in the forward and up menus match the 3D scene, the exporter applies a rotation matrix to orient the exported model, changing its orientation. This is all manors of asinine.

It turns out that the fix was simple. I added a check box in the “init.py” file that causes the script to ignore the values of the menus and export the model as oriented in the 3D view. I could have removed the axis conversion functionality completely, but I don’t understand why it is needed, which makes me think there actually might be a use for it… Although I am at a total loss as to what that could be.:confused:

Anyway, unzip the archive and copy the file into your “scenes->addons->io_scene_obj” folder. I’m using Blender 2.65a, but I would think this would work with prior versions as well.

obj exporter fix.zip (2.94 KB)

well, it SHOULD be possible to set the required coordinate system, so that objects turns out the right side up and facing to the correct direction. Some game engines, e.g. Call of Duty, use a different coordinate system and objects get wrong orientations. But maybe the axis conversion isn’t working right, you should submit a bug report and upload a test files

The problem that I ran into was that I knew the coordinate system of my engine (of course), so I created the model in that coordinate system. Made perfect sense. However the exporter wants to “fix” the coordinate system. It wouldn’t be a problem except that there isn’t a way to turn it off. If the model is modeled in the correct coordinate system, there is no need to change it. Moreover, the exporter is highly unclear. Choosing the up and forward coordinates only works with a frame of reference. Trial and error is required to figure out which way the model will be orientated on export as the coordinate choices are ambiguous. Z up and Y forward in relation to what, exactly?

the labels of the dropdown lists give you the relations, default is

Forward > -Z
Up > Y

it would read it as
“Blender -Z to target engine’s forward axis” and
“Blender Y to target engine’s Up axis”

But no clue if it really works like that…

You deffo need to know what the forward and up axis is in the target engine…

A checkbox to disable the conversion would be user-friendly i guess. But if you set it to Blender’s coord system, it would basically behave like turned off. Only wondering why the default isn’t Forward Y, Up Z as in Blender?!

No, it doesn’t work like that. That is exactly what I tried first. I set forward to -Z and up to +Y, the same as my engine, but the exporter changed the coordinates of the model to something… Else… :confused: I cannot remember now, but after some trial and error, I did find the settings that wouldn’t change the model. However, there is no explanation why those settings worked.