private void FixChildren(MDL0BoneNode node, int axis) { KeyframeEntry kfe; foreach (MDL0BoneNode b in node.Children) { CHR0EntryNode _target = (CHR0EntryNode)FindChild(b.Name, true); if (_target != null) { switch (axis) { case 0: //X, correct Y and Z for (int l = 0; l < _target.FrameCount; l++) { for (int g = 0x13; g < 0x16; g++) { if (g != 0x13) { if ((kfe = _target.GetKeyframe((KeyFrameMode)g, l)) != null) { kfe._value *= -1; } } } } break; case 1: //Y, correct X and Z for (int l = 0; l < _target.FrameCount; l++) { for (int g = 0x13; g < 0x16; g++) { if (g != 0x14) { if ((kfe = _target.GetKeyframe((KeyFrameMode)g, l)) != null) { kfe._value *= -1; } } } } break; case 2: //Z, correct X and Y for (int l = 0; l < _target.FrameCount; l++) { for (int g = 0x13; g < 0x16; g++) { if (g != 0x15) { if ((kfe = _target.GetKeyframe((KeyFrameMode)g, l)) != null) { kfe._value *= -1; } } } } break; } } FixChildren(b, axis); } }
public void MergeWith(CHR0Node external) { if (external.FrameCount != FrameCount && MessageBox.Show(null, "Frame counts are not equal; the shorter animation will end early. Do you still wish to continue?", "", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (external.FrameCount > FrameCount) { FrameCount = external.FrameCount; } foreach (CHR0EntryNode _extTarget in external.Children) { CHR0EntryNode node = null; KeyframeEntry kfe = null; CHR0EntryNode entry = new CHR0EntryNode() { Name = _extTarget.Name }; entry._numFrames = _extTarget.FrameCount; //Apply all external keyframes to current entry. for (int x = 0; x < _extTarget.FrameCount; x++) { for (int i = 0x10; i < 0x19; i++) { if ((kfe = _extTarget.GetKeyframe((KeyFrameMode)i, x)) != null) { entry.Keyframes.SetFrameValue((KeyFrameMode)i, x, kfe._value)._tangent = kfe._tangent; } } } if ((node = FindChild(_extTarget.Name, false) as CHR0EntryNode) == null) { AddChild(entry, true); } else { DialogResult result = MessageBox.Show(null, "A bone entry with the name " + _extTarget.Name + " already exists.\nDo you want to rename this entry?\nOtherwise, you will have the option to merge the keyframes.", "Rename Entry?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { Top: RenameDialog d = new RenameDialog(); if (d.ShowDialog(null, entry) == DialogResult.OK) { if (entry.Name != _extTarget.Name) { AddChild(entry, true); } else { MessageBox.Show("The name wasn't changed!"); goto Top; } } } else if (result == DialogResult.No) { result = MessageBox.Show(null, "Do you want to merge the keyframes of the entries?", "Merge Keyframes?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { KeyframeEntry kfe2 = null; if (_extTarget.FrameCount > node.FrameCount) { node._numFrames = _extTarget.FrameCount; } //Merge all external keyframes with the current entry. for (int x = 0; x < _extTarget.FrameCount; x++) { for (int i = 0x10; i < 0x19; i++) { if ((kfe = _extTarget.GetKeyframe((KeyFrameMode)i, x)) != null) { if ((kfe2 = node.GetKeyframe((KeyFrameMode)i, x)) == null) { node.SetKeyframe((KeyFrameMode)i, x, kfe._value); } else { result = MessageBox.Show(null, "A keyframe at frame " + x + " already exists.\nOld value: " + kfe2._value + "\nNew value:" + kfe._value + "\nReplace the old value with the new one?", "Replace Keyframe?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { node.SetKeyframe((KeyFrameMode)i, x, kfe._value); } else if (result == DialogResult.Cancel) { Restore(); return; } } } } } } else if (result == DialogResult.Cancel) { Restore(); return; } } else if (result == DialogResult.Cancel) { Restore(); return; } } } }