private void LoadREA() { if (Editor.Parser.ANIC != null) { animationSet = CreateAnimationSet(); if (animationSet != null) { animationId = Gui.Renderer.AddAnimationSet(animationSet); renderTimer.Interval = 10; renderTimer.Tick += new EventHandler(renderTimer_Tick); AnimationSetClip(0); } textBoxANICunk1.Text = Editor.Parser.ANIC.unk1.ToString(); textBoxANICunk2.Text = Editor.Parser.ANIC.unk2.ToString(); List <reaAnimationTrack> animationTrackList = Editor.Parser.ANIC.ChildList; createAnimationTrackListView(animationTrackList); animationSetMaxKeyframes(animationTrackList); Gui.Renderer.RenderObjectAdded += new EventHandler(Renderer_RenderObjectAdded); } else { animationSetMaxKeyframes(null); } }
KeyframedAnimationSet CreateAnimationSet() { var trackList = Editor.Parser.ANIC.ChildList; if ((trackList == null) || (trackList.Count <= 0)) { return(null); } KeyframedAnimationSet set = new KeyframedAnimationSet("SetName", 1, PlaybackType.Once, trackList.Count, new CallbackKey[0]); for (int i = 0; i < trackList.Count; i++) { var track = trackList[i]; ScaleKey[] scaleKeys = new ScaleKey[track.scalings.Length]; RotationKey[] rotationKeys = new RotationKey[track.rotations.Length]; TranslationKey[] translationKeys = new TranslationKey[track.translations.Length]; set.RegisterAnimationKeys(track.boneFrame, scaleKeys, rotationKeys, translationKeys); for (int j = 0; j < track.scalings.Length; j++) { float time = track.scalings[j].index; ScaleKey scale = new ScaleKey(); scale.Time = time; scale.Value = track.scalings[j].value; //scaleKeys[j] = scale; set.SetScaleKey(i, j, scale); } for (int j = 0; j < track.rotations.Length; j++) { float time = track.rotations[j].index; RotationKey rotation = new RotationKey(); rotation.Time = time; rotation.Value = track.rotations[j].value; //rotationKeys[j] = rotation; set.SetRotationKey(i, j, rotation); } for (int j = 0; j < track.translations.Length; j++) { float time = track.translations[j].index; TranslationKey translation = new TranslationKey(); translation.Time = time; translation.Value = track.translations[j].value; //translationKeys[j] = translation; set.SetTranslationKey(i, j, translation); } } return(set); }
private void UnloadREA() { try { if (Editor.Parser.ANIC != null) { if (animationSet != null) { Pause(); renderTimer.Tick -= renderTimer_Tick; Gui.Renderer.RemoveAnimationSet(animationId); Gui.Renderer.ResetPose(); animationSet.Dispose(); animationSet = null; } Gui.Renderer.RenderObjectAdded -= new EventHandler(Renderer_RenderObjectAdded); } } catch (Exception ex) { Utility.ReportException(ex); } }
private void buttonAnimationKeyframeNew_Click(object sender, EventArgs e) { try { if (listViewAnimationTrack.SelectedItems.Count != 1) { return; } xaAnimationTrack track = (xaAnimationTrack)listViewAnimationTrack.SelectedItems[0].Tag; int animation = Editor.Parser.AnimationSection.TrackList.IndexOf(track); int timeIndex = (int)numericAnimationClipKeyframe.Value; xaAnimationKeyframe keyframe = (xaAnimationKeyframe)Gui.Scripting.RunScript(EditorVar + ".NewKeyframe(track=" + EditorVar + ".Parser.AnimationSection.TrackList[" + animation + "], index=" + timeIndex + ")"); Changed = Changed; int key = track.KeyframeList.IndexOf(keyframe); if (key >= animationSet.GetRotationKeyCount(animationSet.GetAnimationIndex(track.Name))) { if (animationSet != null) { Pause(); renderTimer.Tick -= renderTimer_Tick; Gui.Renderer.RemoveAnimationSet(animationId); animationSet.Dispose(); animationSet = null; } animationSet = CreateAnimationSet(); if (animationSet != null) { animationId = Gui.Renderer.AddAnimationSet(animationSet); renderTimer.Interval = 10; renderTimer.Tick += new EventHandler(renderTimer_Tick); Play(); } } float time = timeIndex; ScaleKey scale = new ScaleKey(); scale.Time = time; scale.Value = keyframe.Scaling; animationSet.SetScaleKey(animation, key, scale); RotationKey rotation = new RotationKey(); rotation.Time = time; rotation.Value = Quaternion.Invert(keyframe.Rotation); animationSet.SetRotationKey(animation, key, rotation); TranslationKey translation = new TranslationKey(); translation.Time = time; translation.Value = keyframe.Translation; animationSet.SetTranslationKey(animation, key, translation); AdvanceTime(0); AddTrackToEditedTracks(track); listViewAnimationTrack.SelectedItems[0].SubItems[1].Text = track.KeyframeList.Count.ToString(); listViewAnimationTrack.SelectedItems[0].SubItems[2].Text = (track.KeyframeList[track.KeyframeList.Count - 1].Index - track.KeyframeList[0].Index + 1).ToString(); DisplayNewKeyframe(true); } catch (Exception ex) { Utility.ReportException(ex); } }
private void UnloadXA() { try { if (Editor.Parser.AnimationSection != null) { if (animationSet != null) { Pause(); renderTimer.Tick -= renderTimer_Tick; Gui.Renderer.RemoveAnimationSet(animationId); animationSet.Dispose(); animationSet = null; } Gui.Renderer.RenderObjectAdded -= new EventHandler(Renderer_RenderObjectAdded); while (listViewAnimationTrack.SelectedItems.Count > 0) { listViewAnimationTrack.SelectedItems[0].Selected = false; } } setType1View(-1); } catch (Exception ex) { Utility.ReportException(ex); } }
private void LoadXA() { /*for (int i = 0; i < Editor.Parser.header.children.Count; i++) { xaSection section = (xaSection)Editor.Parser.header.children[i]; TreeNode sectionNode = new TreeNode("Section " + (i + 1)); sectionNode.Tag = section; makeXAObjectTree(section, sectionNode); treeViewXA.Nodes.Add(sectionNode); }*/ if (Editor.Parser.MaterialSection != null) { listViewType1.Items.Clear(); for (int i = 0; i < Editor.Parser.MaterialSection.MaterialList.Count; i++) { xaMaterial mat = Editor.Parser.MaterialSection.MaterialList[i]; ListViewItem item = new ListViewItem(mat.Name); item.Tag = mat; listViewType1.Items.Add(item); } listViewType1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); tabPageMaterial.Text = "Material [" + Editor.Parser.MaterialSection.MaterialList.Count + "]"; } if (Editor.Parser.MorphSection != null) { LoadMorphs(); tabControlXA.SelectTabWithoutLoosingFocus(tabPageMorph); } if (Editor.Parser.AnimationSection != null) { animationSet = CreateAnimationSet(); if (animationSet != null) { animationId = Gui.Renderer.AddAnimationSet(animationSet); renderTimer.Interval = 10; renderTimer.Tick += new EventHandler(renderTimer_Tick); Play(); } createAnimationClipDataGridView(); tabPageAnimation.Text = "Animation [" + dataGridViewAnimationClip.Rows.Count + "]"; List<xaAnimationTrack> animationTrackList = Editor.Parser.AnimationSection.TrackList; createAnimationTrackListView(animationTrackList); animationSetMaxKeyframes(animationTrackList); DisableKeyframeTabControl(); dataGridViewAnimationClip.SelectionChanged -= dataGridViewAnimationClip_SelectionChanged; tabControlXA.SelectTabWithoutLoosingFocus(tabPageAnimation); while (dataGridViewAnimationClip.SelectedRows.Count > 0) { dataGridViewAnimationClip.SelectedRows[0].Selected = false; } dataGridViewAnimationClip.SelectionChanged += dataGridViewAnimationClip_SelectionChanged; Gui.Renderer.RenderObjectAdded += new EventHandler(Renderer_RenderObjectAdded); List<DockContent> xaList = null; Gui.Docking.DockContents.TryGetValue(typeof(FormXA), out xaList); if (xaList != null && xaList.Count > 0) { FormXA syncXA = (FormXA)xaList[0]; if (syncXA.checkBoxAnimationKeyframeSyncPlay.Checked) { checkBoxAnimationKeyframeSyncPlay.CheckedChanged -= checkBoxAnimationKeyframeSyncPlay_CheckedChanged; checkBoxAnimationKeyframeSyncPlay.Checked = syncXA.checkBoxAnimationKeyframeSyncPlay.Checked; checkBoxAnimationKeyframeSyncPlay.CheckedChanged += checkBoxAnimationKeyframeSyncPlay_CheckedChanged; numericAnimationClipSpeed.ValueChanged -= numericAnimationClipSpeed_ValueChanged; numericAnimationClipSpeed.Value = syncXA.numericAnimationClipSpeed.Value; numericAnimationClipSpeed.ValueChanged += numericAnimationClipSpeed_ValueChanged; checkBoxAnimationClipLoadNextClip.CheckedChanged -= checkBoxAnimationClipLoadNextClip_CheckedChanged; checkBoxAnimationClipLoadNextClip.Checked = syncXA.checkBoxAnimationClipLoadNextClip.Checked; checkBoxAnimationClipLoadNextClip.CheckedChanged += checkBoxAnimationClipLoadNextClip_CheckedChanged; buttonAnimationClipPlayPause.ImageIndex = syncXA.buttonAnimationClipPlayPause.ImageIndex; play = syncXA.play; if (syncXA.dataGridViewAnimationClip.SelectedRows.Count > 0) { AnimationSetClip(syncXA.dataGridViewAnimationClip.SelectedRows[0].Index); } else if (syncXA.loadedAnimationClip != null) { loadedAnimationClip = dataGridViewAnimationClip.Rows[syncXA.loadedAnimationClip.Index]; } SetKeyframeNum((int)syncXA.numericAnimationClipKeyframe.Value); } } if (loadedAnimationClip == null && trackBarAnimationClipKeyframe.Value > 0) { SelectKeyframe(this, trackBarAnimationClipKeyframe.Value); } } else { animationSetMaxKeyframes(null); } }
KeyframedAnimationSet CreateAnimationSet() { var trackList = Editor.Parser.AnimationSection.TrackList; if ((trackList == null) || (trackList.Count <= 0)) { return null; } KeyframedAnimationSet set = new KeyframedAnimationSet("SetName", 1, PlaybackType.Once, trackList.Count, new CallbackKey[0]); for (int i = 0; i < trackList.Count; i++) { var track = trackList[i]; var keyframes = track.KeyframeList; ScaleKey[] scaleKeys = new ScaleKey[keyframes.Count]; RotationKey[] rotationKeys = new RotationKey[keyframes.Count]; TranslationKey[] translationKeys = new TranslationKey[keyframes.Count]; for (int k = 0; k < 10; k++) { try { set.RegisterAnimationKeys(k == 0 ? track.Name : track.Name + "_error" + k, scaleKeys, rotationKeys, translationKeys); for (int j = 0; j < keyframes.Count; j++) { float time = keyframes[j].Index; ScaleKey scale = new ScaleKey(); scale.Time = time; scale.Value = keyframes[j].Scaling; //scaleKeys[j] = scale; set.SetScaleKey(i, j, scale); RotationKey rotation = new RotationKey(); rotation.Time = time; rotation.Value = Quaternion.Invert(keyframes[j].Rotation); //rotationKeys[j] = rotation; set.SetRotationKey(i, j, rotation); TranslationKey translation = new TranslationKey(); translation.Time = time; translation.Value = keyframes[j].Translation; //translationKeys[j] = translation; set.SetTranslationKey(i, j, translation); } break; } catch (Exception ex) { switch (k) { case 0: Report.ReportLog("Error in Track: " + track.Name); Utility.ReportException(ex); break; case 9: Report.ReportLog("Aborting to register with different name. Animation will not be displayed."); break; } } } } return set; }
private void LoadREA() { if (Editor.Parser.ANIC != null) { animationSet = CreateAnimationSet(); if (animationSet != null) { animationId = Gui.Renderer.AddAnimationSet(animationSet); renderTimer.Interval = 10; renderTimer.Tick += new EventHandler(renderTimer_Tick); AnimationSetClip(0); } textBoxANICunk1.Text = Editor.Parser.ANIC.unk1.ToString(); textBoxANICunk2.Text = Editor.Parser.ANIC.unk2.ToString(); List<reaAnimationTrack> animationTrackList = Editor.Parser.ANIC.ChildList; createAnimationTrackListView(animationTrackList); animationSetMaxKeyframes(animationTrackList); Gui.Renderer.RenderObjectAdded += new EventHandler(Renderer_RenderObjectAdded); } else { animationSetMaxKeyframes(null); } }
KeyframedAnimationSet CreateAnimationSet() { var trackList = Editor.Parser.ANIC.ChildList; if ((trackList == null) || (trackList.Count <= 0)) { return null; } KeyframedAnimationSet set = new KeyframedAnimationSet("SetName", 1, PlaybackType.Once, trackList.Count, new CallbackKey[0]); for (int i = 0; i < trackList.Count; i++) { var track = trackList[i]; ScaleKey[] scaleKeys = new ScaleKey[track.scalings.Length]; RotationKey[] rotationKeys = new RotationKey[track.rotations.Length]; TranslationKey[] translationKeys = new TranslationKey[track.translations.Length]; set.RegisterAnimationKeys(track.boneFrame, scaleKeys, rotationKeys, translationKeys); for (int j = 0; j < track.scalings.Length; j++) { float time = track.scalings[j].index; ScaleKey scale = new ScaleKey(); scale.Time = time; scale.Value = track.scalings[j].value; //scaleKeys[j] = scale; set.SetScaleKey(i, j, scale); } for (int j = 0; j < track.rotations.Length; j++) { float time = track.rotations[j].index; RotationKey rotation = new RotationKey(); rotation.Time = time; rotation.Value = track.rotations[j].value; //rotationKeys[j] = rotation; set.SetRotationKey(i, j, rotation); } for (int j = 0; j < track.translations.Length; j++) { float time = track.translations[j].index; TranslationKey translation = new TranslationKey(); translation.Time = time; translation.Value = track.translations[j].value; //translationKeys[j] = translation; set.SetTranslationKey(i, j, translation); } } return set; }