protected override void Parse(Stream s) { BinaryReader br = new BinaryReader(s); string tag = FOURCC(br.ReadUInt32()); if (Settings.Checking && tag != Tag) { throw new InvalidDataException(string.Format("Invalid Tag read: '{0}'; expected: '{1}'; at 0x{1:X8}", tag, Tag, s.Position)); } mVersion = br.ReadUInt32(); int count = br.ReadInt32(); mBounds = new BoundingBox(0, handler, s); if (mVersion >= 258) { mExtraBounds = new BoundingBoxList(handler, s); mFadeType = br.ReadUInt32(); mCustomFadeDistance = br.ReadSingle(); } else { mExtraBounds = new BoundingBoxList(handler); } mEntries = new LODEntryList(handler, s, count); }
public override Stream UnParse() { MemoryStream s = new MemoryStream(); BinaryWriter bw = new BinaryWriter(s); bw.Write((UInt32)FOURCC(Tag)); if (mExtraBounds == null) { mExtraBounds = new BoundingBoxList(handler); } if (mEntries == null) { mEntries = new LODEntryList(handler); } if (mBounds == null) { mBounds = new BoundingBox(handler); } if (mVersion < 258 && mExtraBounds.Count > 0) { mVersion = 258; } bw.Write(mVersion); bw.Write(mEntries.Count); mBounds.UnParse(s); if (mVersion >= 258) { mExtraBounds.UnParse(s); bw.Write(mFadeType); bw.Write(mCustomFadeDistance); } mEntries.UnParse(s); return(s); }
public MODL(int APIversion, EventHandler handler, uint version, BoundingBox bounds, BoundingBoxList extraBounds, uint fadeType, float customFadeDistance, LODEntryList entries) : base(APIversion, handler, null) { mVersion = version; mBounds = bounds; mExtraBounds = extraBounds == null ? null : extraBounds; mFadeType = fadeType; mCustomFadeDistance = customFadeDistance; mEntries = entries == null ? null : entries; }