Esempio n. 1
0
        public void Export(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae; *.obj;|" +
                         "Bfres Object (shape/vertices) |*.bfobj|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "OBJ |*.obj|" +
                         "All files(*.*)|*.*";
            sfd.DefaultExt = ".bfobj";
            sfd.FileName   = Text;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(sfd.FileName);
                ext = ext.ToLower();

                switch (ext)
                {
                case ".bfobj":
                    ExportBinaryObject(sfd.FileName);
                    break;

                default:
                    AssimpData assimp = new AssimpData();
                    assimp.SaveFromObject(vertices, lodMeshes[DisplayLODIndex].faces, Text, sfd.FileName);
                    break;
                }
            }
        }
Esempio n. 2
0
        private void ReplaceAction(object sender, EventArgs args)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Supported Formats|*.dae;*.fbx;*.json;|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "JSON |*.json|" +
                         "All files(*.*)|*.*";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string ext = Utils.GetExtension(ofd.FileName);
                if (ext == ".json")
                {
                    var model = JsonConvert.DeserializeObject <Model>(
                        System.IO.File.ReadAllText(ofd.FileName));

                    ReloadModel(model);
                    Model.UpdateVertexData(true);
                }
                else
                {
                    AssimpData assimp   = new AssimpData();
                    bool       IsLoaded = assimp.LoadFile(ofd.FileName);

                    if (!IsLoaded)
                    {
                        return;
                    }

                    GFLXModelImporter dialog = new GFLXModelImporter();
                    dialog.LoadMeshes(assimp.objects, assimp.materials, Model.GenericMaterials, Model.GenericMeshes);
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        ImportModel(dialog, assimp.materials, assimp.objects, assimp.skeleton);
                    }
                }
            }

            LoadEditor <STPropertyGrid>();
        }
Esempio n. 3
0
        private void FromAssimp(string FileName, bool IsWiiU)
        {
            var anims = AssimpData.ImportAnimations(FileName);

            for (int i = 0; i < anims.Length; i++)
            {
                if (IsWiiU)
                {
                    SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(FromGeneric(anims[i]));
                    LoadAnim(SkeletalAnimU);
                }
                else
                {
                    SkeletalAnim = FromGeneric(anims[i]);
                    LoadAnim(SkeletalAnim);
                }

                break;
            }
        }
