public DialogResult ShowDialog(MDL0Node internalModel, MDL0Node externalModel) { _internalModel = internalModel; _externalModel = externalModel; _externalModel._renderBones = false; comboBox1.Items.AddRange(_externalModel.FindChild("Objects", true).Children.ToArray()); comboBox2.Items.AddRange(_internalModel._linker.BoneCache); comboBox1.SelectedIndex = comboBox2.SelectedIndex = comboBox3.SelectedIndex = 0; _parent = (MDL0BoneNode)comboBox2.SelectedItem; return base.ShowDialog(null); }
public void Port(MDL0Node _targetModel, MDL0Node _extModel) { MDL0BoneNode extBone; MDL0BoneNode bone; KeyframeEntry kfe; float difference = 0; foreach (CHR0EntryNode _target in Children) { extBone = (MDL0BoneNode)_extModel.FindChild(_target.Name, true); //Get external model bone bone = (MDL0BoneNode)_targetModel.FindChild(_target.Name, true); //Get target model bone for (int x = 0; x < _target.FrameCount; x++) for (int i = 0x13; i < 0x19; i++) if ((kfe = _target.GetKeyframe((KeyFrameMode)i, x)) != null) //Check for a keyframe { if (bone != null && extBone != null) switch (i) { //Translations case 0x16: //Trans X if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._x, 4)) kfe._value = bone._bindState.Translate._x; else if (bone._bindState.Translate._x < extBone._bindState.Translate._x) kfe._value -= extBone._bindState.Translate._x - bone._bindState.Translate._x; else if (bone._bindState.Translate._x > extBone._bindState.Translate._x) kfe._value += bone._bindState.Translate._x - extBone._bindState.Translate._x; break; case 0x17: //Trans Y if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._y, 4)) kfe._value = bone._bindState.Translate._y; else if (bone._bindState.Translate._y < extBone._bindState.Translate._y) kfe._value -= extBone._bindState.Translate._y - bone._bindState.Translate._y; else if (bone._bindState.Translate._y > extBone._bindState.Translate._y) kfe._value += bone._bindState.Translate._y - extBone._bindState.Translate._y; break; case 0x18: //Trans Z if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._z, 4)) kfe._value = bone._bindState.Translate._z; else if (bone._bindState.Translate._z < extBone._bindState.Translate._z) kfe._value -= extBone._bindState.Translate._z - bone._bindState.Translate._z; else if (bone._bindState.Translate._z > extBone._bindState.Translate._z) kfe._value += bone._bindState.Translate._z - extBone._bindState.Translate._z; break; //Rotations //case 0x13: //Rot X // difference = bone._bindState.Rotate._x - extBone._bindState.Rotate._x; // kfe._value += difference; // //if (difference != 0) // // FixChildren(bone, 0); // break; //case 0x14: //Rot Y // difference = bone._bindState.Rotate._y - extBone._bindState.Rotate._y; // kfe._value += difference; // //if (difference != 0) // // FixChildren(bone, 1); // break; //case 0x15: //Rot Z // difference = bone._bindState.Rotate._z - extBone._bindState.Rotate._z; // kfe._value += difference; // //if (difference != 0) // // FixChildren(bone, 2); // break; } if (kfe._value == float.NaN || kfe._value == float.PositiveInfinity || kfe._value == float.NegativeInfinity) { kfe.Remove(); _target.Keyframes._keyCounts[i]--; } } } _changed = true; }
internal void Port(MDL0Node _targetModel, MDL0Node _extModel) { MDL0BoneNode extBone; MDL0BoneNode bone; KeyframeEntry kfe; float difference = 0; foreach (CHR0EntryNode _target in Children) { extBone = (MDL0BoneNode)_extModel.FindChild(_target.Name, true); //Get external model bone bone = (MDL0BoneNode)_targetModel.FindChild(_target.Name, true); //Get target model bone for (int x = 0; x < _target.FrameCount; x++) //Loop thru each frame { for (int i = 0x13; i < 0x19; i++) //Loop thru trans { if ((kfe = _target.GetKeyframe((KeyFrameMode)i, x)) != null) //Check for a keyframe { if (bone != null && extBone != null) { switch (i) { //Translations case 0x16: //Trans X if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._x, 4)) { kfe._value = bone._bindState.Translate._x; } else if (bone._bindState.Translate._x < extBone._bindState.Translate._x) { kfe._value -= extBone._bindState.Translate._x - bone._bindState.Translate._x; } else if (bone._bindState.Translate._x > extBone._bindState.Translate._x) { kfe._value += bone._bindState.Translate._x - extBone._bindState.Translate._x; } break; case 0x17: //Trans Y if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._y, 4)) { kfe._value = bone._bindState.Translate._y; } else if (bone._bindState.Translate._y < extBone._bindState.Translate._y) { kfe._value -= extBone._bindState.Translate._y - bone._bindState.Translate._y; } else if (bone._bindState.Translate._y > extBone._bindState.Translate._y) { kfe._value += bone._bindState.Translate._y - extBone._bindState.Translate._y; } break; case 0x18: //Trans Z if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._z, 4)) { kfe._value = bone._bindState.Translate._z; } else if (bone._bindState.Translate._z < extBone._bindState.Translate._z) { kfe._value -= extBone._bindState.Translate._z - bone._bindState.Translate._z; } else if (bone._bindState.Translate._z > extBone._bindState.Translate._z) { kfe._value += bone._bindState.Translate._z - extBone._bindState.Translate._z; } break; //Rotations case 0x13: //Rot X difference = bone._bindState.Rotate._x - extBone._bindState.Rotate._x; kfe._value += difference; if (difference != 0) { FixChildren(bone, 0); } break; case 0x14: //Rot Y difference = bone._bindState.Rotate._y - extBone._bindState.Rotate._y; kfe._value += difference; if (difference != 0) { FixChildren(bone, 1); } break; case 0x15: //Rot Z difference = bone._bindState.Rotate._z - extBone._bindState.Rotate._z; kfe._value += difference; if (difference != 0) { FixChildren(bone, 2); } break; } } if (kfe._value == float.NaN || kfe._value == float.PositiveInfinity || kfe._value == float.NegativeInfinity) { kfe.Remove(); _target.Keyframes._keyCounts[i]--; } } } } } _changed = true; IsPorted = true; }
public void Port(MDL0Node _targetModel, MDL0Node _extModel) { MDL0BoneNode extBone; MDL0BoneNode bone; KeyframeEntry kfe; float difference = 0; foreach (CHR0EntryNode _target in Children) { extBone = (MDL0BoneNode)_extModel.FindChild(_target.Name, true); //Get external model bone bone = (MDL0BoneNode)_targetModel.FindChild(_target.Name, true); //Get target model bone for (int x = 0; x < _target.FrameCount; x++) { for (int i = 3; i < 9; i++) { if ((kfe = _target.GetKeyframe(i, x)) != null) //Check for a keyframe { if (bone != null && extBone != null) { switch (i) { //Translations case 6: //Trans X if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._x, 4)) { kfe._value = bone._bindState.Translate._x; } else if (bone._bindState.Translate._x < extBone._bindState.Translate._x) { kfe._value -= extBone._bindState.Translate._x - bone._bindState.Translate._x; } else if (bone._bindState.Translate._x > extBone._bindState.Translate._x) { kfe._value += bone._bindState.Translate._x - extBone._bindState.Translate._x; } break; case 7: //Trans Y if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._y, 4)) { kfe._value = bone._bindState.Translate._y; } else if (bone._bindState.Translate._y < extBone._bindState.Translate._y) { kfe._value -= extBone._bindState.Translate._y - bone._bindState.Translate._y; } else if (bone._bindState.Translate._y > extBone._bindState.Translate._y) { kfe._value += bone._bindState.Translate._y - extBone._bindState.Translate._y; } break; case 8: //Trans Z if (Math.Round(kfe._value, 4) == Math.Round(extBone._bindState.Translate._z, 4)) { kfe._value = bone._bindState.Translate._z; } else if (bone._bindState.Translate._z < extBone._bindState.Translate._z) { kfe._value -= extBone._bindState.Translate._z - bone._bindState.Translate._z; } else if (bone._bindState.Translate._z > extBone._bindState.Translate._z) { kfe._value += bone._bindState.Translate._z - extBone._bindState.Translate._z; } break; //Rotations //case 3: //Rot X // difference = bone._bindState.Rotate._x - extBone._bindState.Rotate._x; // kfe._value += difference; // //if (difference != 0) // // FixChildren(bone, 0); // break; //case 4: //Rot Y // difference = bone._bindState.Rotate._y - extBone._bindState.Rotate._y; // kfe._value += difference; // //if (difference != 0) // // FixChildren(bone, 1); // break; //case 5: //Rot Z // difference = bone._bindState.Rotate._z - extBone._bindState.Rotate._z; // kfe._value += difference; // //if (difference != 0) // // FixChildren(bone, 2); // break; } } if (kfe._value == float.NaN || kfe._value == float.PositiveInfinity || kfe._value == float.NegativeInfinity) { kfe.Remove(); _target.Keyframes._keyArrays[i]._keyCount--; } } } } } _changed = true; }