Ejemplo n.º 1
0
        private void ProcessDragDropAnimations(TreeNode node)
        {
            if (node.Tag is DragSource)
            {
                if ((node.Parent != null) && !node.Checked && node.StateImageIndex != (int)CheckState.Indeterminate)
                {
                    return;
                }

                DragSource source = (DragSource)node.Tag;
                if (source.Type == typeof(WorkspaceAnimation))
                {
                    var srcEditor = (ImportedEditor)Gui.Scripting.Variables[source.Variable];
                    WorkspaceAnimation wsAnimation = srcEditor.Animations[(int)source.Id];
                    using (var dragOptions = new FormREADragDrop(Editor))
                    {
                        int resampleCount = -1;
                        if (wsAnimation.importedAnimation is ImportedKeyframedAnimation)
                        {
                            dragOptions.labelAnimationConvertion.Text = "\"" + node.Text + "\"" + dragOptions.labelAnimationConvertion.Text;
                            dragOptions.labelAnimationConvertion.Visible = true;
                        }
                        else if (wsAnimation.importedAnimation is ImportedSampledAnimation)
                        {
                            List<ImportedAnimationSampledTrack> samTrackList = ((ImportedSampledAnimation)wsAnimation.importedAnimation).TrackList;
                            int normalizeLength = samTrackList[0].Scalings.Length;
                            foreach (ImportedAnimationSampledTrack track in samTrackList)
                            {
                                if (track.Scalings.Length != track.Rotations.Length ||
                                    track.Rotations.Length != track.Translations.Length)
                                {
                                    dragOptions.labelNormalizationWarning.Text = "\"" + node.Text + "\"" + dragOptions.labelNormalizationWarning.Text;
                                    dragOptions.labelNormalizationWarning.Visible = true;
                                    break;
                                }
                            }
                        }
                        dragOptions.numericResample.Value = resampleCount;
                        dragOptions.comboBoxMethod.SelectedIndex = (int)ReplaceAnimationMethod.ReplacePresent;
                        if (dragOptions.ShowDialog() == DialogResult.OK)
                        {
                            if (wsAnimation.importedAnimation is ImportedKeyframedAnimation)
                            {
                                Gui.Scripting.RunScript(EditorVar + ".ConvertAnimation(animation=" + source.Variable + ".Animations[" + (int)source.Id + "])");
                                FormWorkspace.UpdateAnimationNode(node, wsAnimation);
                            }

                            // repeating only final choices for repeatability of the script
                            List<ImportedAnimationSampledTrack> trackList = ((ImportedSampledAnimation)wsAnimation.importedAnimation).TrackList;
                            for (int i = 0; i < trackList.Count; i++)
                            {
                                ImportedAnimationTrack track = trackList[i];
                                if (!wsAnimation.isTrackEnabled(track))
                                {
                                    Gui.Scripting.RunScript(source.Variable + ".setTrackEnabled(animationId=" + (int)source.Id + ", id=" + i + ", enabled=false)");
                                }
                            }
                            Gui.Scripting.RunScript(EditorVar + ".ReplaceAnimation(animation=" + source.Variable + ".Animations[" + (int)source.Id + "], skeleton=" + source.Variable + ".Frames, resampleCount=" + dragOptions.numericResample.Value + ", linear=" + dragOptions.radioButtonInterpolationLinear.Checked + ", method=\"" + dragOptions.comboBoxMethod.SelectedItem + "\", insertPos=" + dragOptions.numericPosition.Value + ", negateQuaternionFlips=" + dragOptions.checkBoxNegateQuaternionFlips.Checked + ")");
                            UnloadREA();
                            LoadREA();
                        }
                    }
                }
            }
            else
            {
                foreach (TreeNode child in node.Nodes)
                {
                    ProcessDragDropAnimations(child);
                }
            }
        }
Ejemplo n.º 2
0
        private void ProcessDragDropAnimations(TreeNode node)
        {
            if (node.Tag is DragSource)
            {
                if ((node.Parent != null) && !node.Checked && node.StateImageIndex != (int)CheckState.Indeterminate)
                {
                    return;
                }

                DragSource source = (DragSource)node.Tag;
                if (source.Type == typeof(WorkspaceAnimation))
                {
                    var srcEditor = (ImportedEditor)Gui.Scripting.Variables[source.Variable];
                    WorkspaceAnimation wsAnimation = srcEditor.Animations[(int)source.Id];
                    using (var dragOptions = new FormREADragDrop(Editor))
                    {
                        int resampleCount = -1;
                        if (wsAnimation.importedAnimation is ImportedKeyframedAnimation)
                        {
                            dragOptions.labelAnimationConvertion.Text    = "\"" + node.Text + "\"" + dragOptions.labelAnimationConvertion.Text;
                            dragOptions.labelAnimationConvertion.Visible = true;
                        }
                        else if (wsAnimation.importedAnimation is ImportedSampledAnimation)
                        {
                            List <ImportedAnimationSampledTrack> samTrackList = ((ImportedSampledAnimation)wsAnimation.importedAnimation).TrackList;
                            int normalizeLength = samTrackList[0].Scalings.Length;
                            foreach (ImportedAnimationSampledTrack track in samTrackList)
                            {
                                if (track.Scalings.Length != track.Rotations.Length ||
                                    track.Rotations.Length != track.Translations.Length)
                                {
                                    dragOptions.labelNormalizationWarning.Text    = "\"" + node.Text + "\"" + dragOptions.labelNormalizationWarning.Text;
                                    dragOptions.labelNormalizationWarning.Visible = true;
                                    break;
                                }
                            }
                        }
                        dragOptions.numericResample.Value        = resampleCount;
                        dragOptions.comboBoxMethod.SelectedIndex = (int)ReplaceAnimationMethod.ReplacePresent;
                        if (dragOptions.ShowDialog() == DialogResult.OK)
                        {
                            if (wsAnimation.importedAnimation is ImportedKeyframedAnimation)
                            {
                                Gui.Scripting.RunScript(EditorVar + ".ConvertAnimation(animation=" + source.Variable + ".Animations[" + (int)source.Id + "])");
                                FormWorkspace.UpdateAnimationNode(node, wsAnimation);
                            }

                            // repeating only final choices for repeatability of the script
                            List <ImportedAnimationSampledTrack> trackList = ((ImportedSampledAnimation)wsAnimation.importedAnimation).TrackList;
                            for (int i = 0; i < trackList.Count; i++)
                            {
                                ImportedAnimationTrack track = trackList[i];
                                if (!wsAnimation.isTrackEnabled(track))
                                {
                                    Gui.Scripting.RunScript(source.Variable + ".setTrackEnabled(animationId=" + (int)source.Id + ", id=" + i + ", enabled=false)");
                                }
                            }
                            Gui.Scripting.RunScript(EditorVar + ".ReplaceAnimation(animation=" + source.Variable + ".Animations[" + (int)source.Id + "], skeleton=" + source.Variable + ".Frames, resampleCount=" + dragOptions.numericResample.Value + ", linear=" + dragOptions.radioButtonInterpolationLinear.Checked + ", method=\"" + dragOptions.comboBoxMethod.SelectedItem + "\", insertPos=" + dragOptions.numericPosition.Value + ", negateQuaternionFlips=" + dragOptions.checkBoxNegateQuaternionFlips.Checked + ")");
                            UnloadREA();
                            LoadREA();
                        }
                    }
                }
            }
            else
            {
                foreach (TreeNode child in node.Nodes)
                {
                    ProcessDragDropAnimations(child);
                }
            }
        }