Exemple #1
0
 private void listViewAnimationTrack_AfterLabelEdit(object sender, LabelEditEventArgs e)
 {
     try
     {
         if (e.Label != null)
         {
             string name = e.Label.Trim();
             if (name == String.Empty)
             {
                 e.CancelEdit = true;
             }
             else
             {
                 reaAnimationTrack keyframeList = (reaAnimationTrack)listViewAnimationTrack.Items[e.Item].Tag;
                 Gui.Scripting.RunScript(EditorVar + ".RenameTrack(track=\"" + keyframeList.boneFrame + "\", newName=\"" + e.Label.Trim() + "\")");
                 UnloadREA();
                 LoadREA();
             }
         }
     }
     catch (Exception ex)
     {
         Utility.ReportException(ex);
     }
 }
Exemple #2
0
 public reaParser(Stream stream)
 {
     try
     {
         using (BinaryReader reader = new BinaryReader(stream))
         {
             byte[] type = reader.ReadBytes(4);
             Trace.Assert(remParser.TypeCheck(reaANICsection.ClassType, type));
             int   anicLength = reader.ReadInt32();
             int   unk1       = reader.ReadInt32();
             float unk2       = reader.ReadSingle();
             int   count      = reader.ReadInt32();
             ANIC      = new reaANICsection(count);
             ANIC.unk1 = unk1;
             ANIC.unk2 = unk2;
             for (int i = 0; i < count; i++)
             {
                 reaAnimationTrack track = new reaAnimationTrack();
                 type = reader.ReadBytes(4);
                 Trace.Assert(remParser.TypeCheck(reaAnimationTrack.ClassType, type));
                 int    anioLength = reader.ReadInt32();
                 byte[] name       = reader.ReadBytes(256);
                 track.boneFrame = remParser.GetIdentifier(name, 0, 256);
                 int numScalings = reader.ReadInt32();
                 track.scalings = new reaIndexVector[numScalings];
                 int numRotations = reader.ReadInt32();
                 track.rotations = new reaIndexQuaternion[numRotations];
                 int numTranslations = reader.ReadInt32();
                 track.translations = new reaIndexVector[numTranslations];
                 for (int j = 0; j < numScalings; j++)
                 {
                     reaIndexVector ivec = new reaIndexVector();
                     ivec.index        = reader.ReadInt32();
                     ivec.value        = reader.ReadVector3();
                     track.scalings[j] = ivec;
                 }
                 for (int j = 0; j < numRotations; j++)
                 {
                     reaIndexQuaternion iq = new reaIndexQuaternion();
                     iq.index           = reader.ReadInt32();
                     iq.value           = reader.ReadQuaternion();
                     track.rotations[j] = iq;
                 }
                 for (int j = 0; j < numTranslations; j++)
                 {
                     reaIndexVector ivec = new reaIndexVector();
                     ivec.index            = reader.ReadInt32();
                     ivec.value            = reader.ReadVector3();
                     track.translations[j] = ivec;
                 }
                 ANIC.AddChild(track);
             }
         }
     }
     catch (FileNotFoundException)
     {
         Report.ReportLog("file not found");
     }
 }
Exemple #3
0
            public static reaAnimationTrack ConvertTrack(ImportedAnimationSampledTrack wsTrack, bool isTopFrame)
            {
                reaAnimationTrack track = new reaAnimationTrack();

                track.boneFrame = new remId(wsTrack.Name);

                List <reaIndexVector> scalings = new List <reaIndexVector>();

                for (int i = 0; i < wsTrack.Scalings.Length; i++)
                {
                    Vector3?scale = wsTrack.Scalings[i];
                    if (scale == null)
                    {
                        continue;
                    }

                    reaIndexVector scaleKey = new reaIndexVector();
                    scaleKey.index = i;
                    scaleKey.value = new Vector3(scale.Value.X, isTopFrame ? -scale.Value.Z : scale.Value.Z, scale.Value.Y);
                    scalings.Add(scaleKey);
                }
                track.scalings = scalings.ToArray();

                List <reaIndexQuaternion> rotations = new List <reaIndexQuaternion>();

                for (int i = 0; i < wsTrack.Rotations.Length; i++)
                {
                    Quaternion?rotate = wsTrack.Rotations[i];
                    if (rotate == null)
                    {
                        continue;
                    }

                    reaIndexQuaternion rotateKey = new reaIndexQuaternion();
                    rotateKey.index = i;
                    rotateKey.value = Quaternion.Invert(rotate.Value);
                    rotations.Add(rotateKey);
                }
                track.rotations = rotations.ToArray();

                List <reaIndexVector> translations = new List <reaIndexVector>();

                for (int i = 0; i < wsTrack.Scalings.Length; i++)
                {
                    Vector3?translate = wsTrack.Translations[i];
                    if (translate == null)
                    {
                        continue;
                    }

                    reaIndexVector translateKey = new reaIndexVector();
                    translateKey.index = i;
                    translateKey.value = translate.Value;
                    translations.Add(translateKey);
                }
                track.translations = translations.ToArray();

                return(track);
            }
