Пример #1
0
        public void Import(string[] FileNames, ResNX.ResFile resFileNX, ResU.ResFile resFileU)
        {
            if (Type == BRESGroupType.Textures)
            {
                ImportTexture(FileNames);
                return;
            }

            foreach (string FileName in FileNames)
            {
                string ResourceName    = Path.GetFileNameWithoutExtension(FileName);
                string ResourceNameExt = Path.GetFileName(FileName);

                string extension = Path.GetExtension(FileName);

                switch (Type)
                {
                case BRESGroupType.Models:
                    FMDL fmdl = NewModel(false);
                    fmdl.Text = ResourceName;
                    fmdl.Replace(FileName, resFileNX, resFileU);
                    fmdl.UpdateVertexData();
                    AddNode(fmdl);
                    break;

                case BRESGroupType.SkeletalAnim:
                    FSKA fska = new FSKA();
                    fska.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fska.SkeletalAnimU = new ResU.SkeletalAnim();
                    }
                    else
                    {
                        fska.SkeletalAnim = new ResNX.SkeletalAnim();
                    }

                    fska.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fska);
                    break;

                case BRESGroupType.ShaderParamAnim:
                    if (IsWiiU)
                    {
                        FSHU fshu = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.ShaderParam);
                        fshu.Text = ResourceName;
                        fshu.Replace(FileName, resFileU);
                        Nodes.Add(fshu);
                    }
                    else
                    {
                        FMAA fmaaPrm = new FMAA(new ResNX.MaterialAnim());
                        fmaaPrm.Text = ResourceName;
                        fmaaPrm.Replace(FileName);
                        Nodes.Add(fmaaPrm);
                    }
                    break;

                case BRESGroupType.ColorAnim:
                    if (IsWiiU)
                    {
                        FSHU fclh = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.Color);
                        fclh.Text = ResourceName;
                        fclh.Replace(FileName, resFileU);
                        Nodes.Add(fclh);
                    }
                    else
                    {
                        FMAA fmaaClr = new FMAA(new ResNX.MaterialAnim());
                        fmaaClr.Text = ResourceName;
                        fmaaClr.Replace(FileName);
                        Nodes.Add(fmaaClr);
                    }
                    break;

                case BRESGroupType.TexSrtAnim:
                    if (IsWiiU)
                    {
                        FSHU fsth = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.TextureSrt);
                        fsth.Text = ResourceName;
                        fsth.Replace(FileName, resFileU);
                        Nodes.Add(fsth);
                    }
                    else
                    {
                        FMAA fmaaSrt = new FMAA(new ResNX.MaterialAnim());
                        fmaaSrt.Text = ResourceName;
                        fmaaSrt.Replace(FileName);
                        Nodes.Add(fmaaSrt);
                    }
                    break;

                case BRESGroupType.TexPatAnim:
                    if (IsWiiU)
                    {
                        FTXP ftxp = new FTXP(new ResU.TexPatternAnim());
                        ftxp.Text = ResourceName;
                        ftxp.Replace(FileName, resFileU);
                        Nodes.Add(ftxp);
                    }
                    else
                    {
                        FMAA fmaaTxp = new FMAA(new ResNX.MaterialAnim());
                        fmaaTxp.Text = ResourceName;
                        fmaaTxp.Replace(FileName);
                        Nodes.Add(fmaaTxp);
                    }


                    break;

                case BRESGroupType.BoneVisAnim:
                    FVIS fbnv = new FVIS();
                    fbnv.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fbnv.VisibilityAnimU = new ResU.VisibilityAnim()
                        {
                            Type = ResU.VisibilityAnimType.Bone
                        }
                    }
                    ;
                    else
                    {
                        fbnv.VisibilityAnim = new ResNX.VisibilityAnim();
                    }

                    fbnv.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fbnv);
                    break;

                case BRESGroupType.MatVisAnim:
                    if (IsWiiU)
                    {
                        FVIS fmtv = new FVIS(new ResU.VisibilityAnim()
                        {
                            Type = ResU.VisibilityAnimType.Material
                        });
                        fmtv.Text = ResourceName;
                        fmtv.Replace(FileName, resFileNX, resFileU);
                        Nodes.Add(fmtv);
                    }
                    else
                    {
                        FMAA fmaaVis = new FMAA(new ResNX.MaterialAnim());
                        fmaaVis.Text = ResourceName;
                        fmaaVis.Replace(FileName);
                        Nodes.Add(fmaaVis);
                    }
                    break;

                case BRESGroupType.ShapeAnim:
                    FSHA fsha = new FSHA();
                    fsha.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fsha.ShapeAnimU = new ResU.ShapeAnim();
                    }
                    else
                    {
                        fsha.ShapeAnim = new ResNX.ShapeAnim();
                    }

                    fsha.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fsha);
                    break;

                case BRESGroupType.SceneAnim:
                    FSCN fscn = new FSCN();
                    fscn.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fscn.SceneAnimU = new ResU.SceneAnim();
                    }
                    else
                    {
                        fscn.SceneAnim = new ResNX.SceneAnim();
                    }

                    fscn.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fscn);
                    break;

                case BRESGroupType.Embedded:
                    ExternalFileData ext = new ExternalFileData(ResourceNameExt, File.ReadAllBytes(FileName));
                    ext.Replace(FileName);
                    Nodes.Add(ext);
                    break;

                case BRESGroupType.MaterialAnim:
                    FMAA fmaa = new FMAA(new ResNX.MaterialAnim());
                    fmaa.Replace(FileName);
                    Nodes.Add(fmaa);
                    break;
                }
            }
        }
