private static void WriteAnimKey(StreamWriter file, int i, DAT_Animation.DATAnimTrack track, bool rotation) { file.WriteLine("animData {\n input time;\n output linear;\n weighted 1;\n preInfinity constant;\n postInfinity constant;\n keys {"); int size = track.keys.Count; int time = 0; float cvalue = 0, ctan = 0; for (int f = 0; f < size; f++) { while (track.keys[f].interpolationType == DAT_Animation.InterpolationType.HermiteCurve) { f++; } DAT_Animation.KeyNode no = track.keys[f]; DAT_Animation.KeyNode curve = track.keys[f + 1 >= track.keys.Count ? 0: f + 1]; if (curve.interpolationType == DAT_Animation.InterpolationType.HermiteCurve) { cvalue = no.value; ctan = curve.tan; file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 {1:N6} 1 {2:N6} 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1), no.tan, ctan); } else { switch (no.interpolationType) { case DAT_Animation.InterpolationType.Hermite: { cvalue = no.value; ctan = no.tan; file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 {1:N6} 1 {2:N6} 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1), ctan, ctan); } break; case DAT_Animation.InterpolationType.HermiteValue: { cvalue = no.value; ctan = 0; file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 {1:N6} 1 {2:N6} 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1), ctan, ctan); } break; case DAT_Animation.InterpolationType.Step: { cvalue = no.value; file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 0 1 0 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1)); } break; case DAT_Animation.InterpolationType.Linear: { cvalue = no.value; file.WriteLine(" " + (time + 1) + " {0:N6} linear linear 1 1 0", cvalue * (rotation ? 180 / (float)Math.PI : 1)); } break; } } time += (int)no.frame; } file.WriteLine(" }"); file.WriteLine("}"); }
private static Animation.KeyGroup CreateKeyGroup(int i, DAT_Animation.DATAnimTrack track, bool rotation) { Animation.KeyGroup group = new Animation.KeyGroup(); int size = track.keys.Count; int time = 0; float cvalue = 0, ctan = 0; for (int f = 0; f < size; f++) { while (track.keys[f].interpolationType == DAT_Animation.InterpolationType.HermiteCurve) { f++; } DAT_Animation.KeyNode no = track.keys[f]; DAT_Animation.KeyNode curve = track.keys[f + 1 >= track.keys.Count ? 0 : f + 1]; if (curve.interpolationType == DAT_Animation.InterpolationType.HermiteCurve) { cvalue = no.value; ctan = curve.tan; group.Keys.Add(new Animation.KeyFrame() { Weighted = true, Frame = time, Value = cvalue, In = no.tan, Out = ctan, InterType = Animation.InterpolationType.HERMITE }); //file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 {1:N6} 1 {2:N6} 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1), no.tan, ctan); } else { switch (no.interpolationType) { case DAT_Animation.InterpolationType.Hermite: { cvalue = no.value; ctan = no.tan; group.Keys.Add(new Animation.KeyFrame() { Weighted = true, Frame = time, Value = cvalue, In = ctan, Out = ctan, InterType = Animation.InterpolationType.HERMITE }); //file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 {1:N6} 1 {2:N6} 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1), ctan, ctan); } break; case DAT_Animation.InterpolationType.HermiteValue: { cvalue = no.value; ctan = 0; group.Keys.Add(new Animation.KeyFrame() { Weighted = true, Frame = time, Value = cvalue, In = ctan, Out = ctan, InterType = Animation.InterpolationType.HERMITE }); //file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 {1:N6} 1 {2:N6} 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1), ctan, ctan); } break; case DAT_Animation.InterpolationType.Step: { cvalue = no.value; group.Keys.Add(new Animation.KeyFrame() { Weighted = false, Frame = time, Value = cvalue, InterType = Animation.InterpolationType.STEP }); //file.WriteLine(" " + (time + 1) + " {0:N6} fixed fixed 1 1 0 0 1 0 1;", cvalue * (rotation ? 180 / (float)Math.PI : 1)); } break; case DAT_Animation.InterpolationType.Linear: { cvalue = no.value; group.Keys.Add(new Animation.KeyFrame() { Weighted = false, Frame = time, Value = cvalue, InterType = Animation.InterpolationType.LINEAR }); //file.WriteLine(" " + (time + 1) + " {0:N6} linear linear 1 1 0", cvalue * (rotation ? 180 / (float)Math.PI : 1)); } break; } } time += (int)no.frame; } return(group); }