コード例 #1
0
 private static void WriteKey(Animation.KeyGroup keys)
 {
     foreach (Animation.KeyFrame key in keys.Keys)
     {
     }
 }
コード例 #2
0
ファイル: ANIM.cs プロジェクト: lanvas2008/Switch-Toolbox
        private static void writeKey(StreamWriter file, Animation.KeyGroup keys, Animation.KeyNode rt, int size, string type, bool useSegmentCompenseateScale = false)
        {
            bool isAngular = type == "rotateX" || type == "rotateY" || type == "rotateZ";

            //    string interp = isAngular ? "angular" : "linear";
            string interp = "linear";

            file.WriteLine("animData {");
            file.WriteLine("  input time;");
            file.WriteLine($"  output {interp};");
            file.WriteLine("  weighted 1;");
            file.WriteLine("  preInfinity constant;");
            file.WriteLine("  postInfinity constant;");
            file.WriteLine("  keys {");

            if (((Animation.KeyFrame)keys.Keys[0]).InterType == InterpolationType.CONSTANT)
            {
                size = 1;
            }

            int f = 1;

            foreach (Animation.KeyFrame key in keys.Keys)
            {
                float v = 0;

                switch (type)
                {
                case "translateX":
                case "translateY":
                case "translateZ":
                    v = key.Value;
                    break;

                case "rotateX":
                    if (rt.RotType == Animation.RotationType.EULER)
                    {
                        v = key.Value * Rad2Deg;
                    }
                    if (rt.RotType == Animation.RotationType.QUATERNION)
                    {
                        Quaternion q = new Quaternion(rt.XROT.GetValue(key.Frame), rt.YROT.GetValue(key.Frame), rt.ZROT.GetValue(key.Frame), rt.WROT.GetValue(key.Frame));
                        v = quattoeul(q).X *Rad2Deg;
                    }
                    break;

                case "rotateY":
                    if (rt.RotType == Animation.RotationType.EULER)
                    {
                        v = key.Value * Rad2Deg;
                    }
                    if (rt.RotType == Animation.RotationType.QUATERNION)
                    {
                        Quaternion q = new Quaternion(rt.XROT.GetValue(key.Frame), rt.YROT.GetValue(key.Frame), rt.ZROT.GetValue(key.Frame), rt.WROT.GetValue(key.Frame));
                        v = quattoeul(q).Y *Rad2Deg;
                    }
                    break;

                case "rotateZ":
                    if (rt.RotType == Animation.RotationType.EULER)
                    {
                        v = key.Value * Rad2Deg;
                    }
                    if (rt.RotType == Animation.RotationType.QUATERNION)
                    {
                        Quaternion q = new Quaternion(rt.XROT.GetValue(key.Frame), rt.YROT.GetValue(key.Frame), rt.ZROT.GetValue(key.Frame), rt.WROT.GetValue(key.Frame));
                        v = quattoeul(q).Z *Rad2Deg;
                    }
                    break;

                case "scaleX":
                case "scaleY":
                case "scaleZ":
                    if (useSegmentCompenseateScale)
                    {
                        v = 1f / key.Value;
                    }
                    else
                    {
                        v = key.Value;
                    }
                    break;
                }

                file.WriteLine(" " + (key.Frame + 1) + " {0:N6} fixed fixed 1 1 0 0 1 0 1;", v);
            }

            file.WriteLine(" }");
        }