Ejemplo n.º 1
0
        static object DisplayParam(string key, object value)
        {
            switch (ParamProperty.ParamType)
            {
            case ShaderParamType.Float:
            {
                float output = (float)value;
                if (ImGui.DragFloat(key, ref output))
                {
                    return(output);
                }
                break;
            }

            case ShaderParamType.Float2:
            {
                Vector2 output = (Vector2)value;
                if (ImGui.DragFloat2(key, ref output))
                {
                    return(output);
                }
                break;
            }

            case ShaderParamType.Float3:
            {
                Vector3 output = (Vector3)value;
                if (isColor)
                {
                    if (ImGui.ColorEdit3(key, ref output, ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.Float))
                    {
                        return(output);
                    }
                }
                else
                {
                    if (ImGui.DragFloat3(key, ref output))
                    {
                        return(output);
                    }
                }
                break;
            }

            case ShaderParamType.Float4:
            {
                Vector4 output = (Vector4)value;
                if (isColor)
                {
                    if (ImGui.ColorEdit4(key, ref output, ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.Float))
                    {
                        return(output);
                    }
                }
                else
                {
                    if (ImGui.DragFloat4(key, ref output))
                    {
                        return(output);
                    }
                }
                break;
            }

            case ShaderParamType.TexSrtEx:
            case ShaderParamType.TexSrt:
            {
                TextureSRT output = (TextureSRT)value;

                //6 columns
                bool edited = false;
                edited = edited || ImGuiHelper.ComboFromEnum <TexSrtMode>(key + "C0", output, "Mode", ImGuiComboFlags.NoArrowButton);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C1", output, "ScaleX", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C2", output, "ScaleY", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C3", output, "Rotate", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C4", output, "TranslateX", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C5", output, "TranslateY", true, 0);

                if (edited)
                {
                    return(output);
                }
                break;
            }
            }
            return(null);
        }
