private static void WriteKey(Animation.KeyGroup keys)
 {
     foreach (Animation.KeyFrame key in keys.Keys)
     {
     }
 }
Exemple #2
0
        private static void writeKey(StreamWriter file, Animation.KeyGroup keys, Animation.KeyNode rt, int size, string type)
        {
            file.WriteLine("animData {\n input time;\n output linear;\n weighted 1;\n preInfinity constant;\n postInfinity constant;\n 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":
                    v = key.Value;
                    break;

                case "translateY":
                    v = key.Value;
                    break;

                case "translateZ":
                    v = key.Value;
                    break;

                case "rotateX":
                    if (rt.RotType == Animation.RotationType.EULER)
                    {
                        v = key.Value * (float)(180f / Math.PI);
                    }
                    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 *(float)(180f / Math.PI);
                    }
                    break;

                case "rotateY":
                    if (rt.RotType == Animation.RotationType.EULER)
                    {
                        v = key.Value * (float)(180f / Math.PI);
                    }
                    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 *(float)(180f / Math.PI);
                    }
                    break;

                case "rotateZ":
                    if (rt.RotType == Animation.RotationType.EULER)
                    {
                        v = key.Value * (float)(180f / Math.PI);
                    }
                    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 *(float)(180f / Math.PI);
                    }
                    break;

                case "scaleX":
                    v = key.Value;
                    break;

                case "scaleY":
                    v = key.Value;
                    break;

                case "scaleZ":
                    v = key.Value;
                    break;
                }

                file.WriteLine(" " + (key.Frame + 1) + " {0:N6} fixed fixed 1 1 0 " + key.In * (float)(180f / Math.PI) + " 1 " + key.In * (float)(180f / Math.PI) + " 1;", v);
            }

            file.WriteLine(" }");
        }