Example #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");
     }
 }
Example #2
0
File: Fbx.cs Project: kkdevs/sb3u
            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);
            }