/// <summary> /// Reads a list of properties from the *.anim file. /// </summary> /// <param name="Reader">The BinaryReader instance used to read the *.anim file.</param> /// <returns>A PropertyList instance filled with properties.</returns> private PropertyList ReadPropList(BinaryReader Reader) { PropertyList PList = new PropertyList(); PList.PropsCount = Endian.SwapUInt32(Reader.ReadUInt32()); for (int j = 0; j < PList.PropsCount; j++) { Property Prop = new Property(); uint PairsCount = Endian.SwapUInt32(Reader.ReadUInt32()); for (int k = 0; k < PairsCount; k++) { Prop.Key = Encoding.ASCII.GetString(Reader.ReadBytes(Reader.ReadByte())); Prop.Value = Encoding.ASCII.GetString(Reader.ReadBytes(Reader.ReadByte())); } PList.PList.Add(Prop); } return PList; }
public void Read(Stream stream) { using (var io = IoBuffer.FromStream(stream)) { var version = io.ReadUInt32(); Name = io.ReadLongPascalString(); Duration = io.ReadFloat(); Distance = io.ReadFloat(); IsMoving = io.ReadByte(); var translationCount = io.ReadUInt32(); Translations = new Vector3[translationCount]; for (var i = 0; i < translationCount; i++) { Translations[i] = new Vector3 { X = io.ReadFloat(), Y = io.ReadFloat(), Z = io.ReadFloat() }; } var rotationCount = io.ReadUInt32(); Rotations = new Vector4[rotationCount]; for (var i = 0; i < rotationCount; i++) { Rotations[i] = new Vector4 { X = io.ReadFloat(), Y = -io.ReadFloat(), Z = -io.ReadFloat(), W = io.ReadFloat() }; } var motionCount = io.ReadUInt32(); Motions = new AnimationMotion[motionCount]; for (var i = 0; i < motionCount; i++) { var motion = new AnimationMotion(); var unknown = io.ReadUInt32(); motion.BoneName = io.ReadPascalString(); motion.FrameCount = io.ReadUInt32(); motion.Duration = io.ReadFloat(); motion.HasTranslation = (io.ReadByte() == 1); motion.HasRotation = (io.ReadByte() == 1); motion.FirstTranslationIndex = io.ReadUInt32(); motion.FirstRotationIndex = io.ReadUInt32(); var hasPropsList = io.ReadByte() == 1; if (hasPropsList) { var propListCount = io.ReadUInt32(); var props = new PropertyList[propListCount]; for (var x = 0; x < propListCount; x++) { props[x] = ReadPropertyList(io); } motion.Properties = props; } var hasTimeProps = io.ReadByte() == 1; if (hasTimeProps) { var timePropsListCount = io.ReadUInt32(); var timePropsList = new TimePropertyList[timePropsListCount]; for (var x = 0; x < timePropsListCount; x++) { var list = new TimePropertyList(); var timePropsCount = io.ReadUInt32(); list.Items = new TimePropertyListItem[timePropsCount]; for (var y = 0; y < timePropsCount; y++) { var id = io.ReadUInt32(); list.Items[y] = new TimePropertyListItem { ID = id, Properties = ReadPropertyList(io) }; } timePropsList[x] = list; } motion.TimeProperties = timePropsList; } Motions[i] = motion; } } }