Search code examples
javascriptc#unity-game-engine3dsmax

My in-game meshes are inverted in unity after importing from 3ds MAX with skin


My in-game meshes are inverted in unity after importing from 3ds MAX with skin,

both the mesh and the normals look "upside down", like if i was looking at some kind of ghost.

if i uncheck skin, it works correctly.


Solution

  • step 1 : setup the model and export as FBX.

    step 2 : import in unity. the vertex and the normals will be flipped.

    step 3 : attach this c# script, and run ONLY ONCE.

    public class meshInverter : MonoBehaviour {
    
        // Use this for initialization
        void Start () {
            Mesh mesh = GetComponent<SkinnedMeshRenderer>().sharedMesh;
            mesh.triangles = mesh.triangles.Reverse().ToArray();
        }
    
        // Update is called once per frame
        void Update () {
    
        }
    }
    

    step 4: remove last script, attach this JS script, and run ONLY ONCE:

    #pragma strict
    import System.Linq;
    function Start () {
        var mesh = (transform.GetComponent("SkinnedMeshRenderer") as SkinnedMeshRenderer).sharedMesh;
        var normals : Vector3[] = mesh.normals;
        for (var i=0;i<normals.Length;i++){
            normals[i] = -normals[i];
        }
        mesh.normals = normals;
    }
    
    function Update () {
    
    }
    

    step 5: remove last script, and now that the model is fixed.

    Edit

    Make sure too that your bones o mesh doesn't have any negative scale, that could fuck it up too and would not be a .fbx export failure.