コード例 #1
0
        /// <summary>
        /// Initializes the light pattern from the keyframes in the animation file
        /// </summary>
        /// <param name="k"></param>
        void FromVectorAnim(Keyframes k)
        {
            // Allocate lists to hold the LEDs
            var  FrontSeq  = new List <LightFrame>();
            var  MiddleSeq = new List <LightFrame>();
            var  BackSeq   = new List <LightFrame>();
            uint lastTime  = 0;

            // Convert each of the animation files backpack lights into a
            // single internal format
            for (var I = 0; I < k.BackpackLightsKeyFrameLength; I++)
            {
                var l = k.BackpackLightsKeyFrame(I);
                if (null == l)
                {
                    continue;
                }

                // Convert the struct to frames for each of the LEDs
                lastTime = From((Anki.VectorAnim.BackpackLights)l, out var front, out var middle, out var back);

                // Append these to the list
                FrontSeq.Add(front);
                MiddleSeq.Add(middle);
                BackSeq.Add(back);
            }

            if (FrontSeq.Count == 0 && MiddleSeq.Count == 0 && BackSeq.Count == 0)
            {
                return;
            }

            // Now put that into something to hold all of them
            lightKeyFrames = new IReadOnlyList <LightFrame>[3] {
                FrontSeq, MiddleSeq, BackSeq
            };
            duration_ms = lastTime - FrontSeq[0].triggerTime_ms;
        }