Exemplo n.º 1
0
            public override short AddMaterial(BxlytMaterial material)
            {
                if (material == null)
                {
                    return(-1);
                }

                if (!MaterialList.Materials.Contains(material))
                {
                    MaterialList.Materials.Add(material);
                }

                if (material.NodeWrapper == null)
                {
                    material.NodeWrapper = new MatWrapper(material.Name)
                    {
                        Tag              = material,
                        ImageKey         = "material",
                        SelectedImageKey = "material",
                    }
                }
                ;

                if (!MaterialFolder.Nodes.Contains(material.NodeWrapper))
                {
                    MaterialFolder.Nodes.Add(material.NodeWrapper);
                }

                return((short)MaterialList.Materials.IndexOf(material));
            }
Exemplo n.º 2
0
 private void LoadMaterialAnimation(BxlytMaterial material, LytAnimGroup group)
 {
     //Sub groups store tag entries like texture patterns, srt, etc
     foreach (var subGroup in group.SubAnimGroups)
     {
         if (subGroup is LytTexturePatternGroup)
         {
             LoadTexturePatternGroup(material, (LytTexturePatternGroup)subGroup);
         }
         else if (subGroup is LytTextureSRTGroup)
         {
             LoadTextureSRTGroup(material, (LytTextureSRTGroup)subGroup);
         }
         else if (subGroup is LytAlphaTestGroup)
         {
             LoadAlphaTestGroup(material, (LytAlphaTestGroup)subGroup);
         }
         else if (subGroup is LytIndirectSRTGroup)
         {
             LoadIndirectSRTGroup(material, (LytIndirectSRTGroup)subGroup);
         }
         else if (subGroup is LytMaterialColorGroup)
         {
             LoadMaterialColorGroup(material, (LytMaterialColorGroup)subGroup);
         }
     }
 }
        public void LoadMaterial(BxlytMaterial material, PaneEditor paneEditor)
        {
            ActiveMaterial = material;
            ParentEditor   = paneEditor;

            tevStageCB.Items.Clear();
            tevColorModeCB.ResetBind();
            tevAlphaModeCB.ResetBind();

            if (material.TevStages?.Length > 0)
            {
                tevBasicPanel.Show();

                for (int i = 0; i < material.TevStages.Length; i++)
                {
                    tevStageCB.Items.Add($"Stage [{i}]");
                }

                tevStageCB.SelectedIndex = 0;
            }
            else
            {
                tevBasicPanel.Hide();
            }
        }
