public static EditAnimationSet CreateTestSet() { EditAnimationSet set = new EditAnimationSet(); for (int a = 0; a < 5; ++a) { EditAnimation anim = new EditAnimation(); for (int i = 0; i < a + 1; ++i) { var track = new EditTrack(); track.ledIndices = new List <int>(); track.ledIndices.Add(i); for (int j = 0; j < 3; ++j) { var kf = new EditKeyframe(); kf.time = j; kf.color = Random.ColorHSV(); track.keyframes.Add(kf); } anim.tracks.Add(track); } set.animations.Add(anim); } return(set); }
public EditKeyframe Duplicate() { var keyframe = new EditKeyframe(); keyframe.time = time; keyframe.color = color; return(keyframe); }
public void FromAnimationSet(AnimationSet set) { // Reset the animations, and read them in! animations = new List <EditAnimation>(); for (int i = 0; i < set.animations.Length; ++i) { var anim = set.getAnimation((ushort)i); var editAnim = new EditAnimation(); for (int j = 0; j < anim.trackCount; ++j) { var track = anim.GetTrack(set, (ushort)j); var editTrack = new EditTrack(); editTrack.ledIndices = new List <int>(); editTrack.ledIndices.Add(track.ledIndex); var rgbTrack = track.GetTrack(set); for (int k = 0; k < rgbTrack.keyFrameCount; ++k) { var kf = rgbTrack.GetKeyframe(set, (ushort)k); var editKf = new EditKeyframe(); editKf.time = (float)kf.time() / 1000.0f; if (kf.colorIndex() == AnimationSet.SPECIAL_COLOR_INDEX) { editKf.color = new Color32(255, 255, 255, 0); // Important part is alpha } else { editKf.color = ColorMapping.InverseRemap(set.getColor(kf.colorIndex())); } editTrack.keyframes.Add(editKf); } editAnim.tracks.Add(editTrack); } // De-duplicate tracks for (int l = 0; l < editAnim.tracks.Count; ++l) { for (int m = l + 1; m < editAnim.tracks.Count; ++m) { if (editAnim.tracks[m].keyframes.SequenceEqual(editAnim.tracks[l].keyframes, EditKeyframe.DefaultComparer)) { // Concatenate the leds editAnim.tracks[l].ledIndices.AddRange(editAnim.tracks[m].ledIndices); // Remove the second edit anim editAnim.tracks.RemoveAt(m); m--; } } } editAnim.@event = (Die.AnimationEvent)anim.animationEvent; editAnim.@specialColorType = (Die.SpecialColor)anim.specialColorType; animations.Add(editAnim); } }