Esempio n. 4
0
        //Function addes shapes, vertices and meshes
        public void AddOjects(string FileName, bool Replace = true)
        {
            bool IsWiiU = (GetResFileU() != null);

            int    MatStartIndex = materials.Count;
            string ext           = System.IO.Path.GetExtension(FileName);

            ext = ext.ToLower();

            switch (ext)
            {
            case ".bfobj":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                }

                Shape        shpS         = new Shape();
                VertexBuffer vertexBuffer = new VertexBuffer();
                shpS.Import(FileName, vertexBuffer);

                FSHP shapeS = new FSHP();
                shapeS.Shape = shpS;
                BfresSwitch.ReadShapesVertices(shapeS, shpS, vertexBuffer, this);
                shapes.Add(shapeS);
                Nodes["FshpFolder"].Nodes.Add(shapeS);
                Cursor.Current = Cursors.Default;
                break;

            case ".bfmdl":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                }

                Model mdl = new Model();
                mdl.Import(FileName, GetResFile());
                mdl.Name = Text;
                shapes.Clear();
                foreach (Shape shp in mdl.Shapes)
                {
                    FSHP shape = new FSHP();
                    shape.Shape = shp;
                    BfresSwitch.ReadShapesVertices(shape, shp, mdl.VertexBuffers[shp.VertexBufferIndex], this);
                    shapes.Add(shape);
                    Nodes["FshpFolder"].Nodes.Add(shape);
                }
                Cursor.Current = Cursors.Default;
                break;

            case ".csv":
                CsvModel csvModel = new CsvModel();
                csvModel.LoadFile(FileName, true);

                if (csvModel.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings csvsettings = new BfresModelImportSettings();
                csvsettings.DisableMaterialEdits();
                csvsettings.SetModelAttributes(csvModel.objects[0]);
                if (csvsettings.ShowDialog() == DialogResult.OK)
                {
                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;

                    foreach (STGenericObject obj in csvModel.objects)
                    {
                        FSHP shape = new FSHP();
                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.MaterialIndex     = 0;
                        shape.vertexAttributes  = csvsettings.CreateNewAttributes();
                        shape.boneIndx          = 0;
                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
                        shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex));
                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer(IsWiiU);
                        shape.BoneIndices = new List <ushort>();

                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);
                    }
                    Cursor.Current = Cursors.Default;
                }
                break;

            default:
                AssimpData assimp = new AssimpData();
                assimp.LoadFile(FileName);

                if (assimp.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings settings = new BfresModelImportSettings();
                settings.SetModelAttributes(assimp.objects[0]);
                if (settings.ShowDialog() == DialogResult.OK)
                {
                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;
                    if (Replace)
                    {
                        materials.Clear();
                        Nodes["FmatFolder"].Nodes.Clear();
                        MatStartIndex = 0;
                    }
                    foreach (STGenericMaterial mat in assimp.materials)
                    {
                        FMAT fmat = new FMAT();
                        if (settings.ExternalMaterialPath != string.Empty)
                        {
                            if (GetResFileU() != null)
                            {
                                fmat.MaterialU = new ResU.Material();
                                fmat.MaterialU.Import(settings.ExternalMaterialPath, GetResFileU());
                                BfresWiiU.ReadMaterial(fmat, fmat.MaterialU);
                            }
                            else
                            {
                                fmat.Material = new Material();
                                fmat.Material.Import(settings.ExternalMaterialPath);
                                fmat.ReadMaterial(fmat.Material);
                            }
                        }

                        fmat.Text = mat.Text;
                        //Setup placeholder textures
                        //Note we can't add/remove samplers so we must fill these slots
                        foreach (var t in fmat.TextureMaps)
                        {
                            t.wrapModeS = 0;
                            t.wrapModeT = 0;

                            switch (t.Type)
                            {
                            case STGenericMatTexture.TextureType.Diffuse:
                                t.Name = "Basic_Alb";
                                break;

                            case STGenericMatTexture.TextureType.Emission:
                                t.Name = "Basic_Emm";
                                break;

                            case STGenericMatTexture.TextureType.Normal:
                                t.Name = "Basic_Nrm";
                                break;

                            case STGenericMatTexture.TextureType.Specular:
                                t.Name = "Basic_Spm";
                                break;

                            case STGenericMatTexture.TextureType.SphereMap:
                                t.Name = "Basic_Sphere";
                                break;

                            case STGenericMatTexture.TextureType.Metalness:
                                t.Name = "Basic_Mtl";
                                break;

                            case STGenericMatTexture.TextureType.Roughness:
                                t.Name = "Basic_Rgh";
                                break;

                            case STGenericMatTexture.TextureType.MRA:
                                t.Name = "Basic_MRA";
                                break;

                            case STGenericMatTexture.TextureType.Shadow:
                                t.Name = "Basic_Bake_st0";
                                break;

                            case STGenericMatTexture.TextureType.Light:
                                t.Name = "Basic_Bake_st1";
                                break;
                            }
                        }

                        if (PluginRuntime.bntxContainers.Count > 0)
                        {
                            foreach (var node in Parent.Parent.Nodes["EXT"].Nodes)
                            {
                                if (node is BNTX)
                                {
                                    var bntx = (BNTX)node;

                                    bntx.ImportBasicTextures("Basic_Alb");
                                    bntx.ImportBasicTextures("Basic_Nrm");
                                    bntx.ImportBasicTextures("Basic_Spm");
                                    bntx.ImportBasicTextures("Basic_Sphere");
                                    bntx.ImportBasicTextures("Basic_Mtl");
                                    bntx.ImportBasicTextures("Basic_Rgh");
                                    bntx.ImportBasicTextures("Basic_MRA");
                                    bntx.ImportBasicTextures("Basic_Bake_st0");
                                    bntx.ImportBasicTextures("Basic_Bake_st1");
                                    bntx.ImportBasicTextures("Basic_Emm");
                                }
                            }
                        }

                        foreach (var tex in mat.TextureMaps)
                        {
                            foreach (var t in fmat.TextureMaps)
                            {
                                if (t.Type == tex.Type)
                                {
                                    t.Name      = tex.Name;
                                    t.wrapModeS = tex.wrapModeS;
                                    t.wrapModeT = tex.wrapModeT;
                                    t.wrapModeW = tex.wrapModeW;
                                    t.Type      = tex.Type;
                                }
                            }
                        }

                        List <string> keyList = new List <string>(materials.Keys);
                        fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text);

                        materials.Add(fmat.Text, fmat);
                        Nodes["FmatFolder"].Nodes.Add(fmat);

                        if (GetResFileU() != null)
                        {
                            fmat.MaterialU.Name = Text;
                            fmat.SetMaterial(fmat.MaterialU);
                        }
                        else
                        {
                            fmat.Material.Name = Text;
                            fmat.SetMaterial(fmat.Material);
                        }
                    }


                    foreach (STGenericObject obj in assimp.objects)
                    {
                        FSHP shape = new FSHP();
                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.VertexSkinCount   = obj.MaxSkinInfluenceCount;
                        shape.vertexAttributes  = settings.CreateNewAttributes();
                        shape.boneIndx          = obj.BoneIndex;
                        shape.MaterialIndex     = obj.MaterialIndex + MatStartIndex;

                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        shape.ApplyImportSettings(settings, GetMaterial(shape.MaterialIndex));
                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer(IsWiiU);
                        shape.BoneIndices = new List <ushort>();

                        List <string> keyList = shapes.Select(o => o.Text).ToList();

                        shape.Text = Utils.RenameDuplicateString(keyList, shape.Text);

                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);
                    }
                    Console.WriteLine("Finshed Importing Model");

                    Cursor.Current = Cursors.Default;
                }
                break;
            }
            UpdateVertexData();
        }
