public void Merge(MotionController other) { foreach (var keyController in other.KeyControllers) { var baseKeyController = KeyControllers.FirstOrDefault(x => x.Name.Equals(keyController.Name, StringComparison.OrdinalIgnoreCase)); if (baseKeyController == null) { KeyControllers.Add(keyController); } else { baseKeyController.Merge(keyController); } } Parent.FrameCount = Math.Max(Parent.FrameCount, other.Parent.FrameCount); }
public MotionController GetController(SkeletonEntry skeletonEntry = null, MotionDatabase motionDatabase = null) { if (mController != null) { return(mController); } if (skeletonEntry == null) { throw new ArgumentNullException(nameof(skeletonEntry)); } var controller = new MotionController(this); int index = 0; foreach (var boneInfo in BoneInfos) { if (motionDatabase != null && boneInfo.Id >= motionDatabase.BoneNames.Count) { break; } boneInfo.Name = boneInfo.Name ?? motionDatabase?.BoneNames[boneInfo.Id] ?? throw new ArgumentNullException(nameof(motionDatabase)); var boneEntry = skeletonEntry.GetBoneEntry(boneInfo.Name); var keyController = new KeyController { Name = boneInfo.Name }; if (boneEntry != null) { if (boneEntry.Type != BoneType.Rotation) { keyController.Position = new KeySetVector { X = KeySets[index++], Y = KeySets[index++], Z = KeySets[index++], } } ; if (boneEntry.Type != BoneType.Position) { keyController.Rotation = new KeySetVector { X = KeySets[index++], Y = KeySets[index++], Z = KeySets[index++], } } ; } else if (!skeletonEntry.BoneNames2.Contains(boneInfo.Name)) { keyController.Position = new KeySetVector { X = KeySets[index++], Y = KeySets[index++], Z = KeySets[index++], } } ; controller.KeyControllers.Add(keyController); } return(mController = controller); }