Exemplo n.º 4
0
        private void LoadTexturePatternGroup(BxlytMaterial mat, LytTexturePatternGroup group)
        {
            for (int i = 0; i < 1; i++)
            {
                if (group.GetTrack(i).HasKeys)
                {
                    var track  = group.GetTrack(i);
                    var value  = track.GetFrameValue(Frame, StartFrame);
                    var target = (LTPTarget)i;

                    if (Textures.Count > value && value >= 0)
                    {
                        string texName = Textures[(int)value];

                        if (!mat.animController.TexturePatterns.ContainsKey(target))
                        {
                            mat.animController.TexturePatterns.Add(target, texName);
                        }
                        else
                        {
                            mat.animController.TexturePatterns[target] = texName;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void LoadMaterial(BxlytMaterial material, LayoutEditor parentEditor)
        {
            ActiveMaterial = material;
            ParentEditor   = parentEditor;

            Loaded       = false;
            MaterialMode = true;

            stToolStrip1.Items.Clear();

            AddTab("Texture Maps", LoadTextureMaps);
            if (ActiveMaterial is Revolution.Material)
            {
                AddTab("Colors", LoadBRLYTColorBlending);
                AddTab("Blending", LoadBRLYTBlending);
                AddTab("SwapTable", LoadBRLYTTevSwapChannel);
                AddTab("Combiners", LoadBRLYTTextureCombiners);
            }
            else if (ActiveMaterial is CTR.Material)
            {
                AddTab("Colors", LoadBCLYTColorBlending);
                AddTab("Blending", LoadBlending);
                AddTab("Combiners", LoadBCLYTTextureCombiners);
            }
            else
            {
                AddTab("Colors", LoadColorBlending);
                AddTab("Blending", LoadBlending);
                AddTab("Combiners", LoadTextureCombiners);
            }

            stToolStrip1.Items[Runtime.LayoutEditor.MaterialTabIndex].PerformClick();

            Loaded = true;
        }
Exemplo n.º 6
0
        public void LoadMaterial(BxlytMaterial material, PaneEditor paneEditor,
                                 Dictionary <string, STGenericTexture> textures)
        {
            textureList    = textures;
            ParentEditor   = paneEditor;
            ActiveMaterial = material;

            ReloadTexture();
        }
        public void LoadMaterial(BxlytMaterial material, PaneEditor paneEditor,
                                 Dictionary <string, STGenericTexture> textures, int numTextureCoordinates = 1)
        {
            TexCoordinateCount = numTextureCoordinates;
            textureList        = textures;
            ParentEditor       = paneEditor;
            ActiveMaterial     = material;

            ReloadTexture();
        }
Exemplo n.º 8
0
        public void LoadMaterial(BxlytMaterial material, PaneEditor paneEditor)
        {
            ActiveMaterial = material;
            ParentEditor   = paneEditor;

            whiteColorPB.Color = material.WhiteColor.Color;
            blackColorBP.Color = material.BlackColor.Color;

            chkAlphaInterpolation.Bind(material, "AlphaInterpolation");
        }
Exemplo n.º 9
0
        private void ReloadAlphaCompareValues(BxlytMaterial material)
        {
            loaded = false;
            if (material.AlphaCompare != null && material.EnableAlphaCompare)
            {
                alphaSourcCB.Bind(typeof(GfxAlphaFunction), material.AlphaCompare, "CompareMode");
                alphaValueUD.Value = material.AlphaCompare.Value;

                alphaSourcCB.SelectedItem = material.AlphaCompare.CompareMode;
            }
            loaded = true;
        }
Exemplo n.º 10
0
            public override void TryRemoveMaterial(BxlytMaterial material)
            {
                if (material == null)
                {
                    return;
                }
                material.RemoveNodeWrapper();

                if (MaterialList.Materials.Contains(material))
                {
                    MaterialList.Materials.Remove(material);
                }
            }
Exemplo n.º 11
0
        public void LoadMaterial(BxlytMaterial material, PaneEditor paneEditor)
        {
            loaded         = false;
            ActiveMaterial = material;
            ParentEditor   = paneEditor;

            chkAlphaDefaults.Checked      = !material.EnableAlphaCompare;
            chkColorBlendDefaults.Checked = !material.EnableBlend;

            SetupDefaults();
            ReloadBlendValues(material);

            loaded = true;
        }
Exemplo n.º 12
0
        public void LoadMaterial(Revolution.Material material, PaneEditor paneEditor)
        {
            ParentEditor   = paneEditor;
            ActiveMaterial = material;

            if (material.TevSwapModeTable != null)
            {
                var swapModes = material.TevSwapModeTable.SwapModes;
                //Note these are always 4 in length for RGBA
                for (int i = 0; i < swapModes?.Length; i++)
                {
                    SwapControls[i].LoadSwapMode(swapModes[i]);
                }
            }
        }
Exemplo n.º 13
0
        private static void BindTextureUniforms(BxlytShader shader, BxlytMaterial material)
        {
            //Do uv test pattern
            GL.ActiveTexture(TextureUnit.Texture10);
            GL.Uniform1(GL.GetUniformLocation(shader.program, "uvTestPattern"), 10);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);

            if (material.TextureMaps.Length > 0)
            {
                var tex = material.TextureMaps[0];
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, BxlytToGL.ConvertTextureWrap(tex.WrapModeU));
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, BxlytToGL.ConvertTextureWrap(tex.WrapModeV));
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, BxlytToGL.ConvertMagFilterMode(tex.MaxFilterMode));
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, BxlytToGL.ConvertMinFilterMode(tex.MinFilterMode));
            }
        }
Exemplo n.º 14
0
        private void ReloadColorValues(BxlytMaterial material)
        {
            loaded = false;
            if (material.BlendMode != null && material.EnableBlend)
            {
                colorBlendSrcCB.Bind(typeof(BxlytBlendMode.GX2BlendFactor), material.BlendMode, "SourceFactor");
                colorBlendDestCB.Bind(typeof(BxlytBlendMode.GX2BlendFactor), material.BlendMode, "DestFactor");
                colorBlendOpCB.Bind(typeof(BxlytBlendMode.GX2BlendOp), material.BlendMode, "BlendOp");
                colorBlendLogicCB.Bind(typeof(BxlytBlendMode.GX2LogicOp), material.BlendMode, "LogicOp");

                colorBlendSrcCB.SelectedItem   = material.BlendMode.SourceFactor;
                colorBlendDestCB.SelectedItem  = material.BlendMode.DestFactor;
                colorBlendOpCB.SelectedItem    = material.BlendMode.BlendOp;
                colorBlendLogicCB.SelectedItem = material.BlendMode.LogicOp;
            }
            loaded = true;
        }
