Пример #1
0
        public static Dictionary <Guid, MotionSequence> CopyValueWithSequenceMapping(
            Dictionary <Guid, MotionSequence> originalValue,
            Dictionary <Guid, int> newManipulatableDimensions)
        {
            var motionDuration = originalValue.Values.Max(x => x.GetDuration());
            var timeRange      = motionDuration;

            var manipulatableIds = newManipulatableDimensions.Keys;
            var value            = new Dictionary <Guid, MotionSequence>();

            foreach (var manipulatableId in manipulatableIds)
            {
                MotionSequence motionSequence;
                if (!originalValue.ContainsKey(manipulatableId))
                {
                    motionSequence = QuietMotionSequence(newManipulatableDimensions[manipulatableId],
                                                         InitialForceValue, timeRange);
                }
                else
                {
                    // 親のManipulatorのSequenceをコピー
                    motionSequence = new MotionSequence(originalValue[manipulatableId]);
                }

                value.Add(manipulatableId, motionSequence);
            }

            return(value);
        }
Пример #2
0
        public void MotionSequenceのシリアライズ()
        {
            var a = new MotionTarget(0.0f, new List <float> {
                0.0f, 1.0f, 2.0f
            });
            var b = new MotionTarget(1.0f, new List <float> {
                0.0f, 2.0f, 4.0f
            });

            var src = new MotionSequence(new List <MotionTarget> {
                a, b
            });
            var dst = new MotionSequence(MotionGeneratorSerialization.DeepClone(src.Save()));

            Assert.AreEqual(src.Sequences.Length, dst.Sequences.Length);
            for (int n = 0; n < src.Sequences.Length; ++n)
            {
                var s = src[n];
                var d = dst[n];
                Assert.AreEqual(s.Time, d.Time);
                Assert.AreEqual(s.Values.Length, d.Values.Length);
                for (int m = 0; m < s.Values.Length; ++m)
                {
                    Assert.AreEqual(s.Values[m], d.Values[m]);
                }
            }
        }
Пример #3
0
 public MotionSequence(MotionSequence origin)
 {
     Sequences = origin.Sequences.Select(x => new MotionTarget(x)).ToArray(); // DeepClone
     _index    = 0;
 }