示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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;
        }
示例#4
0
        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;
        }