Esempio n. 5
0
        public void Export(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Supported Formats|*.bfmdl;*.fbx;*.dae; *.obj;*.csv;|" +
                         "Bfres Model|*.bfmdl|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "OBJ |*.obj|" +
                         "CSV |*.csv|" +
                         "All files(*.*)|*.*";
            sfd.DefaultExt = ".bfobj";
            sfd.FileName   = Text;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(sfd.FileName);
                ext = ext.ToLower();

                switch (ext)
                {
                case ".bfmdl":
                    if (GetResFileU() != null)
                    {
                    }
                    else
                    {
                        Model.Export(sfd.FileName, GetResFile());
                    }
                    break;

                case ".csv":
                    CsvModel csv = new CsvModel();
                    foreach (FSHP shape in shapes)
                    {
                        STGenericObject obj = new STGenericObject();
                        obj.ObjectName = shape.Text;
                        obj.vertices   = shape.vertices;
                        obj.faces      = shape.lodMeshes[shape.DisplayLODIndex].faces;
                        csv.objects.Add(obj);

                        int CurVtx = 0;
                        foreach (Vertex v in shape.vertices)
                        {
                            if (v.boneIds[0] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[0]));
                            }
                            if (v.boneIds[1] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[1]));
                            }
                            if (v.boneIds[2] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[2]));
                            }
                            if (v.boneIds[3] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[3]));
                            }

                            CurVtx++;
                        }
                    }
                    System.IO.File.WriteAllBytes(sfd.FileName, csv.Save());
                    break;

                default:
                    List <STGenericTexture> Surfaces = new List <STGenericTexture>();
                    foreach (FSHP fshp in shapes)
                    {
                        foreach (var bntx in PluginRuntime.bntxContainers)
                        {
                            foreach (var tex in fshp.GetMaterial().TextureMaps)
                            {
                                if (bntx.Textures.ContainsKey(tex.Name))
                                {
                                    Surfaces.Add(bntx.Textures[tex.Name]);
                                }
                            }
                        }
                        foreach (var ftex in PluginRuntime.ftexContainers)
                        {
                            foreach (var tex in fshp.GetMaterial().TextureMaps)
                            {
                                if (ftex.Textures.ContainsKey(tex.Name))
                                {
                                    Surfaces.Add(ftex.Textures[tex.Name]);
                                }
                            }
                        }
                    }
                    Console.WriteLine("tex count " + Surfaces.Count);

                    AssimpData assimp = new AssimpData();
                    assimp.SaveFromModel(this, sfd.FileName, Surfaces);
                    break;
                }
            }
        }
