예제 #1
0
        private void AddTextureFTEX(BFRESGroupNode ftexCont)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = FileFilters.FTEX;
            ofd.Multiselect = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string ResourceName = Path.GetFileNameWithoutExtension(ofd.FileName);

                FTEX ftex = new FTEX();
                ftex.texture = new ResU.Texture();
                ftex.Text    = ResourceName;
                ftex.Replace(ofd.FileName);

                if (ftex.IsEdited)
                {
                    ftexCont.AddNode(ftex);
                }
                else
                {
                    ftex.Unload();
                }

                listView1.Items.Add(ftex.Text, ftex.Text, 0);

                int lastItem = listView1.Items.Count - 1;
                listView1.Items[lastItem].Selected = true;
                listView1.Select();
            }
        }
예제 #2
0
        private void LoadAnimations(TreeNodeCollection nodes)
        {
            string cbText = animTypeCB.GetItemText(animTypeCB.SelectedItem);

            animTreeView.Nodes.Clear();

            foreach (var node in nodes)
            {
                if (node is BFRESGroupNode)
                {
                    BFRESGroupNode group = (BFRESGroupNode)node;

                    switch (group.Type)
                    {
                    case BRESGroupType.SkeletalAnim:
                    case BRESGroupType.MaterialAnim:
                    case BRESGroupType.BoneVisAnim:
                    case BRESGroupType.ShapeAnim:
                    case BRESGroupType.SceneAnim:
                    case BRESGroupType.MatVisAnim:
                    case BRESGroupType.ShaderParamAnim:
                    case BRESGroupType.ColorAnim:
                    case BRESGroupType.TexSrtAnim:
                    case BRESGroupType.TexPatAnim:
                        AddAnims(group);
                        break;
                    }
                }
            }
        }
예제 #3
0
        public void NewEmbeddedFile()
        {
            BFRESGroupNode   group = new BFRESGroupNode();
            ExternalFileData fshu  = new ExternalFileData("NewFile", new byte[0]);

            group.AddNode(fshu, "NewFile");
            SetupAddedNode(group, fshu);
        }
예제 #4
0
        public void ImportEmbeddedFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            BFRESGroupNode group = new BFRESGroupNode();

            group.Import(ofd.FileNames);
        }
예제 #5
0
        private static bool BindFTEX(BFRESGroupNode ftexContainer, MatTexture tex, SF.Shader shader, string activeTex)
        {
            FTEX ftex = (FTEX)ftexContainer.ResourceNodes[activeTex];

            if (ftex.RenderableTex == null || !ftex.RenderableTex.GLInitialized)
            {
                ftex.LoadOpenGLTexture();
            }

            BindGLTexture(tex, shader, ftex);

            return(ftex.RenderableTex.GLInitialized);
        }
예제 #6
0
        public void NewModel()
        {
            BFRESGroupNode group = new BFRESGroupNode();
            FMDL           anim  = new FMDL();

            if (IsWiiU)
            {
                BfresWiiU.ReadModel(anim, new ResU.Model());
            }
            else
            {
                BfresSwitch.ReadModel(anim, new ResNX.Model());
            }

            group.AddNode(anim, "NewModel");
        }
예제 #7
0
        private void stComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = stComboBox1.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            if (PluginRuntime.bntxContainers.Count > 0)
            {
                activeBntx = PluginRuntime.bntxContainers[index];

                LoadTexture();
            }
            if (PluginRuntime.ftexContainers.Count > 0)
            {
                activeFtexContainer = PluginRuntime.ftexContainers[index];

                LoadTexture();
            }
        }
예제 #8
0
 private void SetupAddedNode(BFRESGroupNode group, STGenericWrapper node)
 {
     Nodes.Add(group);
     TreeView.SelectedNode = node;
 }
예제 #9
0
        public GifToTexturePatternAnimation(string FileName, BFRESGroupNode TargetFTEXFolder, FTXP ftxp)
        {
            string TextureName = System.IO.Path.GetFileNameWithoutExtension(FileName);

            string ext = Utils.GetExtension(FileName);

            ImageKeyFrame[] Images = new ImageKeyFrame[0];

            if (ext == ".gif")
            {
                Image gifImg = Image.FromFile(FileName);

                //Add all the images
                Images = GetImages(gifImg);
            }
            if (ext == ".png" || ext == ".apng")
            {
                APNG png = new APNG();
                png.Load(FileName);
                for (int i = 0; i < png.NumEmbeddedPNG; i++)
                {
                    Images[i] = new ImageKeyFrame()
                    {
                        Frame = i,
                        Image = png.ToBitmap(i)
                    };
                }
            }

            TargetFTEXFolder.ImportTexture(Images, TextureName);

            //Now load the key data to the animation
            ftxp.TexPatternAnim             = new ResU.TexPatternAnim();
            ftxp.TexPatternAnim.Name        = ftxp.Text;
            ftxp.TexPatternAnim.Path        = "";
            ftxp.TexPatternAnim.FrameCount  = Images.Length;
            ftxp.TexPatternAnim.TextureRefs = new ResU.ResDict <ResU.TextureRef>();
            foreach (ImageKeyFrame key in Images)
            {
                string name = $"{TextureName}{key.Frame}";

                ftxp.TexPatternAnim.TextureRefs.Add($"{TextureName}{key.Frame}",
                                                    new ResU.TextureRef()
                {
                    Name    = $"{name}",
                    Texture = ((FTEX)TargetFTEXFolder.ResourceNodes[name]).texture,
                });
            }

            var material = new ResU.TexPatternMatAnim();

            material.Name = "NewMaterial";

            material.PatternAnimInfos = new List <ResU.PatternAnimInfo>();

            material.BaseDataList.Add(0);

            ResU.PatternAnimInfo info = new ResU.PatternAnimInfo();
            info.CurveIndex   = 0;
            info.SubBindIndex = -1;
            info.Name         = "_a0";
            material.PatternAnimInfos.Add(info);

            ftxp.TexPatternAnim.TexPatternMatAnims.Add(material);
            ResU.AnimCurve curve = new ResU.AnimCurve();
            curve.AnimDataOffset = 0;
            curve.CurveType      = ResU.AnimCurveType.StepInt;
            curve.Delta          = 0;
            curve.EndFrame       = Images.Length;
            curve.StartFrame     = 0;
            curve.FrameType      = ResU.AnimCurveFrameType.Byte;
            curve.Scale          = 1;
            curve.Offset         = 0;
            curve.Frames         = new float[(int)curve.EndFrame];

            for (int i = 0; i < curve.EndFrame; i++)
            {
                curve.Frames[i] = Images[i].Frame;
            }

            curve.Keys = new float[(int)curve.Frames.Length, 1];
            for (int i = 0; i < (ushort)curve.Keys.Length; i++)
            {
                int index = ftxp.TexPatternAnim.TextureRefs.IndexOf($"{TextureName}{Images[i].Frame}");
                curve.Keys[i, 0] = index;
            }

            material.Curves.Add(curve);

            ftxp.UpdateMaterialBinds();
        }