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?


1 Answer 1


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.


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


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.


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.

  • $\begingroup$ 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. $\endgroup$
    – Fr0stBit
    Jan 23, 2017 at 14:56
  • $\begingroup$ 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. $\endgroup$
    – Derag
    Jan 23, 2017 at 15:03
  • 1
    $\begingroup$ 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. $\endgroup$
    – Derag
    Jan 23, 2017 at 16:26
  • $\begingroup$ Modifying mesh vertices for some simple transformation doesn't seem a good idea, seems more like it will complicate things to a new level. $\endgroup$
    – Fr0stBit
    Jan 23, 2017 at 18:55
  • $\begingroup$ 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. $\endgroup$
    – Derag
    Jan 23, 2017 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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