Exemple #1
0
        public static void SetMaterials(BxlytShader shader, GCBLO.Material material,
                                        BasePane pane, Dictionary <string, STGenericTexture> textures)
        {
            var rotationMatrix = pane.GetRotationMatrix();

            shader.SetMatrix("rotationMatrix", ref rotationMatrix);

            STColor8 WhiteColor = material.WhiteColor;
            STColor8 BlackColor = material.BlackColor;

            shader.SetColor("whiteColor", WhiteColor.Color);
            shader.SetColor("blackColor", BlackColor.Color);
            shader.SetInt("debugShading", (int)Runtime.LayoutEditor.Shading);
            shader.SetInt("numTextureMaps", material.TextureMaps.Length);
            shader.SetVec2("uvScale0", new Vector2(1, 1));
            shader.SetFloat("uvRotate0", 0);
            shader.SetVec2("uvTranslate0", new Vector2(0, 0));
            shader.SetInt("flipTexture", 0);
            shader.SetInt("numTevStages", 0);
            shader.SetBool("AlphaInterpolation", material.AlphaInterpolation);
            shader.SetVec4("IndirectMat0", new Vector4(1, 1, 0, 0));
            shader.SetVec4("IndirectMat1", new Vector4(1, 1, 0, 0));
            shader.SetInt("tevTexMode", 0);
            shader.SetInt($"texCoords0GenType", 0);
            shader.SetInt($"texCoords0Source", 0);

            LoadTextureUniforms(shader, material, textures);
            LoadDefaultBlending();
        }
        private void DrawDefaultPane(BasePane pane)
        {
            Vector2[] TexCoords = new Vector2[] {
                new Vector2(1, 1),
                new Vector2(0, 1),
                new Vector2(0, 0),
                new Vector2(1, 0)
            };

            Color color = Color.White;

            if (SelectedPanes.Contains(pane))
            {
                color = Color.Red;
            }

            Color[] Colors = new Color[] {
                color,
                color,
                color,
                color,
            };

            DrawRectangle(pane.Rectangle, TexCoords, Colors);
        }
        public void LoadPane(BasePane pane, PaneEditor paneEditor)
        {
            parentEditor = paneEditor;
            Loaded       = false;

            ActivePane = pane;

            SetUIState();

            nameTB.Bind(pane, "Name");
            userNameTB.Bind(pane, "UserDataInfo");
            partPaneScalingCB.SelectedItem = (PartPaneScaling)pane.PaneMagFlags;

            SetTransform();

            alphaChildrenChk.Bind(pane, "InfluenceAlpha");
            paneVisibleChk.Bind(pane, "Visible");

            alphaUD.Value = pane.Alpha;
            alphaSelectorHorizontalPanel1.Alpha = pane.Alpha;
            SetOrientation();
            SetParentOrientation();

            Loaded = true;
        }
