<p>Maybe not the best solution but one that should work would be to multiply them by matrix like
<span class="math-container">\begin{bmatrix}-1&amp;0&amp;0\\0&amp;1&amp;0\\0&amp;0&amp;-1\end{bmatrix}</span>
And multiply by this your <code>mvp</code> matrix to convert meshes vertices (this could be done offline).</p>
<p>Quaternion can be change to matrix form, multiply and save as quaternion.</p>
<p>You also need to change culling in <code>OpenGL</code> because triangle order will be inverted.</p>
<p>I did this in one project and it works fine. If I will find this project I will write something more about it.</p>
<p>//EDIT</p>
<p>This matrix will invert your Z-axis and X-axis</p>
<p>//EDIT2</p>
<p>To apply this solution to each to component you need to:</p>
<ol>
<li><p>Change translation <code>x</code> and <code>z</code> component to <code>-x</code> and <code>-z</code>.</p>
</li>
<li><p>Rotation in matrix form multiply by matrix above and change it to quaternion.</p>
</li>
<li><p>Scale leave how it is.</p>
<p><s>4. Iterate through all meshes and multiply each of their vertices by this matrix.</s></p>
</li>
</ol>
<p>//EDIT3</p>
<p>Instead of matrix you can just multiply rotation by quaternion <code>(0, 0, 1, 0)</code> (in order <code>(w, x, y, z)</code>) and new quaternion will look like this: <code>(-y,z,w,-x)</code>. This operation (and matrix too) just rotate object by 180 degree in y-axis.</p>

CC BY-SA 3.0
2017-01-23T14:56:55.413Z
This solution is kinda obvious, and far from the question asked. Goal of the question is to find a solution that operates to the *uncombined* tranform components, before creating any model matrix.
Fr0stBit
CC BY-SA 3.0
2017-01-23T15:03:59.267Z
But you can apply this solution to uncombined transform components.
You can of course simplify it, e.g. change sign in position instead of multiply it by matrix but idea is the same.
Applying it to model matrix will apply it also to mesh vertices and you don't need to change models.
Derag
CC BY-SA 3.0
2017-01-23T16:26:18.133Z
Of course if you apply this matrix to scale you don't need to worry about meshes but scale like `(1,1,-1)` isn't intuitive.
Derag
CC BY-SA 3.0
2017-01-23T18:55:58.677Z
Modifying mesh vertices for some simple transformation doesn't seem a good idea, seems more like it will complicate things to a new level.
Fr0stBit
CC BY-SA 3.0
2017-01-23T21:23:09.497Z
When I think about it now, maybe I was wrong. With translation and rotation like this meshes should look alright and no changing in culling should be needed.
Derag
CC BY-SA 3.0
2017-01-23T14:49:30.837Z
2017-01-24T13:10:29.947Z
2020-06-18T08:32:12.800Z
Derag
<p>I am converting some Unity3D scenes to a proprietary json format to be used by my OpenGL renderer that uses a different coordinate system from Unity's.</p>

<p>I have multiple sets of {translation, rotation(quat), scale} pairs that describe some node transformations. The engine that uses them (Unity) uses the positive x-axis looking to the right, the positive y-axis looking up and the positive z-axis looking front.</p>

<p>I want to convert each pair into a {new_translation, new_rotation(quat), new_scale} in order to use them in my engine using the same coordinate convention with the z-axis inverted (positive z-axis looking back, the most common OpenGL convention).</p>

<p>How should the new pairs be constructed?</p>

<opengl><transformations><unity>
How to convert decomposed transformations between different coordinate systems?
Fr0stBit
# How to convert decomposed transformations between different coordinate systems?

(Asked by: username_0 on 2017-01-15)

I am converting some Unity3D scenes to a proprietary json format to be used by my OpenGL renderer that uses a different coordinate system from Unity's.

I have multiple sets of {translation, rotation(quat), scale} pairs that describe some node transformations. The engine that uses them (Unity) uses the positive x-axis looking to the right, the positive y-axis looking up and the positive z-axis looking front.

I want to convert each pair into a {new\_translation, new\_rotation(quat), new\_scale} in order to use them in my engine using the same coordinate convention with the z-axis inverted (positive z-axis looking back, the most common OpenGL convention).

How should the new pairs be constructed?

**Tags:** opengl, transformations, unity


---

## 1 answers

### Answer by username_1 on 2017-01-23. Score: 2

Maybe not the best solution but one that should work would be to multiply them by matrix like
\begin{bmatrix}-1&0&0\\0&1&0\\0&0&-1\end{bmatrix}
And multiply by this your `mvp` matrix to convert meshes vertices (this could be done offline).

Quaternion can be change to matrix form, multiply and save as quaternion.

You also need to change culling in `OpenGL` because triangle order will be inverted.

I did this in one project and it works fine. If I will find this project I will write something more about it.

//EDIT

This matrix will invert your Z-axis and X-axis

//EDIT2

To apply this solution to each to component you need to:

1. Change translation `x` and `z` component to `-x` and `-z`.
2. Rotation in matrix form multiply by matrix above and change it to quaternion.
3. Scale leave how it is.

   ~~4. Iterate through all meshes and multiply each of their vertices by this matrix.~~

//EDIT3

Instead of matrix you can just multiply rotation by quaternion `(0, 0, 1, 0)` (in order `(w, x, y, z)`) and new quaternion will look like this: `(-y,z,w,-x)`. This operation (and matrix too) just rotate object by 180 degree in y-axis.

> **Comments:**
> **username_0**: This solution is kinda obvious, and far from the question asked. Goal of the question is to find a solution that operates to the *uncombined* tranform components, before creating any model matrix.  
> **username_1**: But you can apply this solution to uncombined transform components. You can of course simplify it, e.g. change sign in position instead of multiply it by matrix but idea is the same. Applying it to model matrix will apply it also to mesh vertices and you don't need to change models.  
> **username_1**: Of course if you apply this matrix to scale you don't need to worry about meshes but scale like `(1,1,-1)` isn't intuitive.  
> **username_0**: Modifying mesh vertices for some simple transformation doesn't seem a good idea, seems more like it will complicate things to a new level.  
> **username_1**: When I think about it now, maybe I was wrong. With translation and rotation like this meshes should look alright and no changing in culling should be needed.  

---