Exemple #4
0
 private void createAnimationTrackListView(List <reaAnimationTrack> animationTrackList)
 {
     if (animationTrackList.Count > 0)
     {
         listViewAnimationTrack.BeginUpdate();
         listViewAnimationTrack.Items.Clear();
         for (int i = 0; i < animationTrackList.Count; i++)
         {
             reaAnimationTrack track = animationTrackList[i];
             ListViewItem      item  = new ListViewItem(new string[] { track.boneFrame.ToString(), track.scalings.Length.ToString() + "/" + track.rotations.Length.ToString() + "/" + track.translations.Length.ToString(), (track.scalings[track.scalings.Length - 1].index + 1).ToString() + "/" + (track.rotations[track.rotations.Length - 1].index + 1).ToString() + "/" + (track.translations[track.translations.Length - 1].index + 1).ToString() });
             item.Tag = track;
             listViewAnimationTrack.Items.Add(item);
         }
         listViewAnimationTrack.EndUpdate();
     }
 }
Exemple #5
0
            public static ImportedAnimationSampledTrack ConvertTrack(reaAnimationTrack track, bool isTopFrame)
            {
                ImportedAnimationSampledTrack iTrack = new ImportedAnimationSampledTrack();

                iTrack.Name = track.boneFrame;
                int animLen = track.scalings[track.scalings.Length - 1].index + 1;

                iTrack.Scalings = new Vector3?[animLen];
                if (isTopFrame)
                {
                    for (int i = 0; i < track.scalings.Length; i++)
                    {
                        Vector3 scale = new Vector3(track.scalings[i].value.X, track.scalings[i].value.Z, -track.scalings[i].value.Y);
                        iTrack.Scalings[track.scalings[i].index] = scale;
                    }
                }
                else
                {
                    for (int i = 0; i < track.scalings.Length; i++)
                    {
                        Vector3 scale = new Vector3(track.scalings[i].value.X, track.scalings[i].value.Z, track.scalings[i].value.Y);
                        iTrack.Scalings[track.scalings[i].index] = scale;
                    }
                }

                animLen          = track.rotations[track.rotations.Length - 1].index + 1;
                iTrack.Rotations = new Quaternion?[animLen];
                for (int i = 0; i < track.rotations.Length; i++)
                {
                    iTrack.Rotations[track.rotations[i].index] = Quaternion.Invert(track.rotations[i].value);
                }

                animLen             = track.translations[track.translations.Length - 1].index + 1;
                iTrack.Translations = new Vector3?[animLen];
                for (int i = 0; i < track.translations.Length; i++)
                {
                    iTrack.Translations[track.translations[i].index] = track.translations[i].value;
                }

                return(iTrack);
            }
Exemple #6
0
        public static void ReplaceAnimation(WorkspaceAnimation wsAnimation, List <ImportedFrame> wsSkeleton, reaParser parser, int resampleCount, bool linear, ReplaceAnimationMethod replaceMethod, int insertPos, bool negateQuaternionFlips)
        {
            Report.ReportLog("Replacing animation ...");
            List <KeyValuePair <string, ImportedAnimationSampledTrack> > newTrackList = FbxUtility.CopySampledAnimation(wsAnimation, resampleCount, linear);

            reaANICsection           animationNodeList = parser.ANIC;
            ImportedSampledAnimation iAnim             = new ImportedSampledAnimation();

            iAnim.TrackList = new List <ImportedAnimationSampledTrack>(animationNodeList.Count);
            Dictionary <string, ImportedAnimationSampledTrack> animationNodeDic = null;

            if (replaceMethod != ReplaceAnimationMethod.Replace)
            {
                animationNodeDic = new Dictionary <string, ImportedAnimationSampledTrack>();
                foreach (reaAnimationTrack animationNode in animationNodeList)
                {
                    ImportedFrame boneFrame              = ImportedHelpers.FindFrame(animationNode.boneFrame, wsSkeleton[0]);
                    bool          isTopFrame             = boneFrame != null && boneFrame.Parent == wsSkeleton[0];
                    ImportedAnimationSampledTrack iTrack = Plugins.REMConverter.ConvertTrack(animationNode, isTopFrame);
                    iTrack.Name = animationNode.boneFrame;
                    animationNodeDic.Add(animationNode.boneFrame, iTrack);
                    iAnim.TrackList.Add(iTrack);
                }
            }

            FbxUtility.ReplaceAnimation(replaceMethod, insertPos, newTrackList, iAnim, animationNodeDic, negateQuaternionFlips);

            animationNodeList.ChildList.Clear();
            foreach (var newTrack in iAnim.TrackList)
            {
                ImportedFrame     boneFrame     = ImportedHelpers.FindFrame(newTrack.Name, wsSkeleton[0]);
                bool              isTopFrame    = boneFrame != null && boneFrame.Parent == wsSkeleton[0];
                reaAnimationTrack animationNode = Plugins.REMConverter.ConvertTrack(newTrack, isTopFrame);
                animationNodeList.AddChild(animationNode);
            }
        }
Exemple #7
0
        public void RemoveTrack(string track)
        {
            reaAnimationTrack reaTrack = rea.FindTrack(new remId(track), Parser);

            Parser.ANIC.RemoveChild(reaTrack);
        }
Exemple #8
0
        public void RenameTrack(string track, string newName)
        {
            reaAnimationTrack reaTrack = rea.FindTrack(new remId(track), Parser);

            reaTrack.boneFrame = new remId(newName);
        }