Exemple #4
0
            private void WritePanes(FileWriter writer, BasePane pane, LayoutHeader header, ref int sectionCount)
            {
                WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
                sectionCount++;

                if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null &&
                    ((IUserDataContainer)pane).UserData.Entries.Count > 0)
                {
                    var userData = ((IUserDataContainer)pane).UserData;
                    WriteSection(writer, "usd1", userData, () => userData.Write(writer, this));
                    sectionCount++;
                }

                if (pane.HasChildern)
                {
                    sectionCount += 2;

                    //Write start of children section
                    WriteSection(writer, "pas1", null);

                    foreach (var child in pane.Childern)
                    {
                        WritePanes(writer, child, header, ref sectionCount);
                    }

                    //Write pae1 of children section
                    WriteSection(writer, "pae1", null);
                }
            }
        public BasePane AddNewTextPane()
        {
            NewTextboxDialog newTextDlg = new NewTextboxDialog();

            newTextDlg.LoadFonts(ActiveLayout.Fonts);
            if (newTextDlg.ShowDialog() == DialogResult.OK)
            {
                string font      = newTextDlg.GetFont();
                int    fontIndex = ActiveLayout.AddFont(font);
                string text      = newTextDlg.GetText();

                BasePane pane = null;
                if (ActiveLayout is BFLYT.Header)
                {
                    pane = new BFLYT.TXT1((BFLYT.Header)ActiveLayout, RenamePane("T_text"));
                }

                if (pane != null)
                {
                    ((ITextPane)pane).FontIndex = (ushort)fontIndex;
                    ((ITextPane)pane).FontName  = font;
                    ((ITextPane)pane).Text      = text;

                    pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
                    ((ITextPane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((ITextPane)pane).Material);
                    ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
                }

                return(pane);
            }
            else
            {
                return(null);
            }
        }
        private void DrawRootPane(BasePane pane)
        {
            Color color = Color.Black;

            if (SelectedPanes.Contains(pane))
            {
                color = Color.Red;
            }

            CustomRectangle rect = pane.CreateRectangle();

            //Draw a quad which is the backcolor but lighter
            GL.Begin(PrimitiveType.Quads);
            GL.Color3(BackgroundColor.Lighten(10));
            GL.Vertex2(rect.LeftPoint, rect.TopPoint);
            GL.Vertex2(rect.RightPoint, rect.TopPoint);
            GL.Vertex2(rect.RightPoint, rect.BottomPoint);
            GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
            GL.End();

            //Draw outline of root pane
            GL.Begin(PrimitiveType.LineLoop);
            GL.PolygonOffset(0.5f, 2);
            GL.LineWidth(33);
            GL.Color3(color);
            GL.Vertex2(rect.LeftPoint, rect.TopPoint);
            GL.Vertex2(rect.RightPoint, rect.TopPoint);
            GL.Vertex2(rect.RightPoint, rect.BottomPoint);
            GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
            GL.End();
        }
Exemple #7
0
        //For non material panes
        public void SetBasic(BasePane pane, Color color)
        {
            var rotationMatrix = pane.GetRotationMatrix();

            SetMatrix("rotationMatrix", ref rotationMatrix);
            SetColor("color", color);
        }
Exemple #8
0
                public PaneInfo(BasePane pane, BasePane parent)
                {
                    Pane   = pane;
                    Parent = parent;
                    if (parent == null)
                    {
                        throw new Exception("parent is null!");
                    }

                    //We need to add any materials that the material referenced
                    if (pane is IPicturePane)
                    {
                        Materials.Add(((IPicturePane)pane).Material);
                    }
                    else if (pane is ITextPane)
                    {
                        Materials.Add(((ITextPane)pane).Material);
                    }
                    else if (pane is IWindowPane)
                    {
                        var wnd = pane as IWindowPane;

                        Materials.Add(wnd.Content.Material);
                        foreach (var windowFrame in wnd.WindowFrames)
                        {
                            Materials.Add(windowFrame.Material);
                        }
                    }

                    Console.WriteLine($"Pane Undo {pane.Name} {pane} mats " + Materials.Count);
                }
Exemple #9
0
 private void SetPane(BasePane pane, BasePane parentPane)
 {
     if (parentPane != null)
     {
         parentPane.Childern.Add(pane);
         pane.Parent = parentPane;
     }
 }
 private void GetGroupPanes(BasePane pane, ref List <BasePane> panes)
 {
     panes.Add(pane);
     foreach (var childPane in pane.Childern)
     {
         GetPanes(childPane, ref panes);
     }
 }
Exemple #11
0
 private void LoadVisibiltyGroup(BasePane pane, LytVisibiltyGroup group)
 {
     if (group.AnimTrack.HasKeys)
     {
         var track = group.AnimTrack;
         var value = track.GetFrameValue(Frame, StartFrame);
         pane.animController.Visibile = value == 1 ? true : false;
     }
 }
 public void ShowPaneEditor(BasePane pane)
 {
     /*     if (LayoutPaneEditor == null)
      *       LayoutPaneEditor = new PaneEditor();
      *
      *   LayoutPaneEditor.PropertyChanged += OnPanePropertyChanged;
      *   LayoutPaneEditor.LoadPane(pane);
      *   LayoutPaneEditor.Show();*/
 }
        public void LoadPane(BasePane pane, LayoutEditor editor)
        {
            ActivePane   = pane;
            ParentEditor = editor;

            animationCB.Items.Clear();
            if (pane == null)
            {
                return;               //No pane is selected then jut reset and return
            }
            SearchActiveAnimations(pane);
        }
        private void SearchActiveAnimations(BasePane pane)
        {
            Console.WriteLine($"SearchActiveAnimations {pane.Name} {pane.LayoutFile == null}");

            if (pane.LayoutFile == null)
            {
                return;
            }

            var    animations = GetAnimations();
            var    material   = pane.TryGetActiveMaterial();
            string matName    = material != null ? material.Name : "";

            var archive = pane.LayoutFile.FileInfo.IFileInfo.ArchiveParent;

            if (archive != null)
            {
                foreach (var file in archive.Files)
                {
                    string ext     = Utils.GetExtension(file.FileName);
                    bool   isBxlan = ext == ".bflan" || ext == ".bclan" || ext == ".brlan";
                    if (isBxlan && !animations.Any(x => x.FileName == file.FileName))
                    {
                        if (BxlanHeader.ContainsEntry(file.FileData, new string[2] {
                            pane.Name, matName
                        }))
                        {
                            animationCB.Items.Add(new AnimationComboboxItem(file.FileName)
                            {
                                Tag = file
                            });
                        }
                    }
                }
            }

            for (int i = 0; i < animations?.Count; i++)
            {
                if (animations[i].ContainsEntry(pane.Name) || animations[i].ContainsEntry(matName))
                {
                    animationCB.Items.Add(new AnimationComboboxItem(animations[i].FileName)
                    {
                        Tag = animations[i]
                    });
                }
            }

            if (animationCB.Items.Count > 0)
            {
                animationCB.SelectedIndex = 0;
            }
        }
        public void UpdateHiearchyNodeSelection(BasePane pane)
        {
            var nodeWrapper = pane.NodeWrapper;

            if (nodeWrapper == null)
            {
                return;
            }

            isSelectedInViewer = true;
            LayoutHierarchy?.SelectNode(nodeWrapper);
            isSelectedInViewer = false;
        }
        private void SearchHit(BasePane pane, int X, int Y, ref BasePane SelectedPane)
        {
            if (pane.IsHit(X, Y))
            {
                SelectedPane = pane;
                return;
            }

            foreach (var childPane in pane.Childern)
            {
                SearchHit(childPane, X, Y, ref SelectedPane);
            }
        }
Exemple #17
0
        public void LoadUserData(BasePane pane, UserData UserData)
        {
            activePane = pane;
            if (UserData != null)
            {
                listViewCustom1.Items.Clear();

                ActiveUserData = UserData;
                foreach (var item in ActiveUserData.Entries)
                {
                    LoadUserData(item);
                }
            }
        }
        public void AddNewPastedPane(BasePane pane)
        {
            string name        = pane.Name;
            string numberedEnd = pane.Name.Split('_').LastOrDefault().Replace("_", string.Empty);

            if (numberedEnd.All(char.IsDigit))
            {
                name = name.Replace(numberedEnd, string.Empty);
            }

            pane.Name        = RenamePane(name);
            pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
            ActiveLayout.AddPane(pane, pane.Parent);
        }
Exemple #19
0
        public static void SetMaterials(BxlytShader shader, BCLYT.Material material, BasePane pane, Dictionary <string, STGenericTexture> textures)
        {
            Matrix4 rotationX      = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(pane.Rotate.X));
            Matrix4 rotationY      = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(pane.Rotate.Y));
            Matrix4 rotationZ      = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(pane.Rotate.Z));
            var     rotationMatrix = rotationX * rotationY * rotationZ;

            shader.SetMatrix("rotationMatrix", ref rotationMatrix);

            shader.SetColor("whiteColor", material.TevConstantColors[0].Color);
            shader.SetColor("blackColor", material.TevColor.Color);
            shader.SetInt("debugShading", (int)Runtime.LayoutEditor.Shading);
            shader.SetInt("numTextureMaps", material.TextureMaps.Length);
            shader.SetVec2("uvScale0", new Vector2(1, 1));
            shader.SetFloat("uvRotate0", 0);
            shader.SetVec2("uvTranslate0", new Vector2(0, 0));
            shader.SetInt("flipTexture", 0);
            shader.SetBool("ThresholdingAlphaInterpolation", material.ThresholdingAlphaInterpolation);
            shader.SetInt($"texCoords0GenType", 0);
            shader.SetInt($"texCoords0Source", 0);

            BindTextureUniforms(shader, material);

            string textureMap0 = "";

            if (material.TextureMaps.Length > 0)
            {
                textureMap0 = material.GetTexture(0);
            }

            if (textures.ContainsKey(textureMap0))
            {
                GL.ActiveTexture(TextureUnit.Texture0);
                shader.SetInt("textures0", 0);
                bool isBinded = BxlytToGL.BindGLTexture(material.TextureMaps[0], textures[textureMap0]);
                if (isBinded)
                {
                    shader.SetInt("hasTexture0", 1);
                }
            }

            if (material.TextureTransforms.Length > 0)
            {
                var transform = material.TextureTransforms[0];
                shader.SetVec2("uvScale0", new Vector2(transform.Scale.X, transform.Scale.Y));
                shader.SetFloat("uvRotate0", transform.Rotate);
                shader.SetVec2("uvTranslate0", new Vector2(transform.Translate.X, transform.Translate.Y));
            }
        }
        public BasePane AddNewNullPane()
        {
            BasePane pane = null;

            if (ActiveLayout is BFLYT.Header)
            {
                pane = new BFLYT.PAN1((BFLYT.Header)ActiveLayout, RenamePane("N_null"));
            }

            if (pane != null)
            {
                pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
                ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
            }

            return(pane);
        }