Exemplo n.º 15
0
        private void ReloadAlphaCompareValues(BxlytMaterial material)
        {
            loaded = false;
            if (material.AlphaCompare != null && material.EnableAlphaCompare)
            {
                var alphaCompare = (Revolution.AlphaCompare)material.AlphaCompare;

                alphaSource1CB.Bind(typeof(GfxAlphaFunction), alphaCompare, "Comp0");
                alphaSource2CB.Bind(typeof(GfxAlphaFunction), alphaCompare, "Comp1");

                alphaValue1UD.Value = alphaCompare.Ref0;
                alphaValue2UD.Value = alphaCompare.Ref1;

                alphaSource1CB.SelectedItem = material.AlphaCompare.CompareMode;
            }
            loaded = true;
        }
Exemplo n.º 16
0
        public void LoadMaterial(BxlytMaterial material, LayoutEditor parentEditor)
        {
            ActiveMaterial = material;
            ParentEditor   = parentEditor;

            Loaded       = false;
            MaterialMode = true;

            stToolStrip1.Items.Clear();

            AddTab("Texture Maps", LoadTextureMaps);
            AddTab("Colors", LoadColorBlending);
            AddTab("Blending", LoadBlending);
            AddTab("Combiners", LoadTextureCombiners);

            stToolStrip1.Items[Runtime.LayoutEditor.MaterialTabIndex].PerformClick();

            Loaded = true;
        }
Exemplo n.º 17
0
        public void LoadMaterial(Revolution.Material material, PaneEditor paneEditor)
        {
            loaded         = false;
            ActiveMaterial = material;
            ParentEditor   = paneEditor;

            chkAlphaDefaults.Checked      = !material.EnableAlphaCompare;
            chkColorBlendDefaults.Checked = !material.EnableBlend;

            SetupDefaults();
            ReloadBlendValues(material);

            alphaValue1UD.Maximum = 255;
            alphaValue2UD.Maximum = 255;
            alphaValue1UD.Minimum = 0;
            alphaValue2UD.Minimum = 0;
            alphaValue1UD.Value   = 255;
            alphaValue2UD.Value   = 255;

            loaded = true;
        }
Exemplo n.º 18
0
        private void LoadTextureSRTGroup(BxlytMaterial mat, LytTextureSRTGroup group)
        {
            for (int i = 0; i < 5; i++)
            {
                if (group.GetTrack(i).HasKeys)
                {
                    var track  = group.GetTrack(i);
                    var value  = track.GetFrameValue(Frame, StartFrame);
                    var target = (LTSTarget)i;

                    if (!mat.animController.TextureSRTS.ContainsKey(target))
                    {
                        mat.animController.TextureSRTS.Add(target, value);
                    }
                    else
                    {
                        mat.animController.TextureSRTS[target] = value;
                    }
                }
            }
        }
Exemplo n.º 19
0
        private void LoadMaterialColorGroup(BxlytMaterial mat, LytMaterialColorGroup group)
        {
            for (int i = 0; i < 8; i++)
            {
                if (group.GetTrack(i).HasKeys)
                {
                    var track  = group.GetTrack(i);
                    var value  = track.GetFrameValue(Frame, StartFrame);
                    var target = (LMCTarget)i;

                    if (!mat.animController.MaterialColors.ContainsKey(target))
                    {
                        mat.animController.MaterialColors.Add(target, value);
                    }
                    else
                    {
                        mat.animController.MaterialColors[target] = value;
                    }
                }
            }
        }
Exemplo n.º 20
0
 private void ReloadBlendValues(BxlytMaterial material)
 {
     ReloadAlphaCompareValues(material);
     ReloadColorValues(material);
 }
