Exemple #1
0
            private string ConvertParamOffset(uint offset, FMAA.AnimationType animType)
            {
                if (animType == FMAA.AnimationType.Color)
                {
                    switch (offset)
                    {
                    case 0: return("R");

                    case 4: return("G");

                    case 8: return("B");

                    case 12: return("A");

                    default:
                        return(offset.ToString());
                    }
                }
                else if (animType == FMAA.AnimationType.TextureSrt)
                {
                    switch (offset)
                    {
                    case 0: return("Scale X");

                    case 4: return("Scale Y");

                    case 8: return("Scale Z");

                    case 12: return("Rotate X");

                    case 16: return("Rotate Y");

                    case 20: return("Rotate Z");

                    case 24: return("Translate X");

                    case 28: return("Translate Y");

                    case 32: return("Translate Z");

                    default:
                        return(offset.ToString());
                    }
                }

                return(offset.ToString());
            }
Exemple #2
0
        public static string ToYaml(string Name, MaterialAnim MatAnim, FMAA.AnimationType animType)
        {
            var serializerSettings = new SerializerSettings()
            {
                //  EmitTags = false
            };

            serializerSettings.DefaultStyle          = YamlStyle.Any;
            serializerSettings.ComparerForKeySorting = null;
            serializerSettings.RegisterTagMapping("AnimConfig", typeof(AnimConfig));

            var config = new AnimConfig();

            config.ToYaml(MatAnim, animType);

            var    serializer = new Serializer(serializerSettings);
            string yaml       = serializer.Serialize(config, typeof(AnimConfig));

            return(yaml);
        }
Exemple #3
0
            public void ToYaml(MaterialAnim materialAnim, FMAA.AnimationType animType)
            {
                MaterialAnimConfigs = new List <MatAnimConfig>();

                Name       = materialAnim.Name;
                Path       = materialAnim.Path;
                FrameCount = materialAnim.FrameCount;
                Loop       = materialAnim.Loop;

                foreach (var mat in materialAnim.MaterialAnimDataList)
                {
                    MatAnimConfig matConfig = new MatAnimConfig();
                    matConfig.Name = mat.Name;
                    MaterialAnimConfigs.Add(matConfig);

                    foreach (var paramInfo in mat.ParamAnimInfos)
                    {
                        ParamInfo paramCfg = new ParamInfo();
                        paramCfg.Name       = paramInfo.Name;
                        paramCfg.IsConstant = paramInfo.ConstantCount != 0;
                        matConfig.ParamInfos.Add(paramCfg);

                        if (paramInfo.ConstantCount != 0)
                        {
                            paramCfg.Constants = new List <ConstantConfig>();
                            for (int i = 0; i < paramInfo.ConstantCount; i++)
                            {
                                AnimConstant   constant      = mat.Constants[paramInfo.BeginConstant + i];
                                ConstantConfig ConstantValue = new ConstantConfig();
                                ConstantValue.Offset = ConvertParamOffset(constant.AnimDataOffset, animType);
                                ConstantValue.Value  = constant.Value;

                                paramCfg.Constants.Add(ConstantValue);
                            }
                        }

                        if (paramInfo.BeginCurve != ushort.MaxValue)
                        {
                            paramCfg.CurveData = new List <CurveConfig>();
                            for (int i = 0; i < paramInfo.IntCurveCount + paramInfo.FloatCurveCount; i++)
                            {
                                var curve    = mat.Curves[(int)paramInfo.BeginCurve + i];
                                var CurveCfg = new CurveConfig();
                                CurveCfg.Offset = ConvertParamOffset(curve.AnimDataOffset, animType);

                                if (curve.Scale == 0)
                                {
                                    curve.Scale = 1;
                                }

                                for (int f = 0; f < curve.Frames.Length; f++)
                                {
                                    int   frame = (int)curve.Frames[f];
                                    float Value = curve.Offset + curve.Keys[f, 0] * curve.Scale;
                                    CurveCfg.KeyFrames.Add(frame, Value);
                                }

                                paramCfg.CurveData.Add(CurveCfg);
                            }
                        }
                    }

                    foreach (var patternInfo in mat.TexturePatternAnimInfos)
                    {
                        PatternInfo infoCfg = new PatternInfo();
                        infoCfg.Name       = patternInfo.Name;
                        infoCfg.IsConstant = patternInfo.BeginConstant != ushort.MaxValue;
                        matConfig.TexturePatternInfos.Add(infoCfg);

                        if (infoCfg.IsConstant)
                        {
                            infoCfg.ConstantValue = new ConstantTPConfig();
                            int Index = (int)mat.Constants[(int)patternInfo.BeginConstant].Value;
                            infoCfg.ConstantValue.Texture = materialAnim.TextureNames[Index];
                        }
                        if (patternInfo.CurveIndex != ushort.MaxValue)
                        {
                            var curve = mat.Curves[(int)patternInfo.CurveIndex];
                            infoCfg.CurveData = new CurveTPConfig();

                            if (curve.Scale == 0)
                            {
                                curve.Scale = 1;
                            }

                            for (int f = 0; f < curve.Frames.Length; f++)
                            {
                                int frame = (int)curve.Frames[f];
                                int Value = (int)curve.Offset + (int)curve.Keys[f, 0] * (int)curve.Scale;

                                infoCfg.CurveData.KeyFrames.Add(frame, materialAnim.TextureNames[Value]);
                            }
                        }
                    }
                }
            }