示例#1
0
        /// <summary>
        /// Reads all the property lists in a motion.
        /// </summary>
        /// <param name="Mot">The motion that the propertylists belong to.</param>
        /// <param name="Reader">The BinaryReader instance used to read the *.anim file.</param>
        private void ReadPropertyLists(ref Motion Mot, ref BinaryReader Reader)
        {
            uint Count = Endian.SwapUInt32(Reader.ReadUInt32());

            for (int i = 0; i < Count; i++)
                Mot.PropertyLists.Add(ReadPropList(Reader));
        }
示例#2
0
        /// <summary>
        /// Reads all the timeproperty lists in a motion.
        /// </summary>
        /// <param name="Mot">The motion that the timeproperty lists belong to.</param>
        /// <param name="Reader">The BinaryReader instance used to read the *.anim file.</param>
        private void ReadTimePropertyLists(ref Motion Mot, ref BinaryReader Reader)
        {
            uint Count = Endian.SwapUInt32(Reader.ReadUInt32());

            for (int i = 0; i < Count; i++)
            {
                TimePropertyList TList = new TimePropertyList();
                TList.TimePropsCount = Endian.SwapUInt32(Reader.ReadUInt32());

                for (int j = 0; j < TList.TimePropsCount; j++)
                {
                    TimeProperty TProp = new TimeProperty();
                    TProp.TPropID = Endian.SwapUInt32(Reader.ReadUInt32());
                    TProp.PList = ReadPropList(Reader);
                }

                Mot.TimePropertyLists.Add(TList);
            }
        }
示例#3
0
        /// <summary>
        /// Reads a motion from a *.anim file.
        /// </summary>
        /// <param name="Reader">The BinaryReader instance used to read the *.anim file.</param>
        /// <returns>A Motion instance.</returns>
        private Motion ReadMotion(BinaryReader Reader)
        {
            Motion Mot = new Motion();

            Mot.Unknown = Endian.SwapUInt32(Reader.ReadUInt32());
            Mot.BoneName = Encoding.ASCII.GetString(Reader.ReadBytes(Reader.ReadByte()));
            Mot.NumFrames = Endian.SwapUInt32(Reader.ReadUInt32());
            Mot.Duration = Reader.ReadSingle() / 1000;

            Mot.HasTranslation = Reader.ReadByte();
            Mot.HasRotation = Reader.ReadByte();
            Mot.TranslationsOffset = Endian.SwapUInt32(Reader.ReadUInt32());
            Mot.RotationsOffset = Endian.SwapUInt32(Reader.ReadUInt32());

            if (Mot.HasTranslation != 0)
            {
                Mot.Translations = new float[Mot.NumFrames, 3];
                long CurrentOffset = Reader.BaseStream.Position;
                Reader.BaseStream.Seek(m_TranslationsTableOffset + 12 * Mot.TranslationsOffset, SeekOrigin.Begin);

                for (int i = 0; i < Mot.NumFrames; i++)
                {
                    Mot.Translations[i, 0] = Reader.ReadSingle();
                    Mot.Translations[i, 1] = Reader.ReadSingle();
                    Mot.Translations[i, 2] = Reader.ReadSingle();
                }

                Reader.BaseStream.Seek(CurrentOffset, SeekOrigin.Begin);
            }

            if (Mot.HasRotation != 0)
            {
                Mot.Rotations = new float[Mot.NumFrames, 4];
                long CurrentOffset = Reader.BaseStream.Position;
                Reader.BaseStream.Seek(m_RotationsTableOffset + 16 * Mot.RotationsOffset, SeekOrigin.Begin);

                for (int i = 0; i < Mot.NumFrames; i++)
                {
                    Mot.Rotations[i, 0] = Reader.ReadSingle();
                    Mot.Rotations[i, 1] = -Reader.ReadSingle();
                    Mot.Rotations[i, 2] = -Reader.ReadSingle();
                    Mot.Rotations[i, 3] = Reader.ReadSingle();
                }

                Reader.BaseStream.Seek(CurrentOffset, SeekOrigin.Begin);
            }

            Mot.HasPropertyLists = Reader.ReadByte();

            if (Mot.HasPropertyLists != 0)
            {
                ReadPropertyLists(ref Mot, ref Reader);
            }

            Mot.HasTimePropertyLists = Reader.ReadByte();

            if (Mot.HasTimePropertyLists != 0)
            {
                ReadTimePropertyLists(ref Mot, ref Reader);
            }

            return Mot;
        }