Exemplo n.º 21
0
        public static void LoadTextureUniforms(BxlytShader shader, BxlytMaterial material,
                                               Dictionary <string, STGenericTexture> textures)
        {
            shader.SetInt("hasTexture0", 0);
            shader.SetInt("hasTexture1", 0);
            shader.SetInt("hasTexture2", 0);
            shader.SetInt("textures0", 0);
            shader.SetInt("textures1", 0);
            shader.SetInt("textures2", 0);

            BindTextureUniforms(shader, material);

            if (material.TextureMaps.Length > 0 || Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.UVTestPattern)
            {
                GL.Enable(EnableCap.Texture2D);
            }

            for (int i = 0; i < 3; i++)
            {
                //Default UVs as centered
                var matTranslate = Matrix4.CreateTranslation(0 / 1 - 0.5f, 0 / 1 - 0.5f, 0);
                shader.SetMatrix(String.Format("textureTransforms[{0}]", i), ref matTranslate);
            }

            int id = 1;

            for (int i = 0; i < material.TextureMaps.Length; i++)
            {
                string TexName = material.TextureMaps[i].Name;

                if (material.animController.TexturePatterns.ContainsKey((LTPTarget)i))
                {
                    TexName = material.animController.TexturePatterns[(LTPTarget)i];
                }

                if (textures.ContainsKey(TexName))
                {
                    GL.ActiveTexture(TextureUnit.Texture0 + id);
                    shader.SetInt($"textures{i}", id);
                    bool isBinded = BxlytToGL.BindGLTexture(material.TextureMaps[i], textures[TexName]);
                    if (isBinded)
                    {
                        shader.SetInt($"hasTexture{i}", 1);
                    }

                    var   scale     = new Syroot.Maths.Vector2F(1, 1);
                    float rotate    = 0;
                    var   translate = new Syroot.Maths.Vector2F(0, 0);

                    int index = i;

                    if (material.TextureTransforms.Length > index)
                    {
                        var transform = material.TextureTransforms[index];
                        scale     = transform.Scale;
                        rotate    = transform.Rotate;
                        translate = transform.Translate;

                        foreach (var animItem in material.animController.TextureSRTS)
                        {
                            switch (animItem.Key)
                            {
                            case LTSTarget.ScaleS: scale.X = animItem.Value; break;

                            case LTSTarget.ScaleT: scale.Y = animItem.Value; break;

                            case LTSTarget.Rotate: rotate = animItem.Value; break;

                            case LTSTarget.TranslateS: translate.X = animItem.Value; break;

                            case LTSTarget.TranslateT: translate.Y = animItem.Value; break;
                            }
                        }
                    }


                    var matScale     = Matrix4.CreateScale(scale.X, scale.Y, 1.0f);
                    var matRotate    = Matrix4.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.DegreesToRadians(rotate));
                    var matTranslate = Matrix4.CreateTranslation(
                        translate.X / scale.X - 0.5f,
                        translate.Y / scale.Y - 0.5f, 0);

                    Matrix4 matTransform = matRotate * matTranslate * matScale;
                    shader.SetMatrix(String.Format("textureTransforms[{0}]", i), ref matTransform);

                    id++;
                }
            }
        }
Exemplo n.º 22
0
        public void LoadPane(BasePane pane, LayoutEditor parentEditor)
        {
            ParentEditor = parentEditor;

            Loaded       = false;
            MaterialMode = false;

            ActivePane = pane;

            stToolStrip1.Items.Clear();
            AddTab("Pane", LoadBasePane);
            if (pane is IPicturePane)
            {
                ActiveMaterial = ((IPicturePane)ActivePane).Material;
                AddTab("Picture Pane", LoadPicturePane);
                AddTab("Texture Maps", LoadTextureMaps);
                AddTab("Colors", LoadColorBlending);
                AddTab("Blending", LoadBlending);
                AddTab("Combiners", LoadTextureCombiners);
            }
            if (pane is IWindowPane)
            {
                //Note active material is set in window pane editor based on frame selector

                AddTab("Window Pane", LoadWindowPane);
                AddTab("Texture Maps", LoadWindowLoadTextureMaps);
                AddTab("Colors", LoadWindowColorBlending);
                AddTab("Blending", LoadWindowMatBlending);
                AddTab("Combiners", LoadWindowTextureCombiners);
            }
            if (pane is ITextPane)
            {
                ActiveMaterial = ((ITextPane)ActivePane).Material;

                AddTab("Text Pane", LoadTextPane);
                AddTab("Colors", LoadColorBlending);
                AddTab("Blending", LoadBlending);
            }
            if (pane is IPartPane)
            {
                AddTab("Part Pane", LoadPartPane);
            }

            AddTab("User Data", LoadUserData);

            int tabIndex;

            if (pane is IPicturePane)
            {
                tabIndex = Runtime.LayoutEditor.PicturePaneTabIndex;
            }
            else if (pane is IWindowPane)
            {
                tabIndex = Runtime.LayoutEditor.WindowPaneTabIndex;
            }
            else if (pane is ITextPane)
            {
                tabIndex = Runtime.LayoutEditor.TextPaneTabIndex;
            }
            else
            {
                tabIndex = Runtime.LayoutEditor.NullPaneTabIndex;
            }

            stToolStrip1.Items[tabIndex].PerformClick();

            Loaded = true;
        }
Exemplo n.º 23
0
 private void LoadAlphaTestGroup(BxlytMaterial mat, LytAlphaTestGroup group)
 {
 }
Exemplo n.º 24
0
 private void LoadIndirectSRTGroup(BxlytMaterial mat, LytIndirectSRTGroup group)
 {
 }