示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Warcraft.MDX.Animation.MDXTrack{T}"/> class.
        /// </summary>
        /// <param name="br"></param>
        /// <param name="version">Format.</param>
        /// <param name="valueless">
        /// If this value is true, it indicates that no values are associated with
        /// this track, and any value-related reading should be skipped.
        /// </param>
        public MDXTrack(BinaryReader br, WarcraftVersion version, bool valueless = false)
        {
            this.Interpolationtype = (InterpolationType)br.ReadUInt16();
            this.GlobalSequenceID  = br.ReadUInt16();

            if (version < WarcraftVersion.Wrath)
            {
                this.IsComposite = true;
                this.CompositeTimelineInterpolationRanges = br.ReadMDXArray <IntegerRange>();
                this.CompositeTimelineTimestamps          = br.ReadMDXArray <uint>();

                if (valueless)
                {
                    return;
                }

                // HACK: MDXTracks with quaternions need to have the version passed along
                if (typeof(T) == typeof(Quaternion))
                {
                    this.CompositeTimelineValues = br.ReadMDXArray <T>(version);
                }
                else
                {
                    this.CompositeTimelineValues = br.ReadMDXArray <T>();
                }
            }
            else
            {
                this.IsComposite = false;
                this.Timestamps  = br.ReadMDXArray <MDXArray <uint> >();

                if (valueless)
                {
                    return;
                }

                // HACK: MDXTracks with quaternions need to have the version passed along
                if (typeof(T) == typeof(Quaternion))
                {
                    this.Values = br.ReadMDXArray <MDXArray <T> >(version);
                }
                else
                {
                    this.Values = br.ReadMDXArray <MDXArray <T> >();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Warcraft.MDX.Animation.MDXTrack</c>"/> class.
        /// This class fires off a new BinaryReader, as it outreferences values elsewhere in the file.
        /// The value references in the track are not filled, as they can be a number of different types.
        /// When used, you must fill the values yourself after the creation of the track.
        /// </summary>
        /// <param name="data">Data.</param>
        /// <param name="filePath">File path to the M2 file.</param>
        /// <param name="Format">Format.</param>
        public MDXTrack(byte[] data, string filePath, WarcraftVersion Format)
        {
            using (MemoryStream ms = new MemoryStream(data))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.Interpolationtype = (InterpolationType)br.ReadInt16();
                    this.GlobalSequenceID  = br.ReadInt16();

                    if (Format < WarcraftVersion.Wrath)
                    {
                        this.InterpolationRanges = new MDXArray <KeyValuePair <int, int> >(br.ReadBytes(8));
                        this.Timestamps          = new MDXArray <MDXArray <int> >(br.ReadBytes(8));
                        this.Values = new MDXArray <MDXArray <T> >(br.ReadBytes(8));
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }
        }