Ejemplo n.º 2
0
        static object GetDataValue(List <STAnimationTrack> tracks, int frame)
        {
            switch (ParamProperty.ParamType)
            {
            case ShaderParamType.Float:
            {
                float output = 0;
                foreach (var track in tracks)
                {
                    if (track.Name == "0")
                    {
                        output = track.GetFrameValue(frame);
                    }
                }
                return(output);
            }

            case ShaderParamType.Float2:
            {
                Vector2 output = new Vector2();
                foreach (var track in tracks)
                {
                    if (track.Name == "0")
                    {
                        output.X = track.GetFrameValue(frame);
                    }
                    if (track.Name == "4")
                    {
                        output.Y = track.GetFrameValue(frame);
                    }
                }
                return(output);
            }

            case ShaderParamType.Float3:
            {
                Vector3 output = new Vector3();
                foreach (var track in tracks)
                {
                    if (track.Name == "0")
                    {
                        output.X = track.GetFrameValue(frame);
                    }
                    if (track.Name == "4")
                    {
                        output.Y = track.GetFrameValue(frame);
                    }
                    if (track.Name == "8")
                    {
                        output.Z = track.GetFrameValue(frame);
                    }
                }
                return(output);
            }

            case ShaderParamType.Float4:
            {
                Vector4 output = new Vector4();
                foreach (var track in tracks)
                {
                    if (track.Name == "0")
                    {
                        output.X = track.GetFrameValue(frame);
                    }
                    if (track.Name == "4")
                    {
                        output.Y = track.GetFrameValue(frame);
                    }
                    if (track.Name == "8")
                    {
                        output.Z = track.GetFrameValue(frame);
                    }
                    if (track.Name == "C")
                    {
                        output.W = track.GetFrameValue(frame);
                    }
                }
                return(output);
            }

            case ShaderParamType.TexSrt:
            case ShaderParamType.TexSrtEx:
            {
                var texSRT = new TextureSRT();
                foreach (var track in tracks)
                {
                    if (track.Name == "0")
                    {
                        texSRT.Mode = (TexSrtMode)track.GetFrameValue(frame);
                    }
                    if (track.Name == "4")
                    {
                        texSRT.ScaleX = track.GetFrameValue(frame);
                    }
                    if (track.Name == "8")
                    {
                        texSRT.ScaleY = track.GetFrameValue(frame);
                    }
                    if (track.Name == "C")
                    {
                        texSRT.Rotate = track.GetFrameValue(frame);
                    }
                    if (track.Name == "10")
                    {
                        texSRT.TranslateX = track.GetFrameValue(frame);
                    }
                    if (track.Name == "14")
                    {
                        texSRT.TranslateY = track.GetFrameValue(frame);
                    }
                }
                return(texSRT);
            }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public override bool OnInitialize()
        {
            MDL0TextureRef *header = Header;

            _texPtr      = header->_texPtr;
            _pltPtr      = header->_pltPtr;
            _index1      = header->_index1;
            _index2      = header->_index2;
            _uWrap       = header->_uWrap;
            _vWrap       = header->_vWrap;
            _minFltr     = header->_minFltr;
            _magFltr     = header->_magFltr;
            _lodBias     = header->_lodBias;
            _maxAniso    = header->_maxAniso;
            _clampBias   = header->_clampBias == 1;
            _texelInterp = header->_texelInterp == 1;
            _pad         = header->_pad;

            if (header->_texOffset != 0)
            {
                if (_replaced && header->_texOffset >= Parent.WorkingUncompressed.Length)
                {
                    Name = null;
                }
                else
                {
                    if (_replaced)
                    {
                        Name = header->TextureName;
                    }
                    else
                    {
                        _name = header->TextureName;
                    }
                    _texture = Model.FindOrCreateTexture(_name);
                    _texture._references.Add(this);
                }
            }
            if (header->_pltOffset != 0)
            {
                if (_replaced && header->_pltOffset >= Parent.WorkingUncompressed.Length)
                {
                    _palette = null;
                }
                else
                {
                    string name = header->PaletteName;
                    _palette = Model.FindOrCreatePalette(name);
                    _palette._references.Add(this);
                }
            }

            int len = ((MDL0MaterialNode)Parent).XFCommands.Length;

            if (len != 0 && Index * 2 < len)
            {
                TexMtxFlags  = new XFTexMtxInfo(((MDL0MaterialNode)Parent).XFCommands[Index * 2].values[0]);
                DualTexFlags = new XFDualTex(((MDL0MaterialNode)Parent).XFCommands[Index * 2 + 1].values[0]);
                getValues();
            }

            //if (PaletteNode == null && TextureNode != null)
            //{
            //    if (TextureNode.Source == null)
            //        TextureNode.GetSource();

            //    if (TextureNode.Source is TEX0Node && ((TEX0Node)TextureNode.Source).HasPalette)
            //    {
            //        Model._errors.Add("A palette was not set to texture reference " + Index + " in material " + Parent.Index + " (" + Parent.Name + ").");
            //        PaletteNode = Model.FindOrCreatePalette(TextureNode.Name);

            //        SignalPropertyChange();
            //    }
            //}

            MDL0TexSRTData *TexSettings = ((MDL0MaterialNode)Parent).Header->TexMatrices(((MDL0MaterialNode)Parent)._initVersion);

            _texFlags  = TexSettings->GetTexFlags(Index);
            _texMatrix = TexSettings->GetTexMatrices(Index);

            _flags = (TexFlags)((((MDL0MaterialNode)Parent)._layerFlags >> (4 * Index)) & 0xF);

            _bindState = new FrameState(
                new Vector3(_texFlags.TexScale._x, _texFlags.TexScale._y, 1),
                new Vector3(_texFlags.TexRotation, 0, 0),
                new Vector3(_texFlags.TexTranslation._x, _texFlags.TexTranslation._y, 0));

            return(false);
        }