Esempio n. 6
0
        public void Export(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Supported Formats|*.bfmdl;*.fbx;*.dae; *.obj;*.csv;|" +
                         "Bfres Model|*.bfmdl|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "OBJ |*.obj|" +
                         "CSV |*.csv|" +
                         "All files(*.*)|*.*";
            sfd.DefaultExt = ".bfobj";
            sfd.FileName   = Text;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(sfd.FileName);
                ext = ext.ToLower();

                switch (ext)
                {
                case ".bfmdl":
                    Model.Export(sfd.FileName, GetResFile());
                    break;

                case ".csv":
                    CsvModel csv = new CsvModel();
                    foreach (FSHP shape in shapes)
                    {
                        STGenericObject obj = new STGenericObject();
                        obj.ObjectName = shape.Text;
                        obj.vertices   = shape.vertices;
                        obj.faces      = shape.lodMeshes[shape.DisplayLODIndex].faces;
                        csv.objects.Add(obj);

                        int CurVtx = 0;
                        foreach (Vertex v in shape.vertices)
                        {
                            if (v.boneIds[0] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[0]));
                            }
                            if (v.boneIds[1] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[1]));
                            }
                            if (v.boneIds[2] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[2]));
                            }
                            if (v.boneIds[3] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[3]));
                            }

                            CurVtx++;
                        }
                    }
                    System.IO.File.WriteAllBytes(sfd.FileName, csv.Save());
                    break;

                default:
                    AssimpData assimp = new AssimpData();
                    assimp.SaveFromModel(this, sfd.FileName);
                    break;
                }
            }
        }
Esempio n. 7
0
        public void Replace(object sender, EventArgs args)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae; *.obj;|" +
                         "Bfres Object (shape/vertices) |*.bfobj|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "OBJ |*.obj|" +
                         "All files(*.*)|*.*";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(ofd.FileName);
                ext = ext.ToLower();

                switch (ext)
                {
                case ".bfobj":
                    Shape shp = new Shape();
                    shp.Import(ofd.FileName, VertexBuffer);
                    shp.Name          = Text;
                    shp.MaterialIndex = (ushort)MaterialIndex;
                    BfresSwitch.ReadShapesVertices(this, shp, VertexBuffer, GetModelList()[ModelIndex]);
                    break;

                default:
                    AssimpData assimp = new AssimpData();
                    assimp.LoadFile(ofd.FileName);
                    AssimpMeshSelector selector = new AssimpMeshSelector();
                    selector.LoadMeshes(assimp, Index);

                    if (selector.ShowDialog() == DialogResult.OK)
                    {
                        if (assimp.objects.Count == 0)
                        {
                            MessageBox.Show("No models found!");
                            return;
                        }
                        BfresModelImportSettings settings = new BfresModelImportSettings();
                        settings.SetModelAttributes(assimp.objects[0]);
                        if (settings.ShowDialog() == DialogResult.OK)
                        {
                            GenericObject obj = selector.GetSelectedMesh();

                            Cursor.Current    = Cursors.WaitCursor;
                            VertexBufferIndex = obj.VertexBufferIndex;
                            vertices          = obj.vertices;
                            CreateBoneList(obj, (FMDL)Parent.Parent);
                            VertexSkinCount  = obj.MaxSkinInfluenceCount;
                            vertexAttributes = settings.CreateNewAttributes();
                            lodMeshes        = obj.lodMeshes;
                            CreateNewBoundingBoxes();
                            SaveShape();
                            SaveVertexBuffer();
                            Cursor.Current = Cursors.Default;
                        }
                    }
                    break;
                }
                UpdateVertexData();
            }
        }
