Exemplo n.º 1
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);
            }
        }