Search Unity

How to get the XYZ axis right (3DS MAX/Unity)

Discussion in 'Formats & External Tools' started by holmeren, Apr 23, 2008.

  1. Maurice-Hoffman

    Maurice-Hoffman

    Joined:
    Jan 22, 2009
    Posts:
    182
    Hello Holmeren,

    Can you explain the biped with a youtube video ?

    I dont' know how to add a rood note, i use mosta of the time cheetah 3d.
     
  2. holmeren

    holmeren

    Joined:
    Dec 12, 2006
    Posts:
    300
    sry I dont know Cheetah
    Look for tutorials about linking and heirachy.
     
  3. Adngel

    Adngel

    Joined:
    Feb 20, 2011
    Posts:
    5
    I have problems with this, (or surely I will be doing this wrong).

    1º I have my biped attached to my model in 3dMax.
    2º I create a new Bone001 and I place it in the center of the biped (in the location of the Bip001), and rotate it as (90,0,0).
    3º I go to the Schematic View and connect the Bip001 (and all their children) to the Bone001 so this is in the top of the hierachy.

    But when I export it as FBX, it show me the next warning.

    And when I use it in Unity, Locomotion System tell me that it can not initiate animations. -.-u
     
  4. godoy

    godoy

    Joined:
    Oct 31, 2012
    Posts:
    7
    eu descobri!!! no maya vire o objeto de cabeça para baixo e aplique um freeze transformations nele, logo exporte como FBX. SIMPLES ASSIM!!!

    I discovered!!! in maya turn the object upside down and apply a freeze transformations on it as soon as FBX export. SO SIMPLE!!!
     
    Last edited: Nov 1, 2012
  5. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    96
    I am using Unity 4 and 3ds Max 2013.
    As I understand max uses right handed coordinate system and unity using left... how to correct handle this?
     
    Last edited: Nov 17, 2012
  6. Kasigawa

    Kasigawa

    Joined:
    Aug 18, 2012
    Posts:
    6
    Saved my life dude. You rock.
     
  7. Cheshyr

    Cheshyr

    Joined:
    Oct 8, 2012
    Posts:
    7
    This worked for me as well... Affect Pivot Only being the key part of this.
     
  8. MMO-Studio

    MMO-Studio

    Joined:
    Sep 28, 2012
    Posts:
    4
  9. tigerija

    tigerija

    Joined:
    Mar 26, 2012
    Posts:
    60
    I have one problem. I made model with pivot 0,0,0 and root bone is also 0,0,0. Model is animated btw.
    Now this is problem for Unity.

    Now if I change rotation of bone to 90,0,0 all other bones that are child of that root bone will get their axis switched. Z will become Y. So all animation that was on Z will now be Y (so if something was moving up and down, now it will move sideways).

    Can someone help me? Anyway way to resolve this aside rotating each child bone by 90?
     
  10. twiesner

    twiesner

    Joined:
    Oct 4, 2011
    Posts:
    309
    Export as "Y" is up. Or create an empty game object and move your animated model inside.

    I don't recommend using xform reset as that risks messing up the animation bones
     
  11. tigerija

    tigerija

    Joined:
    Mar 26, 2012
    Posts:
    60
    Export as "Y" is up.
    Doesn't help.

    Or create an empty game object and move your animated model inside. In Unity? You can do that only on prefab.

    Well I have some workarounds for now.

    BTW is everyone using 90,0,0 or are some using -90,0,0 for max to Unity pivot?
     
  12. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @everyone: For all that replied to this thread! :p
    This advice works for any modellig package that uses xzy as right, up and forward vectors respectively. I can say this myself, as I am a happy blender user. :)

    basically, make Y forward, Z up, and X left/right. will save you a lot of headache. also, use the model inside another game object with the right coordinates in unity. (Z-forward, Y-up, X-left/right... :D)
     
  13. Next Beat Games

    Next Beat Games

    Joined:
    Dec 18, 2012
    Posts:
    7
    Ah yes this problem. I am happy to say I have finally figured this out. I have had the EXACT same issue. It turns out there are a few issues at play. I will eventually create a very clear and comprehensive explanation for this but for now, here are some notes:

    Before I begin, you should know I haven't tested on objects that are rigged. It may yield different results.

    Main issue: Unity uses a left handed coordinate system. Max & Maya use a right handed coordinate system.

    A note about 3ds max: There is an issue when exporting to FBX from 3ds Max where children of the parent object are rotated 270 degrees about the x axis. There is no way around this - Don't use max to export to FBX if you wish to have objects and their children to be aligned properly! If you need to use MAX, export to FBX then import this max exported FBX into maya before exporting to your final FBX for importing into unity.

    FYI: Unity doesn't look at the up axis property in an FBX. So, if you select either Y or Z during your fbx export in either maya or max, there will be no effect when importing your fbx into unity. Also, theres an option on maya (i believe max has it too) that allows you to specify the up axis. this is not a solution either. In fact, it just rotates the object.

    There is a formula to convert from one coordinate system to another - flip, or mirror, one the axis (this is not simply a rotate!). However, you don't need to do this because there is some sort of conversion being done when unity imports an FBX. That exact transformation that takes place isn't important.

    The solution: If you are starting out in maya, create your model in its proper, right handed orientation. If you are creating it in max. export to maya then orient your model in its proper, right handed orientation.

    For example, if you have a person model in Maya, The person's face should be pointing forward in the Y+ axis direction, the right shoulder is pointing in the X+ axis direction, the top of the head should be pointing in the Z+ axis.

    When you are ready to export:

    Reset your transformation matrix: Select Modify->Freeze Transformations.

    Apply a 180 degree rotation about the Z axis so your character is facing in the opposite direction. Then rotate the model by 90 degrees about the X axis.

    Reset your transformation matrix again.

    Import into Maya: you will experience a 270 degree rotation about the X axis on the parent object but thats ok since the children aren't affected. just reset it to 0.

    Voila, your character will be properly oriented in the left handed coordinate system: z+ is forward, x+ is to the right, and y+ is upwards.
     
  14. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    What I would do is simply import the FBX as-is (I use blender, so situation in 3DS MAX might be different, as you've said... :D) into unity, then make the model the child of an empty gameObject. Works on animated/rigged objects, especially characters! (For other types of geometry, just rotating it to the desired rotation is usually enough, unless it's animated too... :D)
     
  15. davidosullivan

    davidosullivan

    Joined:
    Jun 9, 2015
    Posts:
    387
    Cant believe this is STILL going on. Its still an issue in September 2015!!! FBX SDK is made by Autodesk so what their software exports should be correct surely, and its not like MAX/Maya are some kind of 'out-there' software packages nobody uses.

    What the fu*k!

    And OK maybe its a solution to export from MAX into Maya and then into Unity, but Max is £145 pm and Maya is £145 pm and Unity is already £175pm so thats going to cost a fortune for a bug that should have been sorted YEARS ago!

    Maybe Unity should offer a free subscription to Maya with their 'Pro' package if this is the only software whose exports it can actually import properly!!! Or just state clearly on their home page that Unity ONLY SUPPORTS MAYA so we can all save ourselves a shed load of stress and hassle
     
  16. Afassolas

    Afassolas

    Joined:
    Apr 10, 2013
    Posts:
    78
    That's the thing
     
  17. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    LOL. That's why I don't use an of those and go blender. ;) (I admit though that I've considered learning Maya at some point)

    And well... if blender gets it wrong, I can always flip the model the right way up in unity, and add it to a root transform that is correct in orientation. :)

    Never tried a 3ds max model however, that stuff for me's poison. :D
     
  18. UnlimitedIW

    UnlimitedIW

    Joined:
    Mar 24, 2017
    Posts:
    1
    Still a problem......... it is easy to comprehend it, just take the z axis as -z axis....
    But, why an official explain is not exist yet.0.0.
     
  19. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    8 years later. I have this issue still. lack of docs.
     
  20. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    104
    It seems still not fixed (
     
  21. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    heres a simple importer that modifies the mesh verts on import
    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3. using UnityEditor;
    4. using UnityEngine;
    5.  
    6. public class MeshImporter3dsmax : AssetPostprocessor
    7. {
    8.     string prefix = "meshm_";
    9.     Vector3 rotationRoot = new Vector3(-90,90,0);
    10.     Vector3 rotationSubmesh = new Vector3(-90,0,0);
    11.  
    12.     void OnPostprocessModel(GameObject g)
    13.     {
    14.         if (assetPath.Contains(prefix))
    15.         {
    16.             ConvertMeshRecursive(g.transform, true);
    17.         }
    18.     }
    19.  
    20.     private void ConvertMeshRecursive(Transform transform, bool root)
    21.     {
    22.         if (transform.childCount > 0)
    23.         {
    24.             foreach (Transform child in transform)
    25.             {
    26.                 ConvertMeshRecursive(child, false);
    27.             }
    28.         }
    29.  
    30.         if (!root || transform.childCount == 0)
    31.             transform.rotation = Quaternion.identity;
    32.  
    33.         var mf = transform.GetComponent<MeshFilter>();
    34.         if (!mf)
    35.             return;
    36.  
    37.         var mesh = mf.sharedMesh;
    38.         if (!mesh)
    39.             return;
    40.  
    41.         var verts = mesh.vertices;
    42.  
    43.         for (int i = 0; i < verts.Length; i++)
    44.         {
    45.             verts[i] = RotatePointAroundPivot(verts[i], Vector3.zero, root ? rotationRoot : rotationSubmesh);
    46.         }
    47.  
    48.         var normals = mesh.normals;
    49.         for (int i = 0; i < normals.Length; i++)
    50.         {
    51.             normals[i] = Quaternion.Euler(root ? rotationRoot : rotationSubmesh) * normals[i];
    52.         }
    53.  
    54.         mesh.vertices = verts;
    55.         mesh.normals = normals;
    56.         mesh.RecalculateTangents();
    57.         mesh.RecalculateBounds();
    58.     }
    59.  
    60.     public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
    61.     {
    62.         Vector3 dir = point - pivot;
    63.         dir = Quaternion.Euler(angles) * dir;
    64.         point = dir + pivot;
    65.         return point;
    66.     }
    67. }
    68.  
    69. #endif
    70.  
     
    Last edited: Feb 27, 2020
  22. Andrey-Postelzhuk

    Andrey-Postelzhuk

    Joined:
    Nov 26, 2013
    Posts:
    75
    February 2020. Still have problem.
     
    KAJed likes this.
  23. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    104
    it's not a bug. It's just different apps and depends of your workflow.
    You need to setup it once and use after