예제 #1
0
    public void AddTrack(Animations.EditTrack track)
    {
        var colorAnim = CreateTrack(null);

        colorAnim.FromAnimationTrack(track, Unit);
        Repaint();
    }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        public EditTrack Duplicate()
        {
            var track = new EditTrack();

            track.ledIndices = new List <int>(ledIndices);
            if (keyframes != null)
            {
                track.keyframes = new List <EditKeyframe>(keyframes.Count);
                foreach (var keyframe in keyframes)
                {
                    track.keyframes.Add(keyframe.Duplicate());
                }
            }
            return(track);
        }
예제 #5
0
 public void FromAnimationTrack(Animations.EditTrack track, float unitSize)
 {
     ShowConfirmRemove(false);
     SetLedNumbers(track.ledIndices);
     if (track.empty)
     {
         LeftBound  = 0 * unitSize;
         RightBound = _timeline.Duration * unitSize;             //TODO
     }
     else
     {
         LeftBound  = track.firstTime * unitSize;
         RightBound = track.lastTime * unitSize;
         ColorSlider.FromAnimationKeyframes(track.keyframes, unitSize);
     }
 }