Esempio n. 8
0
        //Function addes shapes, vertices and meshes
        public void AddOjects(string FileName, ResFile resFileNX, ResU.ResFile resFileU, bool Replace = true)
        {
            int totalSkinCountLimiter = 0;

            bool IsWiiU = (resFileU != null);

            if (shapes.Count > 0)
            {
                totalSkinCountLimiter = shapes[0].VertexSkinCount;
            }

            int    MatStartIndex = materials.Count;
            string ext           = System.IO.Path.GetExtension(FileName);

            ext = ext.ToLower();

            switch (ext)
            {
            case ".bfobj":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                }
                if (IsWiiU)
                {
                    var shpS          = new ResU.Shape();
                    var vertexBufferU = new ResU.VertexBuffer();
                    shpS.Import(FileName, vertexBufferU, resFileU);

                    FSHP shapeS = new FSHP();
                    shapeS.ShapeU = shpS;
                    BfresWiiU.ReadShapesVertices(shapeS, shpS, vertexBufferU, this);
                    shapes.Add(shapeS);
                    Nodes["FshpFolder"].Nodes.Add(shapeS);
                }
                else
                {
                    Shape        shpS         = new Shape();
                    VertexBuffer vertexBuffer = new VertexBuffer();
                    shpS.Import(FileName, vertexBuffer);

                    FSHP shapeS = new FSHP();
                    shapeS.Shape = shpS;
                    BfresSwitch.ReadShapesVertices(shapeS, shpS, vertexBuffer, this);
                    shapes.Add(shapeS);
                    Nodes["FshpFolder"].Nodes.Add(shapeS);
                }

                IsEdited = true;

                Cursor.Current = Cursors.Default;
                break;

            case ".bfmdl":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                    materials.Clear();
                    Nodes["FmatFolder"].Nodes.Clear();
                }

                if (IsWiiU)
                {
                    var mdlU = new ResU.Model();
                    mdlU.Import(FileName, resFileU);
                    mdlU.Name = Text;
                    BfresWiiU.ReadModel(this, mdlU);
                }
                else
                {
                    Model mdl = new Model();
                    mdl.Import(FileName, resFileNX);
                    mdl.Name = Text;

                    Console.WriteLine(mdl.ShapeCount);
                    Console.WriteLine(mdl.MaterialCount);
                    Console.WriteLine(mdl.VertexBufferCount);
                    Console.WriteLine(mdl.Skeleton.Bones.Count);

                    BfresSwitch.ReadModel(this, mdl);
                }
                IsEdited = true;

                Cursor.Current = Cursors.Default;
                break;

            case ".csv":
                CsvModel csvModel = new CsvModel();
                csvModel.LoadFile(new System.IO.FileStream(FileName, System.IO.FileMode.Open), true);

                if (csvModel.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings csvsettings = new BfresModelImportSettings();
                csvsettings.DisableMaterialEdits();
                csvsettings.SkinCountLimit = totalSkinCountLimiter;
                csvsettings.SetModelAttributes(csvModel.objects[0]);
                if (csvsettings.ShowDialog() == DialogResult.OK)
                {
                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;

                    foreach (STGenericObject obj in csvModel.objects)
                    {
                        FSHP shape = new FSHP();
                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);

                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.MaterialIndex     = 0;
                        shape.vertexAttributes  = csvsettings.CreateNewAttributes();
                        shape.BoneIndex         = 0;
                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        //Todo find better way. Currently uses import settings now
                        shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex));
                        shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
                        shape.BoneIndices     = shape.GetIndices(Skeleton);
                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer();

                        if (IsWiiU)
                        {
                            shape.ShapeU.SubMeshBoundingIndices = new List <ushort>();
                            shape.ShapeU.SubMeshBoundingIndices.Add(0);
                            shape.ShapeU.SubMeshBoundingNodes = new List <ResU.BoundingNode>();
                            shape.ShapeU.SubMeshBoundingNodes.Add(new ResU.BoundingNode()
                            {
                                LeftChildIndex  = 0,
                                NextSibling     = 0,
                                SubMeshIndex    = 0,
                                RightChildIndex = 0,
                                Unknown         = 0,
                                SubMeshCount    = 1,
                            });
                        }

                        if (IsWiiU)
                        {
                            BfresWiiU.ReadShapesVertices(shape, shape.ShapeU, shape.VertexBufferU, this);
                        }
                        else
                        {
                            BfresSwitch.ReadShapesVertices(shape, shape.Shape, shape.VertexBuffer, this);
                        }
                    }
                    Cursor.Current = Cursors.Default;
                }
                IsEdited = true;

                break;

            default:
                AssimpData assimp = new AssimpData();
                assimp.LoadFile(FileName);

                if (assimp.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings settings = new BfresModelImportSettings();
                settings.SetModelAttributes(assimp.objects[0]);
                if (settings.ShowDialog() == DialogResult.OK)
                {
                    bool UseMats = settings.ExternalMaterialPath != string.Empty;

                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;
                    if (Replace && UseMats)
                    {
                        materials.Clear();
                        Nodes["FmatFolder"].Nodes.Clear();
                        MatStartIndex = 0;
                    }
                    if (UseMats)
                    {
                        foreach (STGenericMaterial mat in assimp.materials)
                        {
                            FMAT fmat = new FMAT();

                            if (IsWiiU)
                            {
                                fmat.MaterialU = new ResU.Material();
                                fmat.MaterialU.Import(settings.ExternalMaterialPath, resFileU);
                                BfresWiiU.ReadMaterial(fmat, fmat.MaterialU);
                            }
                            else
                            {
                                fmat.Material = new Material();
                                fmat.Material.Import(settings.ExternalMaterialPath);
                                fmat.ReadMaterial(fmat.Material);
                            }

                            fmat.Text = mat.Text;
                            //Setup placeholder textures
                            //Note we can't add/remove samplers so we must fill these slots
                            foreach (var t in fmat.TextureMaps)
                            {
                                t.wrapModeS = 0;
                                t.wrapModeT = 0;

                                switch (t.Type)
                                {
                                case STGenericMatTexture.TextureType.Diffuse:
                                    t.Name = "Basic_Alb";
                                    break;

                                case STGenericMatTexture.TextureType.Emission:
                                    t.Name = "Basic_Emm";
                                    break;

                                case STGenericMatTexture.TextureType.Normal:
                                    t.Name = "Basic_Nrm";
                                    break;

                                case STGenericMatTexture.TextureType.Specular:
                                    t.Name = "Basic_Spm";
                                    break;

                                case STGenericMatTexture.TextureType.SphereMap:
                                    t.Name = "Basic_Sphere";
                                    break;

                                case STGenericMatTexture.TextureType.Metalness:
                                    t.Name = "Basic_Mtl";
                                    break;

                                case STGenericMatTexture.TextureType.Roughness:
                                    t.Name = "Basic_Rgh";
                                    break;

                                case STGenericMatTexture.TextureType.MRA:
                                    t.Name = "Basic_MRA";
                                    break;

                                case STGenericMatTexture.TextureType.Shadow:
                                    t.Name = "Basic_Bake_st0";
                                    break;

                                case STGenericMatTexture.TextureType.Light:
                                    t.Name = "Basic_Bake_st1";
                                    break;
                                }
                            }

                            if (PluginRuntime.bntxContainers.Count > 0 && Parent != null)
                            {
                                foreach (var node in Parent.Parent.Nodes)
                                {
                                    if (node is BNTX)
                                    {
                                        var bntx = (BNTX)node;

                                        bntx.ImportBasicTextures("Basic_Alb");
                                        bntx.ImportBasicTextures("Basic_Nrm");
                                        bntx.ImportBasicTextures("Basic_Spm");
                                        bntx.ImportBasicTextures("Basic_Sphere");
                                        bntx.ImportBasicTextures("Basic_Mtl");
                                        bntx.ImportBasicTextures("Basic_Rgh");
                                        bntx.ImportBasicTextures("Basic_MRA");
                                        bntx.ImportBasicTextures("Basic_Bake_st0");
                                        bntx.ImportBasicTextures("Basic_Bake_st1");
                                        bntx.ImportBasicTextures("Basic_Emm");
                                    }
                                }
                            }
                            if (PluginRuntime.ftexContainers.Count > 0 && Parent != null)
                            {
                                foreach (var node in Parent.Parent.Nodes)
                                {
                                    if (node is BFRESGroupNode)
                                    {
                                        if (((BFRESGroupNode)node).Type == BRESGroupType.Textures)
                                        {
                                            var ftexCont = (BFRESGroupNode)node;

                                            ftexCont.ImportBasicTextures("Basic_Alb");
                                            ftexCont.ImportBasicTextures("Basic_Nrm");
                                            ftexCont.ImportBasicTextures("Basic_Spm");
                                            ftexCont.ImportBasicTextures("Basic_Sphere");
                                            ftexCont.ImportBasicTextures("Basic_Mtl");
                                            ftexCont.ImportBasicTextures("Basic_Rgh");
                                            ftexCont.ImportBasicTextures("Basic_MRA");
                                            ftexCont.ImportBasicTextures("Basic_Bake_st0");
                                            ftexCont.ImportBasicTextures("Basic_Bake_st1");
                                            ftexCont.ImportBasicTextures("Basic_Emm");
                                        }
                                    }
                                }
                            }

                            foreach (var tex in mat.TextureMaps)
                            {
                                foreach (var t in fmat.TextureMaps)
                                {
                                    if (t.Type == tex.Type)
                                    {
                                        t.Name      = tex.Name;
                                        t.wrapModeS = tex.wrapModeS;
                                        t.wrapModeT = tex.wrapModeT;
                                        t.wrapModeW = tex.wrapModeW;
                                        t.Type      = tex.Type;
                                    }
                                }
                            }

                            List <string> keyList = new List <string>(materials.Keys);
                            fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text);

                            if (IsWiiU)
                            {
                                fmat.MaterialU.Name = Text;
                                fmat.SetMaterial(fmat.MaterialU, resFileU);
                            }
                            else
                            {
                                fmat.Material.Name = Text;
                                fmat.SetMaterial(fmat.Material);
                            }

                            materials.Add(fmat.Text, fmat);
                            Nodes["FmatFolder"].Nodes.Add(fmat);
                        }
                    }

                    if (settings.ImportBones)
                    {
                        if (assimp.skeleton.bones.Count > 0)
                        {
                            Skeleton.bones.Clear();
                            Skeleton.node.Nodes.Clear();

                            if (IsWiiU)
                            {
                                BfresWiiU.SaveSkeleton(Skeleton, assimp.skeleton.bones);
                            }
                            else
                            {
                                BfresSwitch.SaveSkeleton(Skeleton, assimp.skeleton.bones);
                            }
                        }
                    }

                    if (materials.Count <= 0)
                    {
                        //Force material creation if there is none present
                        FMAT fmat = new FMAT();
                        fmat.Text = "NewMaterial";
                        materials.Add(fmat.Text, fmat);
                        Nodes["FmatFolder"].Nodes.Add(fmat);

                        if (IsWiiU)
                        {
                            fmat.MaterialU      = new ResU.Material();
                            fmat.MaterialU.Name = "NewMaterial";
                            BfresWiiU.ReadMaterial(fmat, fmat.MaterialU);
                        }
                        else
                        {
                            fmat.Material      = new Material();
                            fmat.Material.Name = "NewMaterial";
                            fmat.ReadMaterial(fmat.Material);
                        }
                    }

                    foreach (STGenericObject obj in assimp.objects)
                    {
                        FSHP shape = new FSHP();
                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);

                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.vertexAttributes  = settings.CreateNewAttributes();
                        shape.BoneIndex         = obj.BoneIndex;

                        STConsole.WriteLine(Text + " " + obj.MaterialIndex);

                        if (UseMats)
                        {
                            shape.MaterialIndex = obj.MaterialIndex + MatStartIndex;
                        }
                        else
                        {
                            shape.MaterialIndex = 0;
                        }

                        if (shape.MaterialIndex >= materials.Count)
                        {
                            shape.MaterialIndex = 0;
                        }

                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        shape.ApplyImportSettings(settings, GetMaterial(shape.MaterialIndex));
                        shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
                        shape.BoneIndices     = shape.GetIndices(Skeleton);

                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer();

                        if (IsWiiU)
                        {
                            shape.ShapeU.SubMeshBoundingIndices = new List <ushort>();
                            shape.ShapeU.SubMeshBoundingIndices.Add(0);
                            shape.ShapeU.SubMeshBoundingNodes = new List <ResU.BoundingNode>();
                            shape.ShapeU.SubMeshBoundingNodes.Add(new ResU.BoundingNode()
                            {
                                LeftChildIndex  = 0,
                                NextSibling     = 0,
                                SubMeshIndex    = 0,
                                RightChildIndex = 0,
                                Unknown         = 0,
                                SubMeshCount    = 1,
                            });
                        }

                        List <string> keyList = shapes.Select(o => o.Text).ToList();
                        shape.Text = Utils.RenameDuplicateString(keyList, shape.Text);

                        if (IsWiiU)
                        {
                            BfresWiiU.ReadShapesVertices(shape, shape.ShapeU, shape.VertexBufferU, this);
                        }
                        else
                        {
                            BfresSwitch.ReadShapesVertices(shape, shape.Shape, shape.VertexBuffer, this);
                        }
                    }


                    IsEdited = true;

                    Cursor.Current = Cursors.Default;
                }
                break;
            }

            if (IsEdited)
            {
                UpdateVertexData();
            }
        }