Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Quick handedness question - WHY do I have to rotate an additional 180 degrees on Y?

Discussion in 'Editor & General Support' started by JonathanBolten, Jan 2, 2014.

  1. JonathanBolten

    JonathanBolten

    Joined:
    Dec 15, 2012
    Posts:
    50
    Hey, I'm having to revisit a problem I had earlier last year, because I'm doing some custom file exporting from Blender. The files contain physics collision primitive/mesh data for a server I wrote (uses Bullet physics).

    Blender uses a right-handed coordinate system while Unity uses a left-handed. To convert from Blender to Unity, I change the Blender matrix like so:

    Code (csharp):
    1.  
    2. def Matrix_To_Unity (m):
    3.     u = Matrix  (((m[0][0],m[0][2],m[0][1],m[0][3])
    4.                 , (m[2][0],m[2][2],m[2][1],m[2][3])
    5.                 , (m[1][0],m[1][2],m[1][1],m[1][3])
    6.                 , (m[3][0],m[3][2],m[3][1],m[3][3])))
    7.     return u
    8.  
    This almost works perfectly, except I noticed I have to rotate my models in Unity by 180 degrees on the Y-axis in order for them to be lined up properly with the collider data.

    The conversion matrix I posted was from here:
    http://stackoverflow.com/questions/1263072/changing-a-matrix-from-right-handed-to-left-handed-coordinate-system
    From other sources I've read, it seems to be the proper way to do this, but I can't find any information on why I have to rotate an additional 180 degrees on Y in Unity. Is the camera matrix responsible for the extra rotation? Or have I done something wrong?
     
  2. JonathanBolten

    JonathanBolten

    Joined:
    Dec 15, 2012
    Posts:
    50
    This is the stuff nightmares are made of. (Was glancing over asset pipeline code and it still bugs me that I don't know why I need the 180 on Y.)
     
  3. psantoki

    psantoki

    Joined:
    Oct 24, 2012
    Posts:
    17
    Probably handedness.

    I'm importing Blender data right now. Have you noticed that Blender export data is in a different space than what you see in the Blender editor? This is most shocking, suddenly I don't know which Blender to believe