예제 #1
0
 public CustomDataParameter()
 {
     CustomData  = new Value.Enum <CustomDataType>();
     Fixed       = new Value.Vector2D();
     Easing      = new Vector2DEasingParamater();
     FCurve      = new Value.FCurveVector2D();
     FCurveColor = new Value.FCurveColorRGBA();
 }
예제 #2
0
 public CustomDataParameter(int customDataNum)
 {
     this.customDataNum = customDataNum;
     CustomData         = new Value.Enum <CustomDataType>();
     Fixed       = new Value.Vector2D();
     Easing      = new Vector2DEasingParamater();
     FCurve      = new Value.FCurveVector2D();
     Fixed4      = new Value.Vector4D();
     FCurveColor = new Value.FCurveColorRGBA();
 }
예제 #3
0
        internal ColorFCurveParameter()
        {
            FCurve = new Value.FCurveColorRGBA();

            FCurve.R.DefaultValueRangeMax = 256.0f;
            FCurve.R.DefaultValueRangeMin = 0.0f;
            FCurve.G.DefaultValueRangeMax = 256.0f;
            FCurve.G.DefaultValueRangeMin = 0.0f;
            FCurve.B.DefaultValueRangeMax = 256.0f;
            FCurve.B.DefaultValueRangeMin = 0.0f;
            FCurve.A.DefaultValueRangeMax = 256.0f;
            FCurve.A.DefaultValueRangeMin = 0.0f;
        }
예제 #4
0
        public static XmlElement SaveToElement(XmlDocument doc, string element_name, Value.FCurveColorRGBA value, bool isClip)
        {
            var e    = doc.CreateElement(element_name);
            var keys = doc.CreateElement("Keys");
            var r    = doc.CreateElement("R");
            var g    = doc.CreateElement("G");
            var b    = doc.CreateElement("B");
            var a    = doc.CreateElement("A");

            int index = 0;

            Action <Value.FCurve <byte>, XmlElement> setValues = (v, xml) =>
            {
                index = 0;

                var st   = SaveToElement(doc, "StartType", v.StartType, isClip);
                var et   = SaveToElement(doc, "EndType", v.EndType, isClip);
                var omax = SaveToElement(doc, "OffsetMax", v.OffsetMax, isClip);
                var omin = SaveToElement(doc, "OffsetMin", v.OffsetMin, isClip);
                var s    = SaveToElement(doc, "Sampling", v.Sampling, isClip);

                if (st != null)
                {
                    xml.AppendChild(st);
                }
                if (et != null)
                {
                    xml.AppendChild(et);
                }
                if (omax != null)
                {
                    xml.AppendChild(omax);
                }
                if (omin != null)
                {
                    xml.AppendChild(omin);
                }
                if (s != null)
                {
                    xml.AppendChild(s);
                }

                foreach (var k_ in v.Keys)
                {
                    var k = doc.CreateElement("Key" + index.ToString());
                    k.AppendChild(doc.CreateTextElement("Frame", k_.Frame.ToString()));
                    k.AppendChild(doc.CreateTextElement("Value", k_.ValueAsFloat.ToString()));
                    k.AppendChild(doc.CreateTextElement("LeftX", k_.LeftX.ToString()));
                    k.AppendChild(doc.CreateTextElement("LeftY", k_.LeftY.ToString()));
                    k.AppendChild(doc.CreateTextElement("RightX", k_.RightX.ToString()));
                    k.AppendChild(doc.CreateTextElement("RightY", k_.RightY.ToString()));

                    k.AppendChild(doc.CreateTextElement("InterpolationType", k_.InterpolationType.GetValueAsInt()));

                    xml.AppendChild(k);
                    index++;
                }
            };

            setValues(value.R, r);
            setValues(value.G, g);
            setValues(value.B, b);
            setValues(value.A, a);

            if (r.ChildNodes.Count > 0)
            {
                keys.AppendChild(r);
            }
            if (g.ChildNodes.Count > 0)
            {
                keys.AppendChild(g);
            }
            if (b.ChildNodes.Count > 0)
            {
                keys.AppendChild(b);
            }
            if (a.ChildNodes.Count > 0)
            {
                keys.AppendChild(a);
            }

            if (keys.ChildNodes.Count > 0)
            {
                e.AppendChild(keys);
            }

            return(e.ChildNodes.Count > 0 ? e : null);
        }
예제 #5
0
        public static void LoadFromElement(XmlElement e, Value.FCurveColorRGBA value, bool isClip)
        {
            Action <Data.Value.FCurve <byte>, XmlElement> import = (v_, e_) =>
            {
                foreach (XmlElement r in e_.ChildNodes)
                {
                    if (r.Name.StartsWith("Key"))
                    {
                        var f  = r.GetTextAsInt("Frame");
                        var v  = r.GetTextAsFloat("Value");
                        var lx = r.GetTextAsFloat("LeftX");
                        var ly = r.GetTextAsFloat("LeftY");
                        var rx = r.GetTextAsFloat("RightX");
                        var ry = r.GetTextAsFloat("RightY");
                        var i  = r.GetTextAsInt("InterpolationType");

                        var t = new Value.FCurveKey <byte>(f, (byte)v);
                        t.SetLeftDirectly(lx, ly);
                        t.SetRightDirectly(rx, ry);
                        t.InterpolationType.SetValue(i);

                        v_.AddKeyDirectly(t);
                    }
                    else if (r.Name.StartsWith("StartType"))
                    {
                        var v = r.GetTextAsInt();
                        v_.StartType.SetValue(v);
                    }
                    else if (r.Name.StartsWith("EndType"))
                    {
                        var v = r.GetTextAsInt();
                        v_.EndType.SetValue(v);
                    }
                    else if (r.Name.StartsWith("OffsetMax"))
                    {
                        var v = r.GetTextAsFloat();
                        v_.OffsetMax.SetValueDirectly(v);
                    }
                    else if (r.Name.StartsWith("OffsetMin"))
                    {
                        var v = r.GetTextAsFloat();
                        v_.OffsetMin.SetValueDirectly(v);
                    }
                    else if (r.Name.StartsWith("Sampling"))
                    {
                        var v = r.GetTextAsInt();
                        v_.Sampling.SetValueDirectly(v);
                    }
                }
            };


            var e_keys = e["Keys"] as XmlElement;

            if (e_keys == null)
            {
                return;
            }

            var e_r = e_keys["R"] as XmlElement;
            var e_g = e_keys["G"] as XmlElement;
            var e_b = e_keys["B"] as XmlElement;
            var e_a = e_keys["A"] as XmlElement;

            if (e_r != null)
            {
                import(value.R, e_r);
            }
            if (e_g != null)
            {
                import(value.G, e_g);
            }
            if (e_b != null)
            {
                import(value.B, e_b);
            }
            if (e_a != null)
            {
                import(value.A, e_a);
            }
        }