Esempio n. 1
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");
     }
 }
Esempio n. 2
0
File: Fbx.cs Progetto: kkdevs/sb3u
            public void ConvertAnimation(reaANICsection animSection, remParser parser)
            {
                ImportedSampledAnimation anim = new ImportedSampledAnimation();

                anim.TrackList = new List <ImportedAnimationSampledTrack>(animSection.Count);
                foreach (reaAnimationTrack track in animSection)
                {
                    remBone boneFrame  = rem.FindFrame(track.boneFrame, parser.BONC.rootFrame);
                    bool    isTopFrame = boneFrame != null && boneFrame.Parent == parser.BONC.rootFrame;
                    ImportedAnimationSampledTrack iTrack = ConvertTrack(track, isTopFrame);
                    anim.TrackList.Add(iTrack);
                }
                AnimationList.Add(anim);
            }
Esempio n. 3
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);
            }
        }