internal static SdkMeshRawAnimData Read(BinaryReader reader) { var data = new SdkMeshRawAnimData { Translation = new XMFloat3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), Orientation = new XMFloat4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), Scaling = new XMFloat3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) }; return(data); }
public static SdkMeshRawAnimFile FromStream(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var file = new SdkMeshRawAnimFile(); using (var reader = new BinaryReader(stream, Encoding.UTF8, true)) { file.Header = SdkMeshRawAnimHeader.Read(reader); if (file.Header.Version != FileVersion) { throw new InvalidDataException(); } if (stream.Position != file.Header.AnimationDataOffset) { throw new InvalidDataException(); } stream.Seek(file.Header.AnimationDataOffset, SeekOrigin.Begin); for (int frameIndex = 0; frameIndex < file.Header.NumFrames; frameIndex++) { SdkMeshRawAnimFrameData frame = SdkMeshRawAnimFrameData.Read(reader); file.AnimationFrames.Add(frame); } foreach (SdkMeshRawAnimFrameData frame in file.AnimationFrames) { if (stream.Position != file.Header.AnimationDataOffset + frame.DataOffset) { throw new InvalidDataException(); } stream.Seek(file.Header.AnimationDataOffset + frame.DataOffset, SeekOrigin.Begin); for (int keyIndex = 0; keyIndex < file.Header.NumAnimationKeys; keyIndex++) { SdkMeshRawAnimData data = SdkMeshRawAnimData.Read(reader); frame.AnimationKeys.Add(data); } } if (stream.Position != file.Header.AnimationDataOffset + file.Header.AnimationDataSize) { throw new InvalidDataException(); } } return(file); }
internal SdkMeshAnimationKey(SdkMeshRawAnimData rawData) { this.Translation = rawData.Translation; this.Orientation = rawData.Orientation; this.Scaling = rawData.Scaling; }