Пример #2
0
        public void Import(string[] FileNames, ResNX.ResFile resFileNX, ResU.ResFile resFileU)
        {
            if (Type == BRESGroupType.Textures)
            {
                ImportTexture(FileNames);
                return;
            }

            foreach (string FileName in FileNames)
            {
                string ResourceName = Path.GetFileNameWithoutExtension(FileName);
                string extension    = Path.GetExtension(FileName);

                switch (Type)
                {
                case BRESGroupType.Models:
                    FMDL fmdl = new FMDL();
                    fmdl.Text = ResourceName;

                    if (IsWiiU)
                    {
                        fmdl.ModelU      = new ResU.Model();
                        fmdl.ModelU      = new ResU.Model();
                        fmdl.ModelU.Name = ResourceName;

                        var skeleton = new ResU.Skeleton();

                        //Create skeleton with empty bone
                        skeleton.Bones.Add("Root", new ResU.Bone()
                        {
                            Name = "Root"
                        });

                        fmdl.ModelU.Skeleton = skeleton;

                        BfresWiiU.ReadModel(fmdl, fmdl.ModelU);
                        ((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton);
                    }
                    else
                    {
                        fmdl.Model      = new ResNX.Model();
                        fmdl.Model.Name = ResourceName;

                        //Create skeleton with empty bone
                        var skeleton = new ResNX.Skeleton();
                        skeleton.Bones.Add(new ResNX.Bone()
                        {
                            Name = "Root"
                        });

                        fmdl.Model.Skeleton = skeleton;

                        BfresSwitch.ReadModel(fmdl, fmdl.Model);
                        ((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton);
                    }
                    fmdl.Replace(FileName, resFileNX, resFileU);

                    Nodes.Add(fmdl);


                    fmdl.UpdateVertexData();
                    break;

                case BRESGroupType.SkeletalAnim:
                    FSKA fska = new FSKA();
                    fska.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fska.SkeletalAnimU = new ResU.SkeletalAnim();
                    }
                    else
                    {
                        fska.SkeletalAnim = new ResNX.SkeletalAnim();
                    }

                    fska.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fska);
                    break;

                case BRESGroupType.ShaderParamAnim:
                    FSHU fshu = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.ShaderParam);
                    fshu.Text = ResourceName;
                    fshu.Replace(FileName, resFileU);
                    Nodes.Add(fshu);
                    break;

                case BRESGroupType.ColorAnim:
                    FSHU fclh = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.Color);
                    fclh.Text = ResourceName;
                    fclh.Replace(FileName, resFileU);
                    Nodes.Add(fclh);
                    break;

                case BRESGroupType.TexSrtAnim:
                    FSHU fsth = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.TextureSrt);
                    fsth.Text = ResourceName;
                    fsth.Replace(FileName, resFileU);
                    Nodes.Add(fsth);
                    break;

                case BRESGroupType.TexPatAnim:
                    FTXP ftxp = new FTXP(new ResU.TexPatternAnim());
                    ftxp.Text = ResourceName;
                    ftxp.Replace(FileName, resFileU);
                    Nodes.Add(ftxp);
                    break;

                case BRESGroupType.BoneVisAnim:
                    FVIS fbnv = new FVIS();
                    fbnv.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fbnv.VisibilityAnimU = new ResU.VisibilityAnim()
                        {
                            Type = ResU.VisibilityAnimType.Bone
                        }
                    }
                    ;
                    else
                    {
                        fbnv.VisibilityAnim = new ResNX.VisibilityAnim();
                    }

                    fbnv.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fbnv);
                    break;

                case BRESGroupType.MatVisAnim:
                    FVIS fmtv = new FVIS(new ResU.VisibilityAnim()
                    {
                        Type = ResU.VisibilityAnimType.Material
                    });
                    fmtv.Text = ResourceName;
                    fmtv.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fmtv);
                    break;

                case BRESGroupType.ShapeAnim:
                    FSHA fsha = new FSHA();
                    fsha.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fsha.ShapeAnimU = new ResU.ShapeAnim();
                    }
                    else
                    {
                        fsha.ShapeAnim = new ResNX.ShapeAnim();
                    }

                    fsha.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fsha);
                    break;

                case BRESGroupType.SceneAnim:
                    FSCN fscn = new FSCN();
                    fscn.Text = ResourceName;
                    if (IsWiiU)
                    {
                        fscn.SceneAnimU = new ResU.SceneAnim();
                    }
                    else
                    {
                        fscn.SceneAnim = new ResNX.SceneAnim();
                    }

                    fscn.Replace(FileName, resFileNX, resFileU);
                    Nodes.Add(fscn);
                    break;

                case BRESGroupType.Embedded:
                    ExternalFileData ext = new ExternalFileData(ResourceName, File.ReadAllBytes(FileName));
                    ext.Replace(FileName);
                    Nodes.Add(ext);
                    break;

                case BRESGroupType.MaterialAnim:
                    FMAA fmaa = new FMAA(new ResNX.MaterialAnim(), MaterialAnimation.AnimationType.ShaderParam);
                    fmaa.Replace(FileName);
                    Nodes.Add(fmaa);
                    break;
                }
            }
        }