Exemple #21
0
        public void LoadPane(BasePane pane, PaneEditor paneEditor)
        {
            ParentEditor = paneEditor;

            var    animations = ParentEditor.GetAnimations();
            var    material   = pane.TryGetActiveMaterial();
            string matName    = material != null ? material.Name : "";

            listViewCustom1.Items.Clear();

            var archive = pane.LayoutFile.FileInfo.IFileInfo.ArchiveParent;

            if (archive != null)
            {
                foreach (var file in archive.Files)
                {
                    if (Utils.GetExtension(file.FileName) == ".bflan" &&
                        !animations.Any(x => x.FileName == file.FileName))
                    {
                        if (BxlanHeader.ContainsEntry(file.FileData, new string[2] {
                            pane.Name, matName
                        }))
                        {
                            listViewCustom1.Items.Add(new ListViewItem(file.FileName)
                            {
                                Tag = file
                            });
                        }
                    }
                }
            }

            for (int i = 0; i < animations?.Count; i++)
            {
                if (animations[i].ContainsEntry(pane.Name) || animations[i].ContainsEntry(matName))
                {
                    listViewCustom1.Items.Add(new ListViewItem(animations[i].FileName)
                    {
                        Tag = animations[i]
                    });
                }
            }
            LayoutAnimEditorBasic editor = new LayoutAnimEditorBasic();

            stPanel1.Controls.Add(editor);
        }
        private void LoadPane(BasePane pane, TreeNode parent = null)
        {
            var paneNode = CreatePaneWrapper(pane);

            if (parent == null)
            {
                treeView1.Nodes.Add(paneNode);
            }
            else
            {
                parent.Nodes.Add(paneNode);
            }

            foreach (var childPane in pane.Childern)
            {
                LoadPane(childPane, paneNode);
            }
        }
        public BasePane AddNewPicturePane()
        {
            BasePane pane = null;

            if (ActiveLayout is BFLYT.Header)
            {
                pane = new BFLYT.PIC1((BFLYT.Header)ActiveLayout, RenamePane("P_pict"));
            }

            if (pane != null)
            {
                pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
                ((IPicturePane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((IPicturePane)pane).Material);
                ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
            }

            return(pane);
        }
Exemple #24
0
 private void LoadPaneAnimation(BasePane pane, LytAnimGroup group)
 {
     //Sub groups store tag entries like vertex colors, srt, etc
     foreach (var subGroup in group.SubAnimGroups)
     {
         if (subGroup is LytVertexColorGroup)
         {
             LoadVertexColorGroup(pane, (LytVertexColorGroup)subGroup);
         }
         else if (subGroup is LytPaneSRTGroup)
         {
             LoadPaneSRTGroup(pane, (LytPaneSRTGroup)subGroup);
         }
         else if (subGroup is LytVisibiltyGroup)
         {
             LoadVisibiltyGroup(pane, (LytVisibiltyGroup)subGroup);
         }
     }
 }
        public void SetPane(float frame, float startFrame, BasePane pane, List <STAnimGroup> groups)
        {
            paneVisibleChkBox.Checked           = pane.Visible;
            alphaSelectorHorizontalPanel1.Alpha = pane.Alpha;
            alphaUD.Value = pane.Alpha;

            foreach (var group in groups)
            {
                if (group is LytVisibiltyGroup)
                {
                    var track = ((LytVisibiltyGroup)group).GetTrack(0);
                    if (track.HasKeys)
                    {
                        bool visbile = track.GetFrameValue(frame, startFrame) == 1;
                        paneVisibleChkBox.Checked = visbile;
                        bool keyed = track.IsKeyed(frame - startFrame);

                        if (keyed)
                        {
                            paneVisibleChkBox.BackColor = Color.FromArgb(255, 150, 106, 18);
                        }
                        else
                        {
                            paneVisibleChkBox.BackColor = FormThemes.BaseTheme.CheckBoxBackColor;
                        }
                    }
                }
                else if (group is LytVertexColorGroup)
                {
                    var track = ((LytVertexColorGroup)group).GetTrack(16);
                    if (track.HasKeys)
                    {
                        byte alpha = (byte)track.GetFrameValue(frame);
                        alphaUD.Value = alpha;
                        alphaSelectorHorizontalPanel1.Alpha = alpha;
                        bool keyed = track.IsKeyed(frame);

                        SetValue(alphaUD, alpha, keyed);
                    }
                }
            }
        }
Exemple #26
0
        private void LoadVertexColorGroup(BasePane pane, LytVertexColorGroup group)
        {
            for (int i = 0; i < 17; i++)
            {
                if (group.GetTrack(i).HasKeys)
                {
                    var track  = group.GetTrack(i);
                    var value  = track.GetFrameValue(Frame, StartFrame);
                    var target = (LVCTarget)i;

                    if (!pane.animController.PaneVertexColors.ContainsKey(target))
                    {
                        pane.animController.PaneVertexColors.Add(target, value);
                    }
                    else
                    {
                        pane.animController.PaneVertexColors[target] = value;
                    }
                }
            }
        }
Exemple #27
0
            private void WriteGroupPanes(FileWriter writer, BasePane pane, LayoutHeader header, ref int sectionCount)
            {
                WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
                sectionCount++;

                if (pane.HasChildern)
                {
                    sectionCount += 2;

                    //Write start of children section
                    WriteSection(writer, "grs1", null);

                    foreach (var child in pane.Childern)
                    {
                        WriteGroupPanes(writer, child, header, ref sectionCount);
                    }

                    //Write pae1 of children section
                    WriteSection(writer, "gre1", null);
                }
            }
Exemple #28
0
        private void LoadPaneSRTGroup(BasePane pane, LytPaneSRTGroup group)
        {
            for (int i = 0; i < 10; i++)
            {
                if (group.GetTrack(i).HasKeys)
                {
                    var track  = group.GetTrack(i);
                    var value  = track.GetFrameValue(Frame, StartFrame);
                    var target = (LPATarget)i;

                    if (!pane.animController.PaneSRT.ContainsKey(target))
                    {
                        pane.animController.PaneSRT.Add(target, value);
                    }
                    else
                    {
                        pane.animController.PaneSRT[target] = value;
                    }
                }
            }
        }
        private void glControl1_MouseDown(object sender, MouseEventArgs e)
        {
            SelectedPanes.Clear();

            //Pick an object for moving
            if (Control.ModifierKeys == Keys.Alt && e.Button == MouseButtons.Left)
            {
                BasePane hitPane = null;
                SearchHit(LayoutFile.RootPane, e.X, e.Y, ref hitPane);
                if (hitPane != null)
                {
                    SelectedPanes.Add(hitPane);
                    UpdateViewport();

                    isPicked = true;
                }
            }
            else if (e.Button == MouseButtons.Left)
            {
                mouseHeldDown = true;
                originMouse   = e.Location;

                BasePane hitPane = null;
                foreach (var child in LayoutFile.RootPane.Childern)
                {
                    SearchHit(child, e.X, e.Y, ref hitPane);
                }
                Console.WriteLine($"Has Hit " + hitPane != null);
                if (hitPane != null)
                {
                    SelectedPanes.Add(hitPane);
                    UpdateViewport();
                }

                glControl1.Invalidate();
            }

            Console.WriteLine("SelectedPanes " + SelectedPanes.Count);
        }
        public void LoadPaneEditorOnSelect(BasePane pane)
        {
            if (pane is IPicturePane)
            {
                LayoutPaneEditor.Text = $"Properties [{pane.Name}]    |   (Picture Pane)";
            }
            else if (pane is ITextPane)
            {
                LayoutPaneEditor.Text = $"Properties [{pane.Name}]    |    (Text Box Pane)";
            }
            else if (pane is IWindowPane)
            {
                LayoutPaneEditor.Text = $"Properties [{pane.Name}]    |    (Window Pane)";
            }
            else if (pane is IBoundryPane)
            {
                LayoutPaneEditor.Text = $"Properties [{pane.Name}]    |    (Boundry Pane)";
            }
            else if (pane is IPartPane)
            {
                LayoutPaneEditor.Text = $"Properties [{pane.Name}]    |    (Part Pane)";
            }
            else
            {
                LayoutPaneEditor.Text = $"Properties [{pane.Name}]    |    (Null Pane)";
            }

            LayoutPaneEditor.LoadPane(pane, this);

            if (ActiveViewport == null)
            {
                return;
            }

            if (!ActiveViewport.SelectedPanes.Contains(pane))
            {
                ActiveViewport.SelectedPanes.Add